Search in sources :

Example 6 with ThingHandlerCallback

use of org.eclipse.smarthome.core.thing.binding.ThingHandlerCallback in project smarthome by eclipse.

the class ChaserThingHandlerTest method initializeTestBridge.

private void initializeTestBridge() {
    bridgeProperties = new HashMap<>();
    bridge = BridgeBuilder.create(THING_TYPE_TEST_BRIDGE, "testbridge").withLabel("Test Bridge").withConfiguration(new Configuration(bridgeProperties)).build();
    dmxBridgeHandler = new TestBridgeHandler(bridge);
    bridge.setHandler(dmxBridgeHandler);
    ThingHandlerCallback bridgeHandler = mock(ThingHandlerCallback.class);
    doAnswer(answer -> {
        ((Thing) answer.getArgument(0)).setStatusInfo(answer.getArgument(1));
        return null;
    }).when(bridgeHandler).statusUpdated(any(), any());
    dmxBridgeHandler.setCallback(bridgeHandler);
    dmxBridgeHandler.initialize();
}
Also used : TestBridgeHandler(org.eclipse.smarthome.binding.dmx.test.TestBridgeHandler) Configuration(org.eclipse.smarthome.config.core.Configuration) ThingHandlerCallback(org.eclipse.smarthome.core.thing.binding.ThingHandlerCallback) Thing(org.eclipse.smarthome.core.thing.Thing)

Example 7 with ThingHandlerCallback

use of org.eclipse.smarthome.core.thing.binding.ThingHandlerCallback in project smarthome by eclipse.

the class DmxBridgeHandlerTest method setUp.

@Before
public void setUp() {
    bridgeProperties = new HashMap<>();
    bridge = BridgeBuilder.create(THING_TYPE_TEST_BRIDGE, "testbridge").withLabel("Test Bridge").withChannel(ChannelBuilder.create(CHANNEL_UID_MUTE, "Switch").withType(MUTE_CHANNEL_TYPEUID).build()).withConfiguration(new Configuration(bridgeProperties)).build();
    ThingHandlerCallback mockCallback = mock(ThingHandlerCallback.class);
    doAnswer(answer -> {
        ((Thing) answer.getArgument(0)).setStatusInfo(answer.getArgument(1));
        return null;
    }).when(mockCallback).statusUpdated(any(), any());
    bridgeHandler = Mockito.spy(new DmxBridgeHandlerImpl(bridge));
    bridgeHandler.getThing().setHandler(bridgeHandler);
    bridgeHandler.setCallback(mockCallback);
    bridgeHandler.initialize();
}
Also used : Configuration(org.eclipse.smarthome.config.core.Configuration) ThingHandlerCallback(org.eclipse.smarthome.core.thing.binding.ThingHandlerCallback) Thing(org.eclipse.smarthome.core.thing.Thing) Before(org.junit.Before)

Example 8 with ThingHandlerCallback

use of org.eclipse.smarthome.core.thing.binding.ThingHandlerCallback in project smarthome by eclipse.

the class SacnBridgeHandlerTest method setUp.

@Before
public void setUp() {
    bridgeProperties = new HashMap<>();
    bridgeProperties.put(CONFIG_ADDRESS, TEST_ADDRESS);
    bridgeProperties.put(CONFIG_UNIVERSE, TEST_UNIVERSE);
    bridgeProperties.put(CONFIG_SACN_MODE, "unicast");
    bridge = BridgeBuilder.create(THING_TYPE_SACN_BRIDGE, "sacnbridge").withLabel("sACN Bridge").withChannel(ChannelBuilder.create(CHANNEL_UID_MUTE, "Switch").withType(MUTE_CHANNEL_TYPEUID).build()).withConfiguration(new Configuration(bridgeProperties)).build();
    ThingHandlerCallback mockCallback = mock(ThingHandlerCallback.class);
    doAnswer(answer -> {
        ((Thing) answer.getArgument(0)).setStatusInfo(answer.getArgument(1));
        return null;
    }).when(mockCallback).statusUpdated(any(), any());
    bridgeHandler = new SacnBridgeHandler(bridge) {

        @Override
        protected void validateConfigurationParameters(Map<String, Object> configurationParameters) {
        }
    };
    bridgeHandler.getThing().setHandler(bridgeHandler);
    bridgeHandler.setCallback(mockCallback);
    bridgeHandler.initialize();
}
Also used : Configuration(org.eclipse.smarthome.config.core.Configuration) ThingHandlerCallback(org.eclipse.smarthome.core.thing.binding.ThingHandlerCallback) SacnBridgeHandler(org.eclipse.smarthome.binding.dmx.handler.SacnBridgeHandler) Thing(org.eclipse.smarthome.core.thing.Thing) Before(org.junit.Before)

Aggregations

ThingHandlerCallback (org.eclipse.smarthome.core.thing.binding.ThingHandlerCallback)8 Thing (org.eclipse.smarthome.core.thing.Thing)7 Configuration (org.eclipse.smarthome.config.core.Configuration)6 Before (org.junit.Before)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 TestBridgeHandler (org.eclipse.smarthome.binding.dmx.test.TestBridgeHandler)2 BaseThingHandler (org.eclipse.smarthome.core.thing.binding.BaseThingHandler)2 ThingHandler (org.eclipse.smarthome.core.thing.binding.ThingHandler)2 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)2 Test (org.junit.Test)2 NonNull (org.eclipse.jdt.annotation.NonNull)1 ArtnetBridgeHandler (org.eclipse.smarthome.binding.dmx.handler.ArtnetBridgeHandler)1 Lib485BridgeHandler (org.eclipse.smarthome.binding.dmx.handler.Lib485BridgeHandler)1 SacnBridgeHandler (org.eclipse.smarthome.binding.dmx.handler.SacnBridgeHandler)1 Channel (org.eclipse.smarthome.core.thing.Channel)1 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)1 ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)1 BaseThingHandlerFactory (org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory)1 ThingHandlerFactory (org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory)1 ChannelBuilder (org.eclipse.smarthome.core.thing.binding.builder.ChannelBuilder)1