use of org.eclipse.smarthome.core.thing.type.ThingType in project smarthome by eclipse.
the class ThingManagerOSGiJavaTest method registerThingTypeProvider.
private void registerThingTypeProvider() throws Exception {
ThingType thingType = ThingTypeBuilder.instance(THING_TYPE_UID, "label").withConfigDescriptionURI(CONFIG_DESCRIPTION_THING).withChannelDefinitions(Collections.singletonList(new ChannelDefinition("channel", CHANNEL_TYPE_UID))).build();
ThingTypeProvider mockThingTypeProvider = mock(ThingTypeProvider.class);
when(mockThingTypeProvider.getThingType(eq(THING_TYPE_UID), any())).thenReturn(thingType);
registerService(mockThingTypeProvider);
}
use of org.eclipse.smarthome.core.thing.type.ThingType in project smarthome by eclipse.
the class ThingPropertiesTest method setup.
@Before
public void setup() {
ThingType thingType = ThingTypeBuilder.instance(new ThingTypeUID("bindingId", "thingTypeId"), "label").withProperties(properties).build();
thing = ThingFactory.createThing(thingType, new ThingUID(thingType.getUID(), "thingId"), new Configuration());
}
use of org.eclipse.smarthome.core.thing.type.ThingType in project smarthome by eclipse.
the class SystemChannelsInChannelGroupsTest method thingTypesWithSystemChannelsInChannelsGoupsShouldHavePorperChannelDefinitions.
@Test
public void thingTypesWithSystemChannelsInChannelsGoupsShouldHavePorperChannelDefinitions() throws Exception {
// install test bundle
Bundle sysBundle = SyntheticBundleInstaller.install(bundleContext, SYSTEM_CHANNELS_IN_CHANNEL_GROUPS_BUNDLE_NAME);
assertThat(sysBundle, is(notNullValue()));
List<ThingType> thingTypes = thingTypeProvider.getThingTypes(null).stream().filter(it -> it.getUID().getId().equals("wireless-router")).collect(Collectors.toList());
assertThat(thingTypes.size(), is(1));
List<ChannelGroupType> channelGroupTypes = channelTypeRegistry.getChannelGroupTypes();
ChannelGroupType channelGroup = channelGroupTypes.stream().filter(it -> it.getUID().equals(new ChannelGroupTypeUID("SystemChannelsInChannelGroups:channelGroup"))).findFirst().get();
assertThat(channelGroup, is(notNullValue()));
List<ChannelDefinition> channelDefs = channelGroup.getChannelDefinitions();
List<ChannelDefinition> myChannel = channelDefs.stream().filter(it -> it.getId().equals("test") && it.getChannelTypeUID().getAsString().equals("system:my-channel")).collect(Collectors.toList());
List<ChannelDefinition> sigStr = channelDefs.stream().filter(it -> it.getId().equals("sigstr") && it.getChannelTypeUID().getAsString().equals("system:signal-strength")).collect(Collectors.toList());
List<ChannelDefinition> lowBat = channelDefs.stream().filter(it -> it.getId().equals("lowbat") && it.getChannelTypeUID().getAsString().equals("system:low-battery")).collect(Collectors.toList());
assertThat(myChannel.size(), is(1));
assertThat(sigStr.size(), is(1));
assertThat(lowBat.size(), is(1));
}
use of org.eclipse.smarthome.core.thing.type.ThingType in project smarthome by eclipse.
the class SystemChannelsInChannelGroupsTest method systemChannelsInChannelGroupsShouldLoadAndUnload.
@Test
public void systemChannelsInChannelGroupsShouldLoadAndUnload() throws Exception {
int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size();
int initialNumberOfChannelTypes = channelTypeRegistry.getChannelTypes().size();
int initialNumberOfChannelGroupTypes = channelTypeRegistry.getChannelGroupTypes().size();
// install test bundle
Bundle bundle = SyntheticBundleInstaller.install(bundleContext, SYSTEM_CHANNELS_IN_CHANNEL_GROUPS_BUNDLE_NAME);
assertThat(bundle, is(notNullValue()));
Collection<ThingType> thingTypes = thingTypeProvider.getThingTypes(null);
assertThat(thingTypes.size(), is(initialNumberOfThingTypes + 1));
assertThat(channelTypeRegistry.getChannelTypes().size(), is(initialNumberOfChannelTypes + 1));
assertThat(channelTypeRegistry.getChannelGroupTypes().size(), is(initialNumberOfChannelGroupTypes + 1));
// uninstall test bundle
bundle.uninstall();
assertThat(bundle.getState(), is(Bundle.UNINSTALLED));
assertThat(thingTypeProvider.getThingTypes(null).size(), is(initialNumberOfThingTypes));
assertThat(channelTypeRegistry.getChannelTypes().size(), is(initialNumberOfChannelTypes));
assertThat(channelTypeRegistry.getChannelGroupTypes().size(), is(initialNumberOfChannelGroupTypes));
}
use of org.eclipse.smarthome.core.thing.type.ThingType in project smarthome by eclipse.
the class SystemWideChannelTypesTest method systemChannelsShouldTranslateProperly.
@Test
public void systemChannelsShouldTranslateProperly() throws Exception {
int initialNumberOfThingTypes = thingTypeProvider.getThingTypes(null).size();
// install test bundle
Bundle sysBundle = SyntheticBundleInstaller.install(bundleContext, SYSTEM_CHANNELS_BUNDLE_NAME);
assertThat(sysBundle, is(notNullValue()));
Collection<ThingType> thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN);
assertThat(thingTypes.size(), is(initialNumberOfThingTypes + 1));
ThingType wirelessRouterType = thingTypes.stream().filter(it -> it.getUID().getAsString().equals("SystemChannels:wireless-router")).findFirst().get();
assertThat(wirelessRouterType, is(notNullValue()));
List<ChannelDefinition> channelDefs = wirelessRouterType.getChannelDefinitions();
assertThat(channelDefs.size(), is(3));
ChannelDefinition myChannel = channelDefs.stream().filter(it -> it.getId().equals("test") && it.getChannelTypeUID().getAsString().equals("system:my-channel")).findFirst().get();
assertThat(myChannel, is(notNullValue()));
ChannelDefinition sigStr = channelDefs.stream().filter(it -> it.getId().equals("sigstr") && it.getChannelTypeUID().getAsString().equals("system:signal-strength")).findFirst().get();
assertThat(sigStr, is(notNullValue()));
ChannelDefinition lowBat = channelDefs.stream().filter(it -> it.getId().equals("lowbat") && it.getChannelTypeUID().getAsString().equals("system:low-battery")).findFirst().get();
assertThat(lowBat, is(notNullValue()));
assertThat(channelTypeRegistry.getChannelType(myChannel.getChannelTypeUID(), Locale.GERMAN).getLabel(), is("Mein String My Channel"));
assertThat(channelTypeRegistry.getChannelType(myChannel.getChannelTypeUID(), Locale.GERMAN).getDescription(), is("Wetterinformation mit My Channel Type Beschreibung"));
assertThat(myChannel.getLabel(), is("Mein String My Channel"));
assertThat(myChannel.getDescription(), is("Wetterinformation mit My Channel Type Beschreibung"));
assertThat(channelTypeRegistry.getChannelType(sigStr.getChannelTypeUID(), Locale.GERMAN).getLabel(), is("Signalstärke"));
assertThat(sigStr.getLabel(), is("Meine spezial Signalstärke"));
assertThat(sigStr.getDescription(), is("Meine spezial Beschreibung für Signalstärke"));
assertThat(channelTypeRegistry.getChannelType(lowBat.getChannelTypeUID(), Locale.GERMAN).getLabel(), is("Niedriger Batteriestatus"));
assertThat(lowBat.getLabel(), is("Niedriger Batteriestatus"));
assertThat(lowBat.getDescription(), is(nullValue()));
}
Aggregations