use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class FirmwareUpdateServiceTest method testUpdateFirmware_noFirmwareUpdateHandler.
@Test
public void testUpdateFirmware_noFirmwareUpdateHandler() {
Thing thing4 = ThingBuilder.create(THING_TYPE_UID_WITHOUT_FW, THING5_ID).build();
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(equalTo(String.format("There is no firmware update handler for thing with UID %s.", thing4.getUID())));
firmwareUpdateService.updateFirmware(thing4.getUID(), FW009_EN.getUID(), null);
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class ThingActionService method getThingStatusInfo.
public static ThingStatusInfo getThingStatusInfo(String thingUid) {
ThingUID uid = new ThingUID(thingUid);
Thing thing = thingRegistry.get(uid);
if (thing != null) {
return thing.getStatusInfo();
} else {
return null;
}
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class MagicHandlerFactoryTest method shoudlReturnDimmableLightHandler.
@Test
public void shoudlReturnDimmableLightHandler() {
Thing thing = mock(Thing.class);
when(thing.getThingTypeUID()).thenReturn(MagicBindingConstants.THING_TYPE_DIMMABLE_LIGHT);
assertThat(factory.createHandler(thing), is(instanceOf(MagicDimmableLightHandler.class)));
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class GenericItemChannelLinkProviderJavaTest method testLinkConfiguration.
@Test
public void testLinkConfiguration() {
Collection<Thing> things = thingRegistry.getAll();
assertThat(things.size(), is(0));
String thingsModel = "Bridge hue:bridge:huebridge [ ipAddress = \"192.168.3.84\", userName = \"19fc3fa6fc870a4280a55f21315631f\" ] {" + //
"LCT001 bulb3 [ lightId = \"3\" ]" + //
"LCT001 bulb4 [ lightId = \"3\" ]" + "}";
modelRepository.addOrRefreshModel(THINGS_TESTMODEL_NAME, new ByteArrayInputStream(thingsModel.getBytes()));
String itemsModel = "Color Light3Color \"Light3 Color\" { channel=\"hue:LCT001:huebridge:bulb3:color\" [ foo=\"bar\", answer=42, always=true ] }" + "Group:Switch:MAX TestSwitches";
modelRepository.addOrRefreshModel(ITEMS_TESTMODEL_NAME, new ByteArrayInputStream(itemsModel.getBytes()));
waitForAssert(() -> {
assertThat(thingRegistry.getAll().size(), is(3));
assertThat(itemRegistry.getItems().size(), is(2));
assertThat(itemChannelLinkRegistry.getAll().size(), is(1));
});
ItemChannelLink link = itemChannelLinkRegistry.get("Light3Color -> hue:LCT001:huebridge:bulb3:color");
assertNotNull(link);
assertEquals("Light3Color", link.getItemName());
assertEquals("hue:LCT001:huebridge:bulb3:color", link.getLinkedUID().toString());
assertEquals("bar", link.getConfiguration().get("foo"));
assertEquals(new BigDecimal(42), link.getConfiguration().get("answer"));
assertEquals(true, link.getConfiguration().get("always"));
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class GenericItemChannelLinkProviderJavaTest method testIntegrationWithGenericItemProvider.
@Test
public void testIntegrationWithGenericItemProvider() throws Exception {
// Wait for the ChannelItemProvider to join the game
Thread.sleep(2500);
Collection<Thing> things = thingRegistry.getAll();
assertThat(things.size(), is(0));
String thingsModel = "Bridge hue:bridge:huebridge [ ipAddress = \"192.168.3.84\", userName = \"19fc3fa6fc870a4280a55f21315631f\" ] {" + "LCT001 bulb3 [ lightId = \"3\" ]" + "LCT001 bulb4 [ lightId = \"3\" ]" + "}";
modelRepository.addOrRefreshModel(THINGS_TESTMODEL_NAME, new ByteArrayInputStream(thingsModel.getBytes()));
Collection<Thing> actualThings = thingRegistry.getAll();
assertThat(actualThings.size(), is(3));
assertThat(itemRegistry.getItems().size(), is(0));
assertThat(itemChannelLinkRegistry.getAll().size(), is(0));
String itemsModel = "Color Light3Color \"Light3 Color\" { channel=\"hue:LCT001:huebridge:bulb3:color\" }" + "Group:Switch:MAX TestSwitches";
// Initially load the model
modelRepository.addOrRefreshModel(ITEMS_TESTMODEL_NAME, new ByteArrayInputStream(itemsModel.getBytes()));
assertThat(itemRegistry.getItems().size(), is(2));
assertThat(itemChannelLinkRegistry.getAll().size(), is(1));
// Update the model to run into GenericItemChannelLinkProvider's amnesia
modelRepository.addOrRefreshModel(ITEMS_TESTMODEL_NAME, new ByteArrayInputStream(itemsModel.getBytes()));
assertThat(itemRegistry.getItems().size(), is(2));
assertThat(itemChannelLinkRegistry.getAll().size(), is(1));
// Remove the model (-> the link and therefore the item is kept)
modelRepository.removeModel(ITEMS_TESTMODEL_NAME);
assertThat(itemRegistry.getItems().size(), is(0));
assertThat(itemChannelLinkRegistry.getAll().size(), is(0));
// Now add the model again
modelRepository.addOrRefreshModel(ITEMS_TESTMODEL_NAME, new ByteArrayInputStream(itemsModel.getBytes()));
// -> ensure ChannelItemProvider cleans up properly
assertThat(itemRegistry.getItems().size(), is(2));
assertThat(itemChannelLinkRegistry.getAll().size(), is(1));
}
Aggregations