Search in sources :

Example 26 with Thing

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));
}
Also used : ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID) Thing(org.eclipse.smarthome.core.thing.Thing) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 27 with Thing

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)));
}
Also used : Thing(org.eclipse.smarthome.core.thing.Thing) Test(org.junit.Test)

Example 28 with Thing

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)));
}
Also used : Thing(org.eclipse.smarthome.core.thing.Thing) Test(org.junit.Test)

Example 29 with Thing

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()));
}
Also used : ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID) Thing(org.eclipse.smarthome.core.thing.Thing) Test(org.junit.Test)

Example 30 with Thing

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"));
}
Also used : Configuration(org.eclipse.smarthome.config.core.Configuration) HashMap(java.util.HashMap) Thing(org.eclipse.smarthome.core.thing.Thing) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

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