Class: OpenHAB::RSpec::Mocks::OSGiEventManager
- Inherits:
-
Object
- Object
- OpenHAB::RSpec::Mocks::OSGiEventManager
- Defined in:
- lib/openhab/rspec/mocks/event_admin.rb
Overview
reimplement to not use a thread
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #handle_event(osgi_event) ⇒ Object
-
#initialize(typed_event_factories, typed_event_subscribers) ⇒ OSGiEventManager
constructor
A new instance of OSGiEventManager.
Constructor Details
#initialize(typed_event_factories, typed_event_subscribers) ⇒ OSGiEventManager
Returns a new instance of OSGiEventManager.
12 13 14 15 16 |
# File 'lib/openhab/rspec/mocks/event_admin.rb', line 12 def initialize(typed_event_factories, typed_event_subscribers) @typed_event_factories = typed_event_factories @typed_event_subscribers = typed_event_subscribers @logger = org.slf4j.LoggerFactory.get_logger("rspec.openhab.core.mocks.event_handler") end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
10 11 12 |
# File 'lib/openhab/rspec/mocks/event_admin.rb', line 10 def logger @logger end |
Instance Method Details
#handle_event(osgi_event) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/openhab/rspec/mocks/event_admin.rb', line 18 def handle_event(osgi_event) type = osgi_event.get_property("type") payload = osgi_event.get_property("payload") topic = osgi_event.get_property("topic") source = osgi_event.get_property("source") if type.is_a?(String) && payload.is_a?(String) && topic.is_a?(String) handle_event_internal(type, payload, topic, source) unless type.empty? || payload.empty? || topic.empty? else logger.error("The handled OSGi event is invalid. " \ "Expect properties as string named 'type', 'payload', and 'topic'. " \ "Received event properties are: #{osgi_event.property_names.inspect}") end end |