Search in sources :

Example 81 with Thing

use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.

the class ArtnetBridgeHandlerTest method setUp.

@Before
public void setUp() {
    bridgeProperties = new HashMap<>();
    bridgeProperties.put(CONFIG_ADDRESS, TEST_ADDRESS);
    bridgeProperties.put(CONFIG_UNIVERSE, TEST_UNIVERSE);
    bridge = BridgeBuilder.create(THING_TYPE_ARTNET_BRIDGE, "artnetbridge").withLabel("Artnet 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 ArtnetBridgeHandler(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) ArtnetBridgeHandler(org.eclipse.smarthome.binding.dmx.handler.ArtnetBridgeHandler) ThingHandlerCallback(org.eclipse.smarthome.core.thing.binding.ThingHandlerCallback) Thing(org.eclipse.smarthome.core.thing.Thing) Before(org.junit.Before)

Example 82 with Thing

use of org.eclipse.smarthome.core.thing.Thing 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 83 with Thing

use of org.eclipse.smarthome.core.thing.Thing 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 84 with Thing

use of org.eclipse.smarthome.core.thing.Thing 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)

Example 85 with Thing

use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.

the class FirmwareUpdateService method validateFirmwareSuitability.

private void validateFirmwareSuitability(Firmware firmware, FirmwareUpdateHandler firmwareUpdateHandler) {
    Thing thing = firmwareUpdateHandler.getThing();
    if (!firmware.isSuitableFor(thing)) {
        throw new IllegalArgumentException(String.format("Firmware with UID %s is not suitable for thing with UID %s.", firmware.getUID(), thing.getUID()));
    }
    String firmwareVersion = getThingFirmwareVersion(firmwareUpdateHandler);
    if (firmware.getPrerequisiteVersion() != null && !firmware.isPrerequisiteVersion(firmwareVersion)) {
        throw new IllegalArgumentException(String.format("Firmware with UID %s requires at least firmware version %s to get installed. But the current firmware version of the thing with UID %s is %s.", firmware.getUID(), firmware.getPrerequisiteVersion(), thing.getUID(), firmwareVersion));
    }
}
Also used : Thing(org.eclipse.smarthome.core.thing.Thing)

Aggregations

Thing (org.eclipse.smarthome.core.thing.Thing)98 Test (org.junit.Test)43 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)28 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)24 Configuration (org.eclipse.smarthome.config.core.Configuration)19 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)19 JavaTest (org.eclipse.smarthome.test.java.JavaTest)18 ThingHandler (org.eclipse.smarthome.core.thing.binding.ThingHandler)14 ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)13 ApiOperation (io.swagger.annotations.ApiOperation)9 ApiResponses (io.swagger.annotations.ApiResponses)9 Item (org.eclipse.smarthome.core.items.Item)9 Path (javax.ws.rs.Path)8 Nullable (org.eclipse.jdt.annotation.Nullable)8 Locale (java.util.Locale)7 RolesAllowed (javax.annotation.security.RolesAllowed)7 Channel (org.eclipse.smarthome.core.thing.Channel)7 ThingHandlerCallback (org.eclipse.smarthome.core.thing.binding.ThingHandlerCallback)7 Command (org.eclipse.smarthome.core.types.Command)7 List (java.util.List)6