Search in sources :

Example 16 with ChannelTypeUID

use of org.eclipse.smarthome.core.thing.type.ChannelTypeUID in project smarthome by eclipse.

the class ChannelTypeResourceTest method returnLinkableItemTypesForTriggerChannelType.

@SuppressWarnings("unchecked")
@Test
public void returnLinkableItemTypesForTriggerChannelType() throws IOException {
    ChannelType channelType = mockChannelType("ct");
    ChannelTypeUID uid = channelType.getUID();
    ProfileTypeUID profileTypeUID = new ProfileTypeUID("system:profileType");
    when(channelTypeRegistry.getChannelType(uid)).thenReturn(channelType);
    TriggerProfileType profileType = mock(TriggerProfileType.class);
    when(profileType.getUID()).thenReturn(profileTypeUID);
    when(profileType.getSupportedChannelTypeUIDs()).thenReturn(Collections.singletonList(uid));
    when(profileType.getSupportedItemTypes()).thenReturn(Arrays.asList("Switch", "Dimmer"));
    when(profileTypeRegistry.getProfileTypes()).thenReturn(Collections.singletonList(profileType));
    Response response = channelTypeResource.getLinkableItemTypes(uid.getAsString());
    verify(channelTypeRegistry).getChannelType(uid);
    verify(profileTypeRegistry).getProfileTypes();
    assertThat(response.getStatus(), is(200));
    assertThat((Set<String>) response.getEntity(), IsCollectionContaining.hasItems("Switch", "Dimmer"));
}
Also used : Response(javax.ws.rs.core.Response) TriggerProfileType(org.eclipse.smarthome.core.thing.profiles.TriggerProfileType) ChannelTypeUID(org.eclipse.smarthome.core.thing.type.ChannelTypeUID) ChannelType(org.eclipse.smarthome.core.thing.type.ChannelType) ProfileTypeUID(org.eclipse.smarthome.core.thing.profiles.ProfileTypeUID) Test(org.junit.Test)

Aggregations

ChannelTypeUID (org.eclipse.smarthome.core.thing.type.ChannelTypeUID)16 ChannelType (org.eclipse.smarthome.core.thing.type.ChannelType)9 StateDescription (org.eclipse.smarthome.core.types.StateDescription)4 ArrayList (java.util.ArrayList)3 Locale (java.util.Locale)3 ChannelDefinition (org.eclipse.smarthome.core.thing.type.ChannelDefinition)3 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 MeteringTypeEnum (org.eclipse.smarthome.binding.digitalstrom.internal.lib.structure.devices.deviceparameters.constants.MeteringTypeEnum)2 ItemRegistry (org.eclipse.smarthome.core.items.ItemRegistry)2 Channel (org.eclipse.smarthome.core.thing.Channel)2 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)2 TriggerProfileType (org.eclipse.smarthome.core.thing.profiles.TriggerProfileType)2 ChannelTypeProvider (org.eclipse.smarthome.core.thing.type.ChannelTypeProvider)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Collection (java.util.Collection)1