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"));
}
Aggregations