Search in sources :

Example 21 with ThingType

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());
    }
}
Also used : ChannelDefinition(org.openhab.core.thing.type.ChannelDefinition) ThingType(org.openhab.core.thing.type.ThingType) ChannelType(org.openhab.core.thing.type.ChannelType) Test(org.junit.jupiter.api.Test) JavaOSGiTest(org.openhab.core.test.java.JavaOSGiTest)

Example 22 with ThingType

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());
    }
}
Also used : ChannelDefinition(org.openhab.core.thing.type.ChannelDefinition) ChannelGroupType(org.openhab.core.thing.type.ChannelGroupType) ThingType(org.openhab.core.thing.type.ThingType) ChannelGroupDefinition(org.openhab.core.thing.type.ChannelGroupDefinition) Test(org.junit.jupiter.api.Test) JavaOSGiTest(org.openhab.core.test.java.JavaOSGiTest)

Example 23 with ThingType

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."));
    }
}
Also used : ChannelGroupType(org.openhab.core.thing.type.ChannelGroupType) ThingType(org.openhab.core.thing.type.ThingType) Test(org.junit.jupiter.api.Test) JavaOSGiTest(org.openhab.core.test.java.JavaOSGiTest)

Example 24 with ThingType

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)."));
    }
}
Also used : ChannelDefinition(org.openhab.core.thing.type.ChannelDefinition) ThingType(org.openhab.core.thing.type.ThingType) Test(org.junit.jupiter.api.Test) JavaOSGiTest(org.openhab.core.test.java.JavaOSGiTest)

Example 25 with ThingType

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."));
    }
}
Also used : ThingType(org.openhab.core.thing.type.ThingType) ChannelGroupDefinition(org.openhab.core.thing.type.ChannelGroupDefinition) Test(org.junit.jupiter.api.Test) JavaOSGiTest(org.openhab.core.test.java.JavaOSGiTest)

Aggregations

ThingType (org.openhab.core.thing.type.ThingType)52 JavaOSGiTest (org.openhab.core.test.java.JavaOSGiTest)22 Test (org.junit.jupiter.api.Test)21 ThingTypeUID (org.openhab.core.thing.ThingTypeUID)20 Thing (org.openhab.core.thing.Thing)18 ThingUID (org.openhab.core.thing.ThingUID)17 Configuration (org.openhab.core.config.core.Configuration)15 ChannelDefinition (org.openhab.core.thing.type.ChannelDefinition)14 URI (java.net.URI)10 ArrayList (java.util.ArrayList)9 ChannelGroupType (org.openhab.core.thing.type.ChannelGroupType)9 ChannelType (org.openhab.core.thing.type.ChannelType)9 List (java.util.List)8 Nullable (org.eclipse.jdt.annotation.Nullable)8 ConfigDescription (org.openhab.core.config.core.ConfigDescription)8 ChannelGroupDefinition (org.openhab.core.thing.type.ChannelGroupDefinition)7 ThingTypeRegistry (org.openhab.core.thing.type.ThingTypeRegistry)7 Locale (java.util.Locale)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 ThingTypeProvider (org.openhab.core.thing.binding.ThingTypeProvider)6