use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class FirmwareTest method testNotModelRestrictedFirmwareIsSuitableForThingWithSameThingType.
@Test
public void testNotModelRestrictedFirmwareIsSuitableForThingWithSameThingType() {
Firmware firmware = new Firmware.Builder(new FirmwareUID(new ThingTypeUID("binding:thingTypeA"), "version")).build();
Thing thing = ThingBuilder.create(new ThingTypeUID("binding:thingTypeA"), "thing").build();
assertThat(firmware.isSuitableFor(thing), is(true));
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class MagicHandlerFactoryTest method shoudlReturnOnOffLightHandler.
@Test
public void shoudlReturnOnOffLightHandler() {
Thing thing = mock(Thing.class);
when(thing.getThingTypeUID()).thenReturn(MagicBindingConstants.THING_TYPE_ON_OFF_LIGHT);
assertThat(factory.createHandler(thing), is(instanceOf(MagicOnOffLightHandler.class)));
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class MagicHandlerFactoryTest method shoudlReturnColorLightHandler.
@Test
public void shoudlReturnColorLightHandler() {
Thing thing = mock(Thing.class);
when(thing.getThingTypeUID()).thenReturn(MagicBindingConstants.THING_TYPE_COLOR_LIGHT);
assertThat(factory.createHandler(thing), is(instanceOf(MagicColorLightHandler.class)));
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class MagicHandlerFactoryTest method shoudlReturnNullForUnknownThingTypeUID.
@Test
public void shoudlReturnNullForUnknownThingTypeUID() {
Thing thing = mock(Thing.class);
when(thing.getThingTypeUID()).thenReturn(new ThingTypeUID("anyBinding:someThingType"));
assertThat(factory.createHandler(thing), is(nullValue()));
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class PersistentInboxTest method testConfigUpdateNormalization_guessType.
@Test
public void testConfigUpdateNormalization_guessType() {
Map<String, Object> props = new HashMap<>();
props.put("foo", 1);
Configuration config = new Configuration(props);
Thing thing = ThingBuilder.create(THING_TYPE_UID, THING_UID).withConfiguration(config).build();
when(thingRegistry.get(eq(THING_UID))).thenReturn(thing);
assertTrue(thing.getConfiguration().get("foo") instanceof BigDecimal);
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty("foo", 3).build());
assertTrue(thing.getConfiguration().get("foo") instanceof BigDecimal);
assertEquals(new BigDecimal(3), thing.getConfiguration().get("foo"));
}
Aggregations