-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jimmy Tanagra <[email protected]>
- Loading branch information
Showing
4 changed files
with
66 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "item_state_event" | ||
|
||
module OpenHAB | ||
module Core | ||
module Events | ||
begin | ||
java_import org.openhab.core.items.events.ItemStateUpdatedEvent | ||
|
||
# | ||
# {AbstractEvent} sent when an item's state has updated. | ||
# | ||
class ItemStateUpdatedEvent < ItemEvent | ||
include ItemState | ||
end | ||
rescue | ||
# @deprecated OH3.4 OH3 will raise an error ItemStateUpdatedEvent is only in OH4 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
if OpenHAB::Core::Events.const_defined?(:ItemStateUpdatedEvent) # @deprecated OH3.4 - remove if | ||
RSpec.describe OpenHAB::Core::Events::ItemStateUpdatedEvent do | ||
it "has proper predicates for a NULL event" do | ||
event = org.openhab.core.items.events.ItemEventFactory.create_state_updated_event("item", NULL) | ||
|
||
expect(event).to be_null | ||
expect(event).not_to be_undef | ||
expect(event.state?).to be false | ||
expect(event.state).to be_nil | ||
end | ||
|
||
it "has proper predicates for an UNDEF event" do | ||
event = org.openhab.core.items.events.ItemEventFactory.create_state_updated_event("item", UNDEF) | ||
|
||
expect(event).not_to be_null | ||
expect(event).to be_undef | ||
expect(event.state?).to be false | ||
expect(event.state).to be_nil | ||
end | ||
|
||
it "has proper predicates for an ON event" do | ||
event = org.openhab.core.items.events.ItemEventFactory.create_state_updated_event("item", ON) | ||
|
||
expect(event).not_to be_null | ||
expect(event).not_to be_undef | ||
expect(event.state?).to be true | ||
expect(event.state).to be ON | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters