use of org.openhab.core.thing.type.ThingType in project openhab-core by openhab.
the class SystemWideChannelTypesTest method systemChannelsShouldTranslateProperly.
@Test
public void systemChannelsShouldTranslateProperly() throws Exception {
try (final AutoCloseable unused = loadedSystemChannelsBundle()) {
Collection<ThingType> thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN);
ThingType wirelessRouterType = thingTypes.stream().filter(it -> "SystemChannels:wireless-router".equals(it.getUID().getAsString())).findFirst().get();
assertNotNull(wirelessRouterType);
List<ChannelDefinition> channelDefs = wirelessRouterType.getChannelDefinitions();
assertEquals(3, channelDefs.size());
ChannelDefinition myChannel = channelDefs.stream().filter(it -> "test".equals(it.getId()) && "system:my-channel".equals(it.getChannelTypeUID().getAsString())).findFirst().get();
assertNotNull(myChannel);
ChannelDefinition sigStr = channelDefs.stream().filter(it -> "sigstr".equals(it.getId()) && "system:signal-strength".equals(it.getChannelTypeUID().getAsString())).findFirst().get();
assertNotNull(sigStr);
ChannelDefinition lowBat = channelDefs.stream().filter(it -> "lowbat".equals(it.getId()) && "system:low-battery".equals(it.getChannelTypeUID().getAsString())).findFirst().get();
assertNotNull(lowBat);
ChannelType lowBatType = systemChannelTypeProvider.getChannelType(lowBat.getChannelTypeUID(), Locale.GERMAN);
ChannelType myChannelChannelType = channelTypeRegistry.getChannelType(myChannel.getChannelTypeUID(), Locale.GERMAN);
assertNotNull(myChannelChannelType);
assertEquals("Mein String My Channel", myChannelChannelType.getLabel());
assertEquals("Wetterinformation mit My Channel Type Beschreibung", myChannelChannelType.getDescription());
assertEquals("Mein String My Channel", myChannel.getLabel());
assertEquals("Wetterinformation mit My Channel Type Beschreibung", myChannel.getDescription());
assertEquals("Meine spezial Signalstärke", sigStr.getLabel());
assertEquals("Meine spezial Beschreibung für Signalstärke", sigStr.getDescription());
assertEquals("Niedriger Batteriestatus", lowBatType.getLabel());
assertNull(lowBatType.getDescription());
}
}
use of org.openhab.core.thing.type.ThingType in project openhab-core by openhab.
the class ThingTypeI18nTest method channelsInGroupTypeShouldBeLocalized.
@Test
public void channelsInGroupTypeShouldBeLocalized() throws Exception {
try (final AutoCloseable unused = loadedTestBundle()) {
Collection<ThingType> thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN);
ThingType weatherGroupType = thingTypes.stream().filter(it -> "acmeweather:weather-with-group".equals(it.toString())).findFirst().get();
assertNotNull(weatherGroupType);
assertEquals(2, weatherGroupType.getChannelGroupDefinitions().size());
ChannelGroupDefinition forecastTodayChannelGroupDefinition = weatherGroupType.getChannelGroupDefinitions().stream().filter(it -> "forecastToday".equals(it.getId())).findFirst().get();
assertNotNull(forecastTodayChannelGroupDefinition);
ChannelGroupType forecastTodayChannelGroupType = channelGroupTypeRegistry.getChannelGroupType(forecastTodayChannelGroupDefinition.getTypeUID(), Locale.GERMAN);
assertNotNull(forecastTodayChannelGroupType);
assertEquals(3, forecastTodayChannelGroupType.getChannelDefinitions().size());
ChannelDefinition temperatureChannelDefinition = forecastTodayChannelGroupType.getChannelDefinitions().stream().filter(it -> "temperature".equals(it.getId())).findFirst().get();
assertNotNull(temperatureChannelDefinition);
assertEquals("Temperatur", temperatureChannelDefinition.getLabel());
assertEquals("Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).", temperatureChannelDefinition.getDescription());
ChannelDefinition minTemperatureChannelDefinition = forecastTodayChannelGroupType.getChannelDefinitions().stream().filter(it -> "minTemperature".equals(it.getId())).findFirst().get();
assertNotNull(minTemperatureChannelDefinition);
assertEquals("Min. Temperatur", minTemperatureChannelDefinition.getLabel());
assertEquals("Minimale vorhergesagte Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).", minTemperatureChannelDefinition.getDescription());
ChannelDefinition maxTemperatureChannelDefinition = forecastTodayChannelGroupType.getChannelDefinitions().stream().filter(it -> "maxTemperature".equals(it.getId())).findFirst().get();
assertNotNull(maxTemperatureChannelDefinition);
assertEquals("Max. Temperatur", maxTemperatureChannelDefinition.getLabel());
assertEquals("Maximale vorhergesagte Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).", maxTemperatureChannelDefinition.getDescription());
}
}
use of org.openhab.core.thing.type.ThingType in project openhab-core by openhab.
the class ThingTypeI18nTest method channelGroupTypeShouldBeLocalized.
@Test
public void channelGroupTypeShouldBeLocalized() throws Exception {
try (final AutoCloseable unused = loadedTestBundle()) {
Collection<ThingType> thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN);
ThingType weatherGroupType = thingTypes.stream().filter(it -> "acmeweather:weather-with-group".equals(it.toString())).findFirst().get();
assertNotNull(weatherGroupType);
ChannelGroupType channelGroupType = channelGroupTypeRegistry.getChannelGroupType(weatherGroupType.getChannelGroupDefinitions().get(0).getTypeUID(), Locale.GERMAN);
assertNotNull(channelGroupType);
assertThat(channelGroupType.getLabel(), is("Wetterinformation mit Gruppe"));
assertThat(channelGroupType.getDescription(), is("Wetterinformation mit Gruppe Beschreibung."));
}
}
use of org.openhab.core.thing.type.ThingType in project openhab-core by openhab.
the class ThingTypeI18nTest method channelsShouldBeLocalized.
@Test
public void channelsShouldBeLocalized() throws Exception {
try (final AutoCloseable unused = loadedTestBundle()) {
Collection<ThingType> thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN);
ThingType weatherType = thingTypes.stream().filter(it -> "acmeweather:weather".equals(it.toString())).findFirst().get();
assertNotNull(weatherType);
assertThat(weatherType.getChannelDefinitions().size(), is(2));
ChannelDefinition temperatureChannelDefinition = weatherType.getChannelDefinitions().stream().filter(it -> "temperature".equals(it.getId())).findFirst().get();
assertNotNull(temperatureChannelDefinition);
assertThat(temperatureChannelDefinition.getLabel(), is("Temperatur"));
assertThat(temperatureChannelDefinition.getDescription(), is("Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial)."));
ChannelDefinition minTemperatureChannelDefinition = weatherType.getChannelDefinitions().stream().filter(it -> "minTemperature".equals(it.getId())).findFirst().get();
assertNotNull(minTemperatureChannelDefinition);
assertThat(minTemperatureChannelDefinition.getLabel(), is("Min. Temperatur"));
assertThat(minTemperatureChannelDefinition.getDescription(), is("Minimale Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial)."));
}
}
use of org.openhab.core.thing.type.ThingType in project openhab-core by openhab.
the class ThingTypeI18nTest method channelGroupsShouldBeLocalized.
@Test
public void channelGroupsShouldBeLocalized() throws Exception {
try (final AutoCloseable unused = loadedTestBundle()) {
Collection<ThingType> thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN);
ThingType weatherGroupType = thingTypes.stream().filter(it -> "acmeweather:weather-with-group".equals(it.toString())).findFirst().get();
assertNotNull(weatherGroupType);
assertThat(weatherGroupType.getChannelGroupDefinitions().size(), is(2));
ChannelGroupDefinition forecastTodayChannelGroupDefinition = weatherGroupType.getChannelGroupDefinitions().stream().filter(it -> "forecastToday".equals(it.getId())).findFirst().get();
assertNotNull(forecastTodayChannelGroupDefinition);
assertThat(forecastTodayChannelGroupDefinition.getLabel(), is("Wettervorhersage heute"));
assertThat(forecastTodayChannelGroupDefinition.getDescription(), is("Wettervorhersage für den heutigen Tag."));
ChannelGroupDefinition forecastTomorrowChannelGroupDefinition = weatherGroupType.getChannelGroupDefinitions().stream().filter(it -> "forecastTomorrow".equals(it.getId())).findFirst().get();
assertNotNull(forecastTomorrowChannelGroupDefinition);
assertThat(forecastTomorrowChannelGroupDefinition.getLabel(), is("Wettervorhersage morgen"));
assertThat(forecastTomorrowChannelGroupDefinition.getDescription(), is("Wettervorhersage für den morgigen Tag."));
}
}
Aggregations