From f682cb56e6557ca1861bc3eda0e57ac949087e18 Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Wed, 13 Nov 2019 18:39:32 +0100 Subject: [PATCH] [itest] Applied new source code formatter tool (#1194) * Applied new source code formatter tool * Fixed weired descriptions in XML files; Fixed XSD schemaLocations Signed-off-by: Christoph Weitkamp --- .../pom.xml | 3 +- .../pom.xml | 3 +- .../test/AutomationIntegrationTest.java | 2 +- .../pom.xml | 3 +- .../pom.xml | 3 +- .../pom.xml | 3 +- .../pom.xml | 3 +- .../org.openhab.core.automation.tests/pom.xml | 3 +- .../pom.xml | 3 +- .../ESH-INF/binding/binding.xml | 39 +- .../ESH-INF/thing/thing-types.xml | 16 +- .../ESH-INF/binding/binding.xml | 39 +- .../ESH-INF/thing/thing-types.xml | 19 +- .../ESH-INF/binding/binding.xml | 14 +- .../pom.xml | 3 +- .../pom.xml | 3 +- .../pom.xml | 3 +- .../discovery/DiscoveryServiceMock.java | 11 +- .../pom.xml | 3 +- .../pom.xml | 3 +- .../pom.xml | 3 +- .../org.openhab.core.config.xml.tests/pom.xml | 3 +- .../ESH-INF/config/config.xml | 2 +- .../ESH-INF/thing/MyThingType.xml | 27 +- .../ESH-INF/config/config.xml | 2 +- .../ESH-INF/config/config.xml | 2 +- .../org.openhab.core.ephemeris.tests/pom.xml | 3 +- .../src/main/resources/events.xml | 35 +- .../pom.xml | 3 +- .../org.openhab.core.model.core.tests/pom.xml | 3 +- .../org.openhab.core.model.item.tests/pom.xml | 3 +- .../pom.xml | 3 +- .../org.openhab.core.model.rule.tests/pom.xml | 3 +- .../pom.xml | 3 +- .../pom.xml | 3 +- .../pom.xml | 4 +- .../pom.xml | 3 +- itests/org.openhab.core.tests/pom.xml | 3 +- itests/org.openhab.core.thing.tests/pom.xml | 3 +- ...eUpdateServiceFirmwareRestrictionTest.java | 37 +- .../org.openhab.core.thing.xml.tests/pom.xml | 3 +- .../core/thing/xml/test/ChannelTypesTest.java | 192 ++++---- .../xml/test/ConfigDescriptionsTest.java | 304 ++++++------ .../thing/xml/test/ThingTypeI18nTest.java | 434 ++++++++--------- .../core/thing/xml/test/ThingTypesTest.java | 438 +++++++++--------- .../ESH-INF/thing/thing-types.xml | 2 +- .../ESH-INF/thing/thing-types.xml | 2 +- .../ESH-INF/binding/binding.xml | 5 +- .../ESH-INF/thing/thing-types.xml | 43 +- .../ESH-INF/binding/binding.xml | 5 +- .../ESH-INF/binding/binding.xml | 8 +- .../ESH-INF/thing/thing-types.xml | 3 +- .../ESH-INF/binding/binding.xml | 2 +- .../ESH-INF/thing/thing-types.xml | 13 +- .../ESH-INF/binding/binding.xml | 2 +- .../ESH-INF/thing/thing-types.xml | 14 +- .../ESH-INF/binding/binding.xml | 5 +- .../ESH-INF/thing/thing-types.xml | 2 +- itests/org.openhab.core.voice.tests/pom.xml | 3 +- itests/pom.xml | 3 +- 60 files changed, 915 insertions(+), 895 deletions(-) diff --git a/itests/org.openhab.core.auth.oauth2client.tests/pom.xml b/itests/org.openhab.core.auth.oauth2client.tests/pom.xml index 03db5ed6a6c07..a99b3f2ce6524 100644 --- a/itests/org.openhab.core.auth.oauth2client.tests/pom.xml +++ b/itests/org.openhab.core.auth.oauth2client.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.automation.integration.tests/pom.xml b/itests/org.openhab.core.automation.integration.tests/pom.xml index 95b9297ad014e..ebe921b340d82 100644 --- a/itests/org.openhab.core.automation.integration.tests/pom.xml +++ b/itests/org.openhab.core.automation.integration.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/AutomationIntegrationTest.java b/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/AutomationIntegrationTest.java index 1d5c597576492..d9d975e5ad46c 100644 --- a/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/AutomationIntegrationTest.java +++ b/itests/org.openhab.core.automation.integration.tests/src/main/java/org/openhab/core/automation/integration/test/AutomationIntegrationTest.java @@ -105,7 +105,7 @@ public void before() { logger.info("@Before.begin"); getService(ItemRegistry.class); - + ItemProvider itemProvider = new ItemProvider() { @Override public void addProviderChangeListener(ProviderChangeListener listener) { diff --git a/itests/org.openhab.core.automation.module.core.tests/pom.xml b/itests/org.openhab.core.automation.module.core.tests/pom.xml index e8991de3963ee..b194d81b7bd34 100644 --- a/itests/org.openhab.core.automation.module.core.tests/pom.xml +++ b/itests/org.openhab.core.automation.module.core.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.automation.module.script.defaultscope.tests/pom.xml b/itests/org.openhab.core.automation.module.script.defaultscope.tests/pom.xml index 913acfc7b2855..c9ddcbd8b9df0 100644 --- a/itests/org.openhab.core.automation.module.script.defaultscope.tests/pom.xml +++ b/itests/org.openhab.core.automation.module.script.defaultscope.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.automation.module.script.tests/pom.xml b/itests/org.openhab.core.automation.module.script.tests/pom.xml index 867f661b698f0..af516ce60e58d 100644 --- a/itests/org.openhab.core.automation.module.script.tests/pom.xml +++ b/itests/org.openhab.core.automation.module.script.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.automation.module.timer.tests/pom.xml b/itests/org.openhab.core.automation.module.timer.tests/pom.xml index af74c4c26010b..eaecb3a74d96d 100644 --- a/itests/org.openhab.core.automation.module.timer.tests/pom.xml +++ b/itests/org.openhab.core.automation.module.timer.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.automation.tests/pom.xml b/itests/org.openhab.core.automation.tests/pom.xml index c55b1799666d6..e5cf87ff97cf9 100644 --- a/itests/org.openhab.core.automation.tests/pom.xml +++ b/itests/org.openhab.core.automation.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.binding.xml.tests/pom.xml b/itests/org.openhab.core.binding.xml.tests/pom.xml index dbc7627b3853b..229316ae8a19c 100644 --- a/itests/org.openhab.core.binding.xml.tests/pom.xml +++ b/itests/org.openhab.core.binding.xml.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTest.bundle/ESH-INF/binding/binding.xml b/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTest.bundle/ESH-INF/binding/binding.xml index 3990acca15c0b..25be2221c3ac0 100644 --- a/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTest.bundle/ESH-INF/binding/binding.xml +++ b/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTest.bundle/ESH-INF/binding/binding.xml @@ -1,34 +1,33 @@ + xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd" id="hue"> hue Binding The hue Binding integrates the Philips hue system. It allows to control hue lights. Deutsche Telekom AG - - + + - - - - - - - - + + + + + + + + - item - - alarm, light - color - hue - + item + + alarm, light + color + hue + - + - + diff --git a/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTest.bundle/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTest.bundle/ESH-INF/thing/thing-types.xml index 0690cf740f3cb..6d2eb9915aec4 100644 --- a/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTest.bundle/ESH-INF/thing/thing-types.xml +++ b/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTest.bundle/ESH-INF/thing/thing-types.xml @@ -1,7 +1,7 @@ - + @@ -18,9 +18,7 @@ password - Name of a registered hue bridge user, that allows to - access the API. - + Name of a registered hue bridge user, that allows to access the API. @@ -45,10 +43,8 @@ ColorItem - The color channel allows to control the color of the hue - lamp. It is also possible to dim values and switch the lamp on and - off. - + The color channel allows to control the color of the hue lamp. It is also possible to dim values and + switch the lamp on and off. diff --git a/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTestNoAuthor.bundle/ESH-INF/binding/binding.xml b/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTestNoAuthor.bundle/ESH-INF/binding/binding.xml index 7a836b1332325..c56096372cb33 100644 --- a/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTestNoAuthor.bundle/ESH-INF/binding/binding.xml +++ b/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTestNoAuthor.bundle/ESH-INF/binding/binding.xml @@ -1,33 +1,32 @@ + xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd" id="hue"> hue Binding The hue Binding integrates the Philips hue system. It allows to control hue lights. - - + + - - - - - - - - + + + + + + + + - item - - alarm, light - color - hue - + item + + alarm, light + color + hue + - + - + diff --git a/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTestNoAuthor.bundle/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTestNoAuthor.bundle/ESH-INF/thing/thing-types.xml index 0690cf740f3cb..578c1dbcbcc83 100644 --- a/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTestNoAuthor.bundle/ESH-INF/thing/thing-types.xml +++ b/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/BundleInfoTestNoAuthor.bundle/ESH-INF/thing/thing-types.xml @@ -1,7 +1,7 @@ - + @@ -18,9 +18,7 @@ password - Name of a registered hue bridge user, that allows to - access the API. - + Name of a registered hue bridge user, that allows to access the API. @@ -45,10 +43,8 @@ ColorItem - The color channel allows to control the color of the hue - lamp. It is also possible to dim values and switch the lamp on and - off. - + The color channel allows to control the color of the hue lamp. It is also possible to dim values and + switch the lamp on and off. @@ -59,8 +55,7 @@ DimmerItem - The color temperature channel allows to set the color - temperature from 0 (cold) to 100 (warm). + The color temperature channel allows to set the color temperature from 0 (cold) to 100 (warm). diff --git a/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/ESH-INF/binding/binding.xml b/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/ESH-INF/binding/binding.xml index 5cc449e2318e0..0f994ecb8a4a8 100644 --- a/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/ESH-INF/binding/binding.xml +++ b/itests/org.openhab.core.binding.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/ESH-INF/binding/binding.xml @@ -1,12 +1,10 @@ - + - YahooWeather Binding - The Yahoo Weather Binding requests the Yahoo Weather Service - to show the current temperature, humidity and pressure. - Kai Kreuzer + YahooWeather Binding + The Yahoo Weather Binding requests the Yahoo Weather Service to show the current temperature, humidity and pressure. + Kai Kreuzer diff --git a/itests/org.openhab.core.config.core.tests/pom.xml b/itests/org.openhab.core.config.core.tests/pom.xml index 07ea1fd29a310..1893bc93162c9 100644 --- a/itests/org.openhab.core.config.core.tests/pom.xml +++ b/itests/org.openhab.core.config.core.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.config.discovery.mdns.tests/pom.xml b/itests/org.openhab.core.config.discovery.mdns.tests/pom.xml index 9fd3601358a20..9f988514be88d 100644 --- a/itests/org.openhab.core.config.discovery.mdns.tests/pom.xml +++ b/itests/org.openhab.core.config.discovery.mdns.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.config.discovery.tests/pom.xml b/itests/org.openhab.core.config.discovery.tests/pom.xml index a0295b0e331be..22f5d6686b547 100644 --- a/itests/org.openhab.core.config.discovery.tests/pom.xml +++ b/itests/org.openhab.core.config.discovery.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.openhab.core.itests diff --git a/itests/org.openhab.core.config.discovery.tests/src/main/java/org/eclipse/smarthome/config/discovery/DiscoveryServiceMock.java b/itests/org.openhab.core.config.discovery.tests/src/main/java/org/eclipse/smarthome/config/discovery/DiscoveryServiceMock.java index d201a7db7f824..01973dfb1e513 100644 --- a/itests/org.openhab.core.config.discovery.tests/src/main/java/org/eclipse/smarthome/config/discovery/DiscoveryServiceMock.java +++ b/itests/org.openhab.core.config.discovery.tests/src/main/java/org/eclipse/smarthome/config/discovery/DiscoveryServiceMock.java @@ -15,17 +15,16 @@ import java.util.Collections; import java.util.Random; -import org.eclipse.smarthome.config.discovery.AbstractDiscoveryService; -import org.eclipse.smarthome.config.discovery.DiscoveryService; import org.eclipse.smarthome.config.discovery.internal.DiscoveryResultImpl; import org.eclipse.smarthome.core.thing.ThingTypeUID; import org.eclipse.smarthome.core.thing.ThingUID; /** - * The {@link DiscoveryServiceMock} is a mock for a {@link DiscoveryService} - * which can simulate a working and faulty discovery.
- * If this mock is configured to be faulty, an exception is thrown if the - * discovery is enforced or aborted. + * The {@link DiscoveryServiceMock} is a mock for a {@link + * org.eclipse.smarthome.config.discovery.DiscoveryService} which can simulate a working and faulty + * discovery.
+ * If this mock is configured to be faulty, an exception is thrown if the discovery is enforced or + * aborted. * * @author Michael Grammling - Initial contribution * @author Thomas Höfer - Added representation diff --git a/itests/org.openhab.core.config.discovery.usbserial.linuxsysfs.tests/pom.xml b/itests/org.openhab.core.config.discovery.usbserial.linuxsysfs.tests/pom.xml index 23c1d4069a776..7ab45d15e2bfa 100644 --- a/itests/org.openhab.core.config.discovery.usbserial.linuxsysfs.tests/pom.xml +++ b/itests/org.openhab.core.config.discovery.usbserial.linuxsysfs.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.openhab.core.itests diff --git a/itests/org.openhab.core.config.discovery.usbserial.tests/pom.xml b/itests/org.openhab.core.config.discovery.usbserial.tests/pom.xml index f6f70835f8cae..b5d32496a7c96 100644 --- a/itests/org.openhab.core.config.discovery.usbserial.tests/pom.xml +++ b/itests/org.openhab.core.config.discovery.usbserial.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.config.dispatch.tests/pom.xml b/itests/org.openhab.core.config.dispatch.tests/pom.xml index ddb305a081863..56fa996685f2d 100644 --- a/itests/org.openhab.core.config.dispatch.tests/pom.xml +++ b/itests/org.openhab.core.config.dispatch.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.config.xml.tests/pom.xml b/itests/org.openhab.core.config.xml.tests/pom.xml index a3c8d4c85a99a..884f834d70cd5 100644 --- a/itests/org.openhab.core.config.xml.tests/pom.xml +++ b/itests/org.openhab.core.config.xml.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsFragmentTest.fragment/ESH-INF/config/config.xml b/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsFragmentTest.fragment/ESH-INF/config/config.xml index 5371020fefbba..d88267d04e940 100644 --- a/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsFragmentTest.fragment/ESH-INF/config/config.xml +++ b/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsFragmentTest.fragment/ESH-INF/config/config.xml @@ -2,7 +2,7 @@ + xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0 https://openhab.org/schemas/config-description-1.0.0.xsd"> diff --git a/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsFragmentTest.host/ESH-INF/thing/MyThingType.xml b/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsFragmentTest.host/ESH-INF/thing/MyThingType.xml index 382dbe4ee4347..c03d736da9de2 100644 --- a/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsFragmentTest.host/ESH-INF/thing/MyThingType.xml +++ b/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsFragmentTest.host/ESH-INF/thing/MyThingType.xml @@ -1,18 +1,17 @@ - + - - - My Thing Type + + + My Thing Type - - - - My ID. - - - + + + + My ID. + + + diff --git a/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/config/config.xml b/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/config/config.xml index fe1e7e8b416d9..eb1519a15d1d5 100644 --- a/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/config/config.xml +++ b/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/config/config.xml @@ -2,7 +2,7 @@ + xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0 https://openhab.org/schemas/config-description-1.0.0.xsd"> diff --git a/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/ESH-INF/config/config.xml b/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/ESH-INF/config/config.xml index 375b3f9b28292..ea38f9cfa9203 100644 --- a/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/ESH-INF/config/config.xml +++ b/itests/org.openhab.core.config.xml.tests/src/main/resources/test-bundle-pool/yahooweather.bundle/ESH-INF/config/config.xml @@ -2,7 +2,7 @@ + xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0 https://openhab.org/schemas/config-description-1.0.0.xsd"> diff --git a/itests/org.openhab.core.ephemeris.tests/pom.xml b/itests/org.openhab.core.ephemeris.tests/pom.xml index 9d5c4b0a5c5cf..79da7ea3674b8 100644 --- a/itests/org.openhab.core.ephemeris.tests/pom.xml +++ b/itests/org.openhab.core.ephemeris.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.ephemeris.tests/src/main/resources/events.xml b/itests/org.openhab.core.ephemeris.tests/src/main/resources/events.xml index f53282ef5e7f8..ecb1c4df7e898 100644 --- a/itests/org.openhab.core.ephemeris.tests/src/main/resources/events.xml +++ b/itests/org.openhab.core.ephemeris.tests/src/main/resources/events.xml @@ -1,20 +1,25 @@ - + - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/itests/org.openhab.core.io.rest.core.tests/pom.xml b/itests/org.openhab.core.io.rest.core.tests/pom.xml index f550b4ead188e..6e3398ff6d9fd 100644 --- a/itests/org.openhab.core.io.rest.core.tests/pom.xml +++ b/itests/org.openhab.core.io.rest.core.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.model.core.tests/pom.xml b/itests/org.openhab.core.model.core.tests/pom.xml index 70c51f9b3942c..da637d568a4c6 100644 --- a/itests/org.openhab.core.model.core.tests/pom.xml +++ b/itests/org.openhab.core.model.core.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.model.item.tests/pom.xml b/itests/org.openhab.core.model.item.tests/pom.xml index 888951ded45ab..e15e2493657c3 100644 --- a/itests/org.openhab.core.model.item.tests/pom.xml +++ b/itests/org.openhab.core.model.item.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.model.persistence.tests/pom.xml b/itests/org.openhab.core.model.persistence.tests/pom.xml index 3ff3a53b8a720..2ed9093f21996 100644 --- a/itests/org.openhab.core.model.persistence.tests/pom.xml +++ b/itests/org.openhab.core.model.persistence.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.model.rule.tests/pom.xml b/itests/org.openhab.core.model.rule.tests/pom.xml index 115ad38555160..e1c2df0a44856 100644 --- a/itests/org.openhab.core.model.rule.tests/pom.xml +++ b/itests/org.openhab.core.model.rule.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.model.script.tests/pom.xml b/itests/org.openhab.core.model.script.tests/pom.xml index 20a665db77ba6..d7ae5c8a49750 100644 --- a/itests/org.openhab.core.model.script.tests/pom.xml +++ b/itests/org.openhab.core.model.script.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.model.thing.tests/pom.xml b/itests/org.openhab.core.model.thing.tests/pom.xml index 645927a44b517..568bd8d72e611 100644 --- a/itests/org.openhab.core.model.thing.tests/pom.xml +++ b/itests/org.openhab.core.model.thing.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.model.thing.testsupport/pom.xml b/itests/org.openhab.core.model.thing.testsupport/pom.xml index 869c857162d6c..35c67d1998feb 100644 --- a/itests/org.openhab.core.model.thing.testsupport/pom.xml +++ b/itests/org.openhab.core.model.thing.testsupport/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 @@ -14,4 +15,3 @@ openHAB Core :: Integration Tests :: Model Thing Test Support - diff --git a/itests/org.openhab.core.storage.json.tests/pom.xml b/itests/org.openhab.core.storage.json.tests/pom.xml index d5452b9179c7d..d6774794899e0 100644 --- a/itests/org.openhab.core.storage.json.tests/pom.xml +++ b/itests/org.openhab.core.storage.json.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.tests/pom.xml b/itests/org.openhab.core.tests/pom.xml index 319aa64f1cf3b..c41fe38978d2f 100644 --- a/itests/org.openhab.core.tests/pom.xml +++ b/itests/org.openhab.core.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.thing.tests/pom.xml b/itests/org.openhab.core.thing.tests/pom.xml index 92193c08c2309..9160f58eec7d3 100644 --- a/itests/org.openhab.core.thing.tests/pom.xml +++ b/itests/org.openhab.core.thing.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/firmware/FirmwareUpdateServiceFirmwareRestrictionTest.java b/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/firmware/FirmwareUpdateServiceFirmwareRestrictionTest.java index 302562a637483..45c1a3eaf4e73 100644 --- a/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/firmware/FirmwareUpdateServiceFirmwareRestrictionTest.java +++ b/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/firmware/FirmwareUpdateServiceFirmwareRestrictionTest.java @@ -70,8 +70,8 @@ public void tearDown() { @Test public void firmwareRestrictionExactFirmwareVersion() { - FirmwareRestriction firmwareRestrictionFunction = t -> t.getProperties() - .get(Thing.PROPERTY_FIRMWARE_VERSION).equals(FIRMWARE_VERSION_1); + FirmwareRestriction firmwareRestrictionFunction = t -> t.getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION) + .equals(FIRMWARE_VERSION_1); Firmware firmware = FirmwareBuilder.create(thingTypeUID, FIRMWARE_VERSION_2) .withFirmwareRestriction(firmwareRestrictionFunction).build(); @@ -83,21 +83,22 @@ public void firmwareRestrictionExactFirmwareVersion() { @Test public void firmwareRestrictionExactHardwareVersion() { - FirmwareRestriction hardwareRestrictionFunction = t -> t.getProperties() - .get(Thing.PROPERTY_HARDWARE_VERSION).equals(HARDWARE_VERSION_A); + FirmwareRestriction hardwareRestrictionFunction = t -> t.getProperties().get(Thing.PROPERTY_HARDWARE_VERSION) + .equals(HARDWARE_VERSION_A); Firmware firmware = FirmwareBuilder.create(thingTypeUID, FIRMWARE_VERSION_2) .withFirmwareRestriction(hardwareRestrictionFunction).build(); registerFirmwareProviderWithSingleFirmware(firmware); - assertThatFirmwareUpdateIsExecutableForThingWithFirmwareVersionAndHardwareVersion(FIRMWARE_VERSION_0_1, HARDWARE_VERSION_A); + assertThatFirmwareUpdateIsExecutableForThingWithFirmwareVersionAndHardwareVersion(FIRMWARE_VERSION_0_1, + HARDWARE_VERSION_A); } @Test public void firmwareRestrictionExactFirmwareAndHardwareVersion() { - FirmwareRestriction fwAndHwRestrictionFunction = t -> t.getProperties() - .get(Thing.PROPERTY_HARDWARE_VERSION).equals(HARDWARE_VERSION_A) + FirmwareRestriction fwAndHwRestrictionFunction = t -> t.getProperties().get(Thing.PROPERTY_HARDWARE_VERSION) + .equals(HARDWARE_VERSION_A) && t.getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION).equals(FIRMWARE_VERSION_1); Firmware firmware = FirmwareBuilder.create(thingTypeUID, FIRMWARE_VERSION_2) @@ -105,13 +106,14 @@ public void firmwareRestrictionExactFirmwareAndHardwareVersion() { registerFirmwareProviderWithSingleFirmware(firmware); - assertThatFirmwareUpdateIsExecutableForThingWithFirmwareVersionAndHardwareVersion(FIRMWARE_VERSION_1, HARDWARE_VERSION_A); + assertThatFirmwareUpdateIsExecutableForThingWithFirmwareVersionAndHardwareVersion(FIRMWARE_VERSION_1, + HARDWARE_VERSION_A); } @Test public void firmwareRestrictionAndRestrictedModel() { - FirmwareRestriction firmwareRestrictionFunction = t -> t.getProperties() - .get(Thing.PROPERTY_FIRMWARE_VERSION).equals(FIRMWARE_VERSION_1); + FirmwareRestriction firmwareRestrictionFunction = t -> t.getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION) + .equals(FIRMWARE_VERSION_1); Firmware firmware = FirmwareBuilder.create(thingTypeUID, FIRMWARE_VERSION_2).withModelRestricted(true) .withModel(TEST_MODEL).withFirmwareRestriction(firmwareRestrictionFunction).build(); @@ -123,8 +125,8 @@ public void firmwareRestrictionAndRestrictedModel() { @Test public void firmwareRestrictionAndPrerequisiteVersion() { - FirmwareRestriction firmwareRestrictionFunction = t -> t.getProperties() - .get(Thing.PROPERTY_FIRMWARE_VERSION).equals(FIRMWARE_VERSION_1); + FirmwareRestriction firmwareRestrictionFunction = t -> t.getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION) + .equals(FIRMWARE_VERSION_1); Firmware firmware = FirmwareBuilder.create(thingTypeUID, FIRMWARE_VERSION_2).withPrerequisiteVersion("0.0.5") .withFirmwareRestriction(firmwareRestrictionFunction).build(); @@ -158,10 +160,10 @@ public void hardwareVersionDependsOnInstalledFirmware() { && !thg.getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION).equals(FW_VERSION_32); // Build firmwares - Firmware fw38 = FirmwareBuilder.create(thingTypeUID, FW_VERSION_38).withFirmwareRestriction(hwVersion2Restriction) - .build(); - Firmware fw40 = FirmwareBuilder.create(thingTypeUID, FW_VERSION_40).withFirmwareRestriction(hwVersion1Restriction) - .build(); + Firmware fw38 = FirmwareBuilder.create(thingTypeUID, FW_VERSION_38) + .withFirmwareRestriction(hwVersion2Restriction).build(); + Firmware fw40 = FirmwareBuilder.create(thingTypeUID, FW_VERSION_40) + .withFirmwareRestriction(hwVersion1Restriction).build(); // Mock the provider to return the firmwares FirmwareProvider lambdaFirmwareProvider = mock(FirmwareProvider.class); @@ -184,7 +186,8 @@ public void hardwareVersionDependsOnInstalledFirmware() { FW_VERSION_38); } - private void assertThatFirmwareUpdateIsExecutableForThingWithFirmwareVersionAndHardwareVersion(String firmwareVersion, String hardwareVersion) { + private void assertThatFirmwareUpdateIsExecutableForThingWithFirmwareVersionAndHardwareVersion( + String firmwareVersion, String hardwareVersion) { Thing thing = createThing("customThing", firmwareVersion, hardwareVersion); registerService(createFirmwareUpdateHandler(thing)); diff --git a/itests/org.openhab.core.thing.xml.tests/pom.xml b/itests/org.openhab.core.thing.xml.tests/pom.xml index c99c8c55af0b8..4ea02102e8e52 100644 --- a/itests/org.openhab.core.thing.xml.tests/pom.xml +++ b/itests/org.openhab.core.thing.xml.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ChannelTypesTest.java b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ChannelTypesTest.java index a92b673464263..972d21db3b490 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ChannelTypesTest.java +++ b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ChannelTypesTest.java @@ -1,96 +1,96 @@ -/** - * Copyright (c) 2010-2019 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.smarthome.core.thing.xml.test; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertThat; - -import java.util.Collection; - -import org.eclipse.smarthome.core.thing.type.ChannelGroupType; -import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeProvider; -import org.eclipse.smarthome.core.thing.type.ChannelType; -import org.eclipse.smarthome.core.thing.type.ChannelTypeProvider; -import org.eclipse.smarthome.test.BundleCloseable; -import org.eclipse.smarthome.test.SyntheticBundleInstaller; -import org.eclipse.smarthome.test.java.JavaOSGiTest; -import org.junit.Before; -import org.junit.Test; - -/*** - * - * This test checks if channel types are loaded properly. - * - * @author Dennis Nobel - Initial contribution - */ -public class ChannelTypesTest extends JavaOSGiTest { - - private static final String TEST_BUNDLE_NAME = "ChannelTypesTest.bundle"; - - private ChannelTypeProvider channelTypeProvider; - private ChannelGroupTypeProvider channelGroupTypeProvider; - - @Before - public void setUp() { - // get ONLY the XMLChannelTypeProvider - channelTypeProvider = getService(ChannelTypeProvider.class, - serviceReference -> "core.xml.channels".equals(serviceReference.getProperty("esh.scope"))); - assertThat(channelTypeProvider, is(notNullValue())); - channelGroupTypeProvider = getService(ChannelGroupTypeProvider.class, - serviceReference -> "core.xml.channelGroups".equals(serviceReference.getProperty("esh.scope"))); - assertThat(channelGroupTypeProvider, is(notNullValue())); - } - - @Test - public void channelTypesShouldBeLoaded() throws Exception { - int initialNumberOfChannelTypes = channelTypeProvider.getChannelTypes(null).size(); - int initialNumberOfChannelGroupTypes = channelGroupTypeProvider.getChannelGroupTypes(null).size(); - - // install test bundle - try (BundleCloseable bundle = new BundleCloseable( - SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME))) { - assertThat(bundle, is(notNullValue())); - - Collection channelTypes = waitForAssert(() -> { - Collection channelTypesTmp = channelTypeProvider.getChannelTypes(null); - assertThat(channelTypesTmp.size(), is(initialNumberOfChannelTypes + 2)); - return channelTypesTmp; - }); - - ChannelType channelType1 = channelTypes.stream() - .filter(it -> it.getUID().toString().equals("somebinding:channel1")).findFirst().get(); - assertThat(channelType1, is(not(nullValue()))); - - ChannelType channelType2 = channelTypes.stream() - .filter(it -> it.getUID().toString().equals("somebinding:channel-without-reference")).findFirst() - .get(); - assertThat(channelType2, is(not(nullValue()))); - - Collection channelGroupTypes = waitForAssert(() -> { - Collection channelGroupTypesTmp = channelGroupTypeProvider.getChannelGroupTypes(null); - assertThat(channelGroupTypesTmp.size(), is(initialNumberOfChannelGroupTypes + 1)); - return channelGroupTypesTmp; - }); - - ChannelGroupType channelGroupType = channelGroupTypes.stream() - .filter(it -> it.getUID().toString().equals("somebinding:channelgroup")).findFirst().get(); - assertThat(channelGroupType, is(not(nullValue()))); - assertThat(channelGroupType.getCategory(), is("Temperature")); - } - - waitForAssert( - () -> assertThat(channelTypeProvider.getChannelTypes(null).size(), is(initialNumberOfChannelTypes))); - waitForAssert(() -> assertThat(channelGroupTypeProvider.getChannelGroupTypes(null).size(), - is(initialNumberOfChannelGroupTypes))); - } -} +/** + * Copyright (c) 2010-2019 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.smarthome.core.thing.xml.test; + +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.assertThat; + +import java.util.Collection; + +import org.eclipse.smarthome.core.thing.type.ChannelGroupType; +import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeProvider; +import org.eclipse.smarthome.core.thing.type.ChannelType; +import org.eclipse.smarthome.core.thing.type.ChannelTypeProvider; +import org.eclipse.smarthome.test.BundleCloseable; +import org.eclipse.smarthome.test.SyntheticBundleInstaller; +import org.eclipse.smarthome.test.java.JavaOSGiTest; +import org.junit.Before; +import org.junit.Test; + +/*** + * + * This test checks if channel types are loaded properly. + * + * @author Dennis Nobel - Initial contribution + */ +public class ChannelTypesTest extends JavaOSGiTest { + + private static final String TEST_BUNDLE_NAME = "ChannelTypesTest.bundle"; + + private ChannelTypeProvider channelTypeProvider; + private ChannelGroupTypeProvider channelGroupTypeProvider; + + @Before + public void setUp() { + // get ONLY the XMLChannelTypeProvider + channelTypeProvider = getService(ChannelTypeProvider.class, + serviceReference -> "core.xml.channels".equals(serviceReference.getProperty("esh.scope"))); + assertThat(channelTypeProvider, is(notNullValue())); + channelGroupTypeProvider = getService(ChannelGroupTypeProvider.class, + serviceReference -> "core.xml.channelGroups".equals(serviceReference.getProperty("esh.scope"))); + assertThat(channelGroupTypeProvider, is(notNullValue())); + } + + @Test + public void channelTypesShouldBeLoaded() throws Exception { + int initialNumberOfChannelTypes = channelTypeProvider.getChannelTypes(null).size(); + int initialNumberOfChannelGroupTypes = channelGroupTypeProvider.getChannelGroupTypes(null).size(); + + // install test bundle + try (BundleCloseable bundle = new BundleCloseable( + SyntheticBundleInstaller.install(bundleContext, TEST_BUNDLE_NAME))) { + assertThat(bundle, is(notNullValue())); + + Collection channelTypes = waitForAssert(() -> { + Collection channelTypesTmp = channelTypeProvider.getChannelTypes(null); + assertThat(channelTypesTmp.size(), is(initialNumberOfChannelTypes + 2)); + return channelTypesTmp; + }); + + ChannelType channelType1 = channelTypes.stream() + .filter(it -> it.getUID().toString().equals("somebinding:channel1")).findFirst().get(); + assertThat(channelType1, is(not(nullValue()))); + + ChannelType channelType2 = channelTypes.stream() + .filter(it -> it.getUID().toString().equals("somebinding:channel-without-reference")).findFirst() + .get(); + assertThat(channelType2, is(not(nullValue()))); + + Collection channelGroupTypes = waitForAssert(() -> { + Collection channelGroupTypesTmp = channelGroupTypeProvider.getChannelGroupTypes(null); + assertThat(channelGroupTypesTmp.size(), is(initialNumberOfChannelGroupTypes + 1)); + return channelGroupTypesTmp; + }); + + ChannelGroupType channelGroupType = channelGroupTypes.stream() + .filter(it -> it.getUID().toString().equals("somebinding:channelgroup")).findFirst().get(); + assertThat(channelGroupType, is(not(nullValue()))); + assertThat(channelGroupType.getCategory(), is("Temperature")); + } + + waitForAssert( + () -> assertThat(channelTypeProvider.getChannelTypes(null).size(), is(initialNumberOfChannelTypes))); + waitForAssert(() -> assertThat(channelGroupTypeProvider.getChannelGroupTypes(null).size(), + is(initialNumberOfChannelGroupTypes))); + } +} diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ConfigDescriptionsTest.java b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ConfigDescriptionsTest.java index 5ad8348da78b5..90753ae8261ed 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ConfigDescriptionsTest.java +++ b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ConfigDescriptionsTest.java @@ -1,152 +1,152 @@ -/** - * Copyright (c) 2010-2019 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.smarthome.core.thing.xml.test; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertThat; - -import java.net.URI; -import java.util.Collection; - -import org.eclipse.smarthome.config.core.ConfigDescription; -import org.eclipse.smarthome.config.core.ConfigDescriptionParameter; -import org.eclipse.smarthome.config.core.ConfigDescriptionParameter.Type; -import org.eclipse.smarthome.config.core.ConfigDescriptionParameterGroup; -import org.eclipse.smarthome.config.core.ConfigDescriptionRegistry; -import org.eclipse.smarthome.core.thing.xml.test.LoadedTestBundle.StuffAddition; -import org.eclipse.smarthome.test.java.JavaOSGiTest; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Henning Treu - Initial contribution - */ -public class ConfigDescriptionsTest extends JavaOSGiTest { - - private LoadedTestBundle loadedTestBundle() throws Exception { - return new LoadedTestBundle("ConfigDescriptionsTest.bundle", bundleContext, this::getService, - new StuffAddition().configDescriptions(3)); - } - - private ConfigDescriptionRegistry configDescriptionRegistry; - - @Before - public void before() { - configDescriptionRegistry = getService(ConfigDescriptionRegistry.class); - assertThat(configDescriptionRegistry, is(notNullValue())); - } - - @Test - public void syntheticBundleShouldLoadFromTestResource() throws Exception { - try (final AutoCloseable unused = loadedTestBundle()) { - } - } - - @Test - public void configDescriptionsShouldLoadProperly() throws Exception { - try (final AutoCloseable unused = loadedTestBundle()) { - URI bridgeURI = new URI("thing-type:hue:bridge"); - ConfigDescription bridgeConfigDescription = configDescriptionRegistry.getConfigDescriptions().stream() - .filter(it -> it.getUID().equals(bridgeURI)).findFirst().get(); - - assertThat(bridgeConfigDescription, is(notNullValue())); - - Collection parameters = bridgeConfigDescription.getParameters(); - assertThat(parameters.size(), is(2)); - - ConfigDescriptionParameter ipParameter = parameters.stream().filter(it -> it.getName().equals("ip")) - .findFirst().get(); - assertThat(ipParameter, is(notNullValue())); - assertThat(ipParameter.getType(), is(Type.TEXT)); - assertThat(ipParameter.getContext(), is("network-address")); - assertThat(ipParameter.getLabel(), is("Network Address")); - assertThat(ipParameter.getDescription(), is("Network address of the hue bridge.")); - assertThat(ipParameter.isRequired(), is(true)); - - ConfigDescriptionParameter userNameParameter = parameters.stream() - .filter(it -> it.getName().equals("username")).findFirst().get(); - assertThat(userNameParameter, is(notNullValue())); - - assertThat(userNameParameter.isAdvanced(), is(true)); - - assertThat(userNameParameter.getType(), is(Type.TEXT)); - assertThat(userNameParameter.getContext(), is("password")); - assertThat(userNameParameter.getLabel(), is("Username")); - assertThat(userNameParameter.getDescription(), - is("Name of a registered hue bridge user, that allows to access the API.")); - - URI colorURI = new URI("channel-type:hue:color"); - ConfigDescription colorConfigDescription = configDescriptionRegistry.getConfigDescriptions().stream() - .filter(it -> it.getUID().equals(colorURI)).findFirst().get(); - - assertThat(colorConfigDescription, is(notNullValue())); - - parameters = colorConfigDescription.getParameters(); - assertThat(parameters.size(), is(1)); - - ConfigDescriptionParameter lastDimValueParameter = parameters.stream() - .filter(it -> it.getName().equals("lastDimValue")).findFirst().get(); - assertThat(lastDimValueParameter, is(notNullValue())); - assertThat(lastDimValueParameter.getType(), is(Type.BOOLEAN)); - - Collection groups = bridgeConfigDescription.getParameterGroups(); - assertThat(groups.size(), is(2)); - - ConfigDescriptionParameterGroup group1 = groups.stream().filter(it -> it.getName().equals("group1")) - .findFirst().get(); - assertThat(group1, is(notNullValue())); - assertThat(group1.getContext(), is("Group1-context")); - assertThat(group1.getLabel(), is("Group Label 1")); - assertThat(group1.getDescription(), is("Group description 1")); - } - } - - @Test - public void parametersWithOptionsAndFiltersShouldLoadProperly() throws Exception { - try (final AutoCloseable unused = loadedTestBundle()) { - URI dummyURI = new URI("thing-type:hue:dummy"); - ConfigDescription bridgeConfigDescription = configDescriptionRegistry.getConfigDescriptions().stream() - .filter(it -> it.getUID().equals(dummyURI)).findFirst().get(); - assertThat(bridgeConfigDescription, is(notNullValue())); - - Collection parameters = bridgeConfigDescription.getParameters(); - assertThat(parameters.size(), is(2)); - - ConfigDescriptionParameter unitParameter = parameters.stream().filter(it -> it.getName().equals("unit")) - .findFirst().get(); - assertThat(unitParameter, is(notNullValue())); - assertThat(join(unitParameter.getOptions(), ","), is( - "ParameterOption [value=\"us\", label=\"US\"],ParameterOption [value=\"metric\", label=\"Metric\"]")); - - ConfigDescriptionParameter lightParameter = parameters.stream() - .filter(it -> it.getName().equals("color-alarming-light")).findFirst().get(); - assertThat(lightParameter, is(notNullValue())); - assertThat(join(lightParameter.getFilterCriteria(), ","), is( - "FilterCriteria [name=\"tags\", value=\"alarm, light\"],FilterCriteria [name=\"type\", value=\"color\"],FilterCriteria [name=\"binding-id\", value=\"hue\"]")); - } - } - - private String join(Collection elements, String separator) { - StringBuilder sb = new StringBuilder(); - for (Object element : elements) { - if (sb.length() > 0) { - sb.append(separator); - } - if (element != null) { - sb.append(element.toString()); - } - } - - return sb.toString(); - } -} +/** + * Copyright (c) 2010-2019 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.smarthome.core.thing.xml.test; + +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.assertThat; + +import java.net.URI; +import java.util.Collection; + +import org.eclipse.smarthome.config.core.ConfigDescription; +import org.eclipse.smarthome.config.core.ConfigDescriptionParameter; +import org.eclipse.smarthome.config.core.ConfigDescriptionParameter.Type; +import org.eclipse.smarthome.config.core.ConfigDescriptionParameterGroup; +import org.eclipse.smarthome.config.core.ConfigDescriptionRegistry; +import org.eclipse.smarthome.core.thing.xml.test.LoadedTestBundle.StuffAddition; +import org.eclipse.smarthome.test.java.JavaOSGiTest; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Henning Treu - Initial contribution + */ +public class ConfigDescriptionsTest extends JavaOSGiTest { + + private LoadedTestBundle loadedTestBundle() throws Exception { + return new LoadedTestBundle("ConfigDescriptionsTest.bundle", bundleContext, this::getService, + new StuffAddition().configDescriptions(3)); + } + + private ConfigDescriptionRegistry configDescriptionRegistry; + + @Before + public void before() { + configDescriptionRegistry = getService(ConfigDescriptionRegistry.class); + assertThat(configDescriptionRegistry, is(notNullValue())); + } + + @Test + public void syntheticBundleShouldLoadFromTestResource() throws Exception { + try (final AutoCloseable unused = loadedTestBundle()) { + } + } + + @Test + public void configDescriptionsShouldLoadProperly() throws Exception { + try (final AutoCloseable unused = loadedTestBundle()) { + URI bridgeURI = new URI("thing-type:hue:bridge"); + ConfigDescription bridgeConfigDescription = configDescriptionRegistry.getConfigDescriptions().stream() + .filter(it -> it.getUID().equals(bridgeURI)).findFirst().get(); + + assertThat(bridgeConfigDescription, is(notNullValue())); + + Collection parameters = bridgeConfigDescription.getParameters(); + assertThat(parameters.size(), is(2)); + + ConfigDescriptionParameter ipParameter = parameters.stream().filter(it -> it.getName().equals("ip")) + .findFirst().get(); + assertThat(ipParameter, is(notNullValue())); + assertThat(ipParameter.getType(), is(Type.TEXT)); + assertThat(ipParameter.getContext(), is("network-address")); + assertThat(ipParameter.getLabel(), is("Network Address")); + assertThat(ipParameter.getDescription(), is("Network address of the hue bridge.")); + assertThat(ipParameter.isRequired(), is(true)); + + ConfigDescriptionParameter userNameParameter = parameters.stream() + .filter(it -> it.getName().equals("username")).findFirst().get(); + assertThat(userNameParameter, is(notNullValue())); + + assertThat(userNameParameter.isAdvanced(), is(true)); + + assertThat(userNameParameter.getType(), is(Type.TEXT)); + assertThat(userNameParameter.getContext(), is("password")); + assertThat(userNameParameter.getLabel(), is("Username")); + assertThat(userNameParameter.getDescription(), + is("Name of a registered hue bridge user, that allows to access the API.")); + + URI colorURI = new URI("channel-type:hue:color"); + ConfigDescription colorConfigDescription = configDescriptionRegistry.getConfigDescriptions().stream() + .filter(it -> it.getUID().equals(colorURI)).findFirst().get(); + + assertThat(colorConfigDescription, is(notNullValue())); + + parameters = colorConfigDescription.getParameters(); + assertThat(parameters.size(), is(1)); + + ConfigDescriptionParameter lastDimValueParameter = parameters.stream() + .filter(it -> it.getName().equals("lastDimValue")).findFirst().get(); + assertThat(lastDimValueParameter, is(notNullValue())); + assertThat(lastDimValueParameter.getType(), is(Type.BOOLEAN)); + + Collection groups = bridgeConfigDescription.getParameterGroups(); + assertThat(groups.size(), is(2)); + + ConfigDescriptionParameterGroup group1 = groups.stream().filter(it -> it.getName().equals("group1")) + .findFirst().get(); + assertThat(group1, is(notNullValue())); + assertThat(group1.getContext(), is("Group1-context")); + assertThat(group1.getLabel(), is("Group Label 1")); + assertThat(group1.getDescription(), is("Group description 1")); + } + } + + @Test + public void parametersWithOptionsAndFiltersShouldLoadProperly() throws Exception { + try (final AutoCloseable unused = loadedTestBundle()) { + URI dummyURI = new URI("thing-type:hue:dummy"); + ConfigDescription bridgeConfigDescription = configDescriptionRegistry.getConfigDescriptions().stream() + .filter(it -> it.getUID().equals(dummyURI)).findFirst().get(); + assertThat(bridgeConfigDescription, is(notNullValue())); + + Collection parameters = bridgeConfigDescription.getParameters(); + assertThat(parameters.size(), is(2)); + + ConfigDescriptionParameter unitParameter = parameters.stream().filter(it -> it.getName().equals("unit")) + .findFirst().get(); + assertThat(unitParameter, is(notNullValue())); + assertThat(join(unitParameter.getOptions(), ","), is( + "ParameterOption [value=\"us\", label=\"US\"],ParameterOption [value=\"metric\", label=\"Metric\"]")); + + ConfigDescriptionParameter lightParameter = parameters.stream() + .filter(it -> it.getName().equals("color-alarming-light")).findFirst().get(); + assertThat(lightParameter, is(notNullValue())); + assertThat(join(lightParameter.getFilterCriteria(), ","), is( + "FilterCriteria [name=\"tags\", value=\"alarm, light\"],FilterCriteria [name=\"type\", value=\"color\"],FilterCriteria [name=\"binding-id\", value=\"hue\"]")); + } + } + + private String join(Collection elements, String separator) { + StringBuilder sb = new StringBuilder(); + for (Object element : elements) { + if (sb.length() > 0) { + sb.append(separator); + } + if (element != null) { + sb.append(element.toString()); + } + } + + return sb.toString(); + } +} diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypeI18nTest.java b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypeI18nTest.java index 79aac2bda87d7..d84629c02f347 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypeI18nTest.java +++ b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypeI18nTest.java @@ -1,217 +1,217 @@ -/** - * Copyright (c) 2010-2019 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.smarthome.core.thing.xml.test; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -import java.util.Collection; -import java.util.Locale; - -import org.eclipse.smarthome.core.thing.binding.ThingTypeProvider; -import org.eclipse.smarthome.core.thing.type.ChannelDefinition; -import org.eclipse.smarthome.core.thing.type.ChannelGroupDefinition; -import org.eclipse.smarthome.core.thing.type.ChannelGroupType; -import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeRegistry; -import org.eclipse.smarthome.core.thing.type.ChannelType; -import org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry; -import org.eclipse.smarthome.core.thing.type.ThingType; -import org.eclipse.smarthome.core.thing.xml.test.LoadedTestBundle.StuffAddition; -import org.eclipse.smarthome.test.java.JavaOSGiTest; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Henning Treu - Initial contribution - */ -public class ThingTypeI18nTest extends JavaOSGiTest { - - private LoadedTestBundle loadedTestBundle() throws Exception { - return new LoadedTestBundle("yahooweather.bundle", bundleContext, this::getService, - new StuffAddition().thingTypes(2)); - } - - private ThingTypeProvider thingTypeProvider; - private ChannelTypeRegistry channelTypeRegistry; - private ChannelGroupTypeRegistry channelGroupTypeRegistry; - - @Before - public void setUp() { - thingTypeProvider = getService(ThingTypeProvider.class); - assertNotNull(thingTypeProvider); - - channelTypeRegistry = getService(ChannelTypeRegistry.class); - assertNotNull(channelTypeRegistry); - - channelGroupTypeRegistry = getService(ChannelGroupTypeRegistry.class); - assertNotNull(channelGroupTypeRegistry); - } - - @Test - public void thingTypeShouldBeLocalized() throws Exception { - try (final AutoCloseable unused = loadedTestBundle()) { - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - - ThingType weatherType = thingTypes.stream().filter(it -> it.toString().equals("yahooweather:weather")) - .findFirst().get(); - assertNotNull(weatherType); - - assertThat(weatherType.getLabel(), is("Wetterinformation")); - assertThat(weatherType.getDescription(), - is("Stellt verschiedene Wetterdaten vom Yahoo Wetterdienst bereit")); - } - } - - @Test - public void channelGroupTypeShouldBeLocalized() throws Exception { - try (final AutoCloseable unused = loadedTestBundle()) { - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - - ThingType weatherGroupType = thingTypes.stream() - .filter(it -> it.toString().equals("yahooweather:weather-with-group")).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.")); - } - } - - @Test - public void channelGroupsShouldBeLocalized() throws Exception { - try (final AutoCloseable unused = loadedTestBundle()) { - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - - ThingType weatherGroupType = thingTypes.stream() - .filter(it -> it.toString().equals("yahooweather:weather-with-group")).findFirst().get(); - assertNotNull(weatherGroupType); - assertThat(weatherGroupType.getChannelGroupDefinitions().size(), is(2)); - - ChannelGroupDefinition forecastTodayChannelGroupDefinition = weatherGroupType.getChannelGroupDefinitions() - .stream().filter(it -> it.getId().equals("forecastToday")).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 -> it.getId().equals("forecastTomorrow")) - .findFirst().get(); - assertNotNull(forecastTomorrowChannelGroupDefinition); - - assertThat(forecastTomorrowChannelGroupDefinition.getLabel(), is("Wettervorhersage morgen")); - assertThat(forecastTomorrowChannelGroupDefinition.getDescription(), - is("Wettervorhersage für den morgigen Tag.")); - } - } - - @Test - public void channelsInGroupTypeShouldBeLocalized() throws Exception { - try (final AutoCloseable unused = loadedTestBundle()) { - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - - ThingType weatherGroupType = thingTypes.stream() - .filter(it -> it.toString().equals("yahooweather:weather-with-group")).findFirst().get(); - assertNotNull(weatherGroupType); - assertEquals(2, weatherGroupType.getChannelGroupDefinitions().size()); - - ChannelGroupDefinition forecastTodayChannelGroupDefinition = weatherGroupType.getChannelGroupDefinitions() - .stream().filter(it -> it.getId().equals("forecastToday")).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 -> it.getId().equals("temperature")).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 -> it.getId().equals("minTemperature")).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 -> it.getId().equals("maxTemperature")).findFirst().get(); - assertNotNull(maxTemperatureChannelDefinition); - - assertEquals("Max. Temperatur", maxTemperatureChannelDefinition.getLabel()); - assertEquals("Maximale vorhergesagte Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).", - maxTemperatureChannelDefinition.getDescription()); - } - } - - @Test - public void channelTypeShouldBeLocalized() throws Exception { - try (final AutoCloseable unused = loadedTestBundle()) { - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - - ThingType weatherType = thingTypes.stream().filter(it -> it.toString().equals("yahooweather:weather")) - .findFirst().get(); - assertNotNull(weatherType); - assertThat(weatherType.getChannelDefinitions().size(), is(2)); - - ChannelType temperatureChannelType = channelTypeRegistry.getChannelType(weatherType.getChannelDefinitions() - .stream().filter(it -> it.getId().equals("temperature")).findFirst().get().getChannelTypeUID(), - Locale.GERMAN); - assertNotNull(temperatureChannelType); - - assertThat(temperatureChannelType.getLabel(), is("Temperatur")); - assertThat(temperatureChannelType.getDescription(), - is("Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).")); - assertThat(temperatureChannelType.getState().getPattern(), is("%d Grad Celsius")); - assertThat(temperatureChannelType.getState().getOptions().get(0).getLabel(), is("Mein String")); - } - } - - @Test - public void channelsShouldBeLocalized() throws Exception { - try (final AutoCloseable unused = loadedTestBundle()) { - Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); - - ThingType weatherType = thingTypes.stream().filter(it -> it.toString().equals("yahooweather:weather")) - .findFirst().get(); - assertNotNull(weatherType); - assertThat(weatherType.getChannelDefinitions().size(), is(2)); - - ChannelDefinition temperatureChannelDefinition = weatherType.getChannelDefinitions().stream() - .filter(it -> it.getId().equals("temperature")).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 -> it.getId().equals("minTemperature")).findFirst().get(); - assertNotNull(minTemperatureChannelDefinition); - - assertThat(minTemperatureChannelDefinition.getLabel(), is("Min. Temperatur")); - assertThat(minTemperatureChannelDefinition.getDescription(), - is("Minimale Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).")); - } - } -} +/** + * Copyright (c) 2010-2019 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.smarthome.core.thing.xml.test; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.*; + +import java.util.Collection; +import java.util.Locale; + +import org.eclipse.smarthome.core.thing.binding.ThingTypeProvider; +import org.eclipse.smarthome.core.thing.type.ChannelDefinition; +import org.eclipse.smarthome.core.thing.type.ChannelGroupDefinition; +import org.eclipse.smarthome.core.thing.type.ChannelGroupType; +import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeRegistry; +import org.eclipse.smarthome.core.thing.type.ChannelType; +import org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry; +import org.eclipse.smarthome.core.thing.type.ThingType; +import org.eclipse.smarthome.core.thing.xml.test.LoadedTestBundle.StuffAddition; +import org.eclipse.smarthome.test.java.JavaOSGiTest; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Henning Treu - Initial contribution + */ +public class ThingTypeI18nTest extends JavaOSGiTest { + + private LoadedTestBundle loadedTestBundle() throws Exception { + return new LoadedTestBundle("yahooweather.bundle", bundleContext, this::getService, + new StuffAddition().thingTypes(2)); + } + + private ThingTypeProvider thingTypeProvider; + private ChannelTypeRegistry channelTypeRegistry; + private ChannelGroupTypeRegistry channelGroupTypeRegistry; + + @Before + public void setUp() { + thingTypeProvider = getService(ThingTypeProvider.class); + assertNotNull(thingTypeProvider); + + channelTypeRegistry = getService(ChannelTypeRegistry.class); + assertNotNull(channelTypeRegistry); + + channelGroupTypeRegistry = getService(ChannelGroupTypeRegistry.class); + assertNotNull(channelGroupTypeRegistry); + } + + @Test + public void thingTypeShouldBeLocalized() throws Exception { + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); + + ThingType weatherType = thingTypes.stream().filter(it -> it.toString().equals("yahooweather:weather")) + .findFirst().get(); + assertNotNull(weatherType); + + assertThat(weatherType.getLabel(), is("Wetterinformation")); + assertThat(weatherType.getDescription(), + is("Stellt verschiedene Wetterdaten vom Yahoo Wetterdienst bereit")); + } + } + + @Test + public void channelGroupTypeShouldBeLocalized() throws Exception { + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); + + ThingType weatherGroupType = thingTypes.stream() + .filter(it -> it.toString().equals("yahooweather:weather-with-group")).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.")); + } + } + + @Test + public void channelGroupsShouldBeLocalized() throws Exception { + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); + + ThingType weatherGroupType = thingTypes.stream() + .filter(it -> it.toString().equals("yahooweather:weather-with-group")).findFirst().get(); + assertNotNull(weatherGroupType); + assertThat(weatherGroupType.getChannelGroupDefinitions().size(), is(2)); + + ChannelGroupDefinition forecastTodayChannelGroupDefinition = weatherGroupType.getChannelGroupDefinitions() + .stream().filter(it -> it.getId().equals("forecastToday")).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 -> it.getId().equals("forecastTomorrow")) + .findFirst().get(); + assertNotNull(forecastTomorrowChannelGroupDefinition); + + assertThat(forecastTomorrowChannelGroupDefinition.getLabel(), is("Wettervorhersage morgen")); + assertThat(forecastTomorrowChannelGroupDefinition.getDescription(), + is("Wettervorhersage für den morgigen Tag.")); + } + } + + @Test + public void channelsInGroupTypeShouldBeLocalized() throws Exception { + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); + + ThingType weatherGroupType = thingTypes.stream() + .filter(it -> it.toString().equals("yahooweather:weather-with-group")).findFirst().get(); + assertNotNull(weatherGroupType); + assertEquals(2, weatherGroupType.getChannelGroupDefinitions().size()); + + ChannelGroupDefinition forecastTodayChannelGroupDefinition = weatherGroupType.getChannelGroupDefinitions() + .stream().filter(it -> it.getId().equals("forecastToday")).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 -> it.getId().equals("temperature")).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 -> it.getId().equals("minTemperature")).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 -> it.getId().equals("maxTemperature")).findFirst().get(); + assertNotNull(maxTemperatureChannelDefinition); + + assertEquals("Max. Temperatur", maxTemperatureChannelDefinition.getLabel()); + assertEquals("Maximale vorhergesagte Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).", + maxTemperatureChannelDefinition.getDescription()); + } + } + + @Test + public void channelTypeShouldBeLocalized() throws Exception { + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); + + ThingType weatherType = thingTypes.stream().filter(it -> it.toString().equals("yahooweather:weather")) + .findFirst().get(); + assertNotNull(weatherType); + assertThat(weatherType.getChannelDefinitions().size(), is(2)); + + ChannelType temperatureChannelType = channelTypeRegistry.getChannelType(weatherType.getChannelDefinitions() + .stream().filter(it -> it.getId().equals("temperature")).findFirst().get().getChannelTypeUID(), + Locale.GERMAN); + assertNotNull(temperatureChannelType); + + assertThat(temperatureChannelType.getLabel(), is("Temperatur")); + assertThat(temperatureChannelType.getDescription(), + is("Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).")); + assertThat(temperatureChannelType.getState().getPattern(), is("%d Grad Celsius")); + assertThat(temperatureChannelType.getState().getOptions().get(0).getLabel(), is("Mein String")); + } + } + + @Test + public void channelsShouldBeLocalized() throws Exception { + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(Locale.GERMAN); + + ThingType weatherType = thingTypes.stream().filter(it -> it.toString().equals("yahooweather:weather")) + .findFirst().get(); + assertNotNull(weatherType); + assertThat(weatherType.getChannelDefinitions().size(), is(2)); + + ChannelDefinition temperatureChannelDefinition = weatherType.getChannelDefinitions().stream() + .filter(it -> it.getId().equals("temperature")).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 -> it.getId().equals("minTemperature")).findFirst().get(); + assertNotNull(minTemperatureChannelDefinition); + + assertThat(minTemperatureChannelDefinition.getLabel(), is("Min. Temperatur")); + assertThat(minTemperatureChannelDefinition.getDescription(), + is("Minimale Temperatur in Grad Celsius (Metrisch) oder Fahrenheit (Imperial).")); + } + } +} diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypesTest.java b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypesTest.java index 70d245bbf0e0e..d7521a5c62628 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypesTest.java +++ b/itests/org.openhab.core.thing.xml.tests/src/main/java/org/eclipse/smarthome/core/thing/xml/test/ThingTypesTest.java @@ -1,219 +1,219 @@ -/** - * Copyright (c) 2010-2019 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.smarthome.core.thing.xml.test; - -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; -import static org.junit.Assert.assertThat; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import org.eclipse.smarthome.core.thing.binding.ThingTypeProvider; -import org.eclipse.smarthome.core.thing.type.BridgeType; -import org.eclipse.smarthome.core.thing.type.ChannelDefinition; -import org.eclipse.smarthome.core.thing.type.ChannelGroupDefinition; -import org.eclipse.smarthome.core.thing.type.ChannelGroupType; -import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeRegistry; -import org.eclipse.smarthome.core.thing.type.ChannelType; -import org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry; -import org.eclipse.smarthome.core.thing.type.ThingType; -import org.eclipse.smarthome.core.thing.xml.test.LoadedTestBundle.StuffAddition; -import org.eclipse.smarthome.core.types.StateDescription; -import org.eclipse.smarthome.test.java.JavaOSGiTest; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Henning Treu - Initial contribution - */ -public class ThingTypesTest extends JavaOSGiTest { - - private LoadedTestBundle loadedTestBundle() throws Exception { - return new LoadedTestBundle("ThingTypesTest.bundle", bundleContext, this::getService, - new StuffAddition().thingTypes(4)); - } - - private ThingTypeProvider thingTypeProvider; - private ChannelTypeRegistry channelTypeRegistry; - private ChannelGroupTypeRegistry channelGroupTypeRegistry; - - @Before - public void setUp() { - thingTypeProvider = getService(ThingTypeProvider.class); - assertThat(thingTypeProvider, is(notNullValue())); - - channelTypeRegistry = getService(ChannelTypeRegistry.class); - assertThat(channelTypeRegistry, is(notNullValue())); - - channelGroupTypeRegistry = getService(ChannelGroupTypeRegistry.class); - assertThat(channelGroupTypeRegistry, is(notNullValue())); - } - - @Test - public void thingTypesShouldLoad() throws Exception { - try (final AutoCloseable unused = loadedTestBundle()) { - Collection thingTypes = thingTypeProvider.getThingTypes(null); - - // HUE Bridge - BridgeType bridgeType = (BridgeType) thingTypes.stream().filter(it -> it.toString().equals("hue:bridge")) - .findFirst().get(); - assertThat(bridgeType, is(notNullValue())); - assertThat(bridgeType.getCategory(), is("NetworkAppliance")); - assertThat(bridgeType.isListed(), is(false)); - assertThat(bridgeType.getLabel(), is("HUE Bridge")); - assertThat(bridgeType.getDescription(), is("The hue Bridge represents the Philips hue bridge.")); - assertThat(bridgeType.getProperties().size(), is(1)); - assertThat(bridgeType.getProperties().get("vendor"), is("Philips")); - assertThat(bridgeType.getRepresentationProperty(), is("serialNumber")); - - // HUE Lamp - ThingType thingType = thingTypes.stream().filter(it -> it.toString().equals("hue:lamp")).findFirst().get(); - - assertThat(thingType, is(notNullValue())); - assertThat(thingType.getCategory(), is("Lightbulb")); - assertThat(thingType.isListed(), is(false)); - assertThat(thingType.getLabel(), is("HUE Lamp")); - assertThat(thingType.getDescription(), is("My own great HUE Lamp.")); - assertThat(thingType.getSupportedBridgeTypeUIDs().size(), is(1)); - assertThat(thingType.getSupportedBridgeTypeUIDs().get(0), is("hue:bridge")); - assertThat(thingType.getExtensibleChannelTypeIds(), containsInAnyOrder("alarm", "brightness")); - assertThat(thingType.getProperties().size(), is(2)); - assertThat(thingType.getProperties().get("key1"), is("value1")); - assertThat(thingType.getProperties().get("key2"), is("value2")); - assertThat(thingType.getRepresentationProperty(), is("uniqueId")); - - List channelDefinitions = thingType.getChannelDefinitions(); - - assertThat(channelDefinitions.size(), is(3)); - ChannelDefinition colorChannel = channelDefinitions.stream().filter(it -> it.getId().equals("color")) - .findFirst().get(); - assertThat(colorChannel, is(notNullValue())); - - assertThat(colorChannel.getProperties().size(), is(2)); - assertThat(colorChannel.getProperties().get("chan.key1"), is("value1")); - assertThat(colorChannel.getProperties().get("chan.key2"), is("value2")); - - ChannelType colorChannelType = channelTypeRegistry.getChannelType(colorChannel.getChannelTypeUID()); - assertThat(colorChannelType, is(notNullValue())); - assertThat(colorChannelType.toString(), is("hue:color")); - assertThat(colorChannelType.getItemType(), is("ColorItem")); - assertThat(colorChannelType.getLabel(), is("HUE Lamp Color")); - assertThat(colorChannelType.getDescription(), is( - "The color channel allows to control the color of the hue lamp. It is also possible to dim values and switch the lamp on and off.")); - - Set tags = colorChannelType.getTags(); - assertThat(tags, is(notNullValue())); - assertThat(tags.contains("Hue"), is(true)); - assertThat(tags.contains("ColorLamp"), is(true)); - assertThat(tags.contains("AmbientLamp"), is(false)); - assertThat(tags.contains("AlarmSystem"), is(false)); - - ChannelDefinition colorTemperatureChannel = channelDefinitions.stream() - .filter(it -> it.getId().equals("color_temperature")).findFirst().get(); - - assertThat(colorTemperatureChannel, is(notNullValue())); - assertThat(colorTemperatureChannel.getProperties().size(), is(0)); - ChannelType colorTemperatureChannelType = channelTypeRegistry - .getChannelType(colorTemperatureChannel.getChannelTypeUID()); - assertThat(colorTemperatureChannelType, is(notNullValue())); - - assertThat(colorTemperatureChannelType.toString(), is("hue:color_temperature")); - assertThat(colorTemperatureChannelType.getItemType(), is("DimmerItem")); - assertThat(colorTemperatureChannelType.getLabel(), is("HUE Lamp Color Temperature")); - assertThat(colorTemperatureChannelType.getDescription(), is( - "The color temperature channel allows to set the color temperature from 0 (cold) to 100 (warm).")); - - tags = colorTemperatureChannelType.getTags(); - assertThat(tags, is(notNullValue())); - assertThat(tags.contains("Hue"), is(true)); - assertThat(tags.contains("AmbientLamp"), is(true)); - assertThat(tags.contains("ColorLamp"), is(false)); - assertThat(tags.contains("AlarmSystem"), is(false)); - - ChannelDefinition alarmChannel = channelDefinitions.stream().filter(it -> it.getId().equals("alarm")) - .findFirst().get(); - assertThat(alarmChannel, is(notNullValue())); - ChannelType alarmChannelType = channelTypeRegistry.getChannelType(alarmChannel.getChannelTypeUID()); - assertThat(alarmChannelType, is(notNullValue())); - - assertThat(alarmChannelType.toString(), is("hue:alarm")); - assertThat(alarmChannelType.getItemType(), is("Number")); - assertThat(alarmChannelType.getLabel(), is("Alarm System")); - assertThat(alarmChannelType.getDescription(), is("The light blinks if alarm is set.")); - - tags = alarmChannelType.getTags(); - assertThat(tags, is(notNullValue())); - assertThat(tags.contains("Hue"), is(true)); - assertThat(tags.contains("AlarmSystem"), is(true)); - assertThat(tags.contains("AmbientLamp"), is(false)); - assertThat(tags.contains("ColorLamp"), is(false)); - assertThat(alarmChannelType.getCategory(), is(equalTo("ALARM"))); - - StateDescription state = alarmChannelType.getState(); - assertThat(state.getMinimum(), is(BigDecimal.ZERO)); - assertThat(state.getMaximum(), is(BigDecimal.valueOf(100.0))); - assertThat(state.getStep(), is(BigDecimal.valueOf(10.0))); - assertThat(state.getPattern(), is(equalTo("%d Peek"))); - assertThat(state.isReadOnly(), is(true)); - assertThat(state.getOptions().size(), is(2)); - assertThat(state.getOptions().get(0).getValue(), is(equalTo("SOUND"))); - assertThat(state.getOptions().get(0).getLabel(), is(equalTo("My great sound."))); - - // HUE Lamp with group - thingType = thingTypes.stream().filter(it -> it.toString().equals("hue:lamp-with-group")).findFirst().get(); - assertThat(thingType, is(notNullValue())); - assertThat(thingType.getProperties().size(), is(0)); - assertThat(thingType.getCategory(), is(nullValue())); - assertThat(thingType.isListed(), is(true)); - assertThat(thingType.getExtensibleChannelTypeIds(), containsInAnyOrder("brightness", "alarm")); - - List channelGroupDefinitions = thingType.getChannelGroupDefinitions(); - assertThat(channelGroupDefinitions.size(), is(2)); - - // Channel Group - ChannelGroupDefinition channelGroupDefinition = channelGroupDefinitions.stream() - .filter(it -> it.getId().equals("lampgroup")).findFirst().get(); - assertThat(channelGroupDefinition, is(notNullValue())); - ChannelGroupType channelGroupType = channelGroupTypeRegistry - .getChannelGroupType(channelGroupDefinition.getTypeUID()); - assertThat(channelGroupType, is(notNullValue())); - channelDefinitions = channelGroupType.getChannelDefinitions(); - assertThat(channelDefinitions.size(), is(3)); - - // Channel Group without channels - channelGroupDefinition = channelGroupDefinitions.stream() - .filter(it -> it.getId().equals("lampgroup-without-channels")).findFirst().get(); - assertThat(channelGroupDefinition, is(notNullValue())); - channelGroupType = channelGroupTypeRegistry.getChannelGroupType(channelGroupDefinition.getTypeUID()); - assertThat(channelGroupType, is(notNullValue())); - channelDefinitions = channelGroupType.getChannelDefinitions(); - assertThat(channelDefinitions.size(), is(0)); - - // HUE Lamp without channels - thingType = thingTypes.stream().filter(it -> it.toString().equals("hue:lamp-without-channels")).findFirst() - .get(); - assertThat(thingType, is(notNullValue())); - channelDefinitions = thingType.getChannelDefinitions(); - assertThat(channelDefinitions.size(), is(0)); - } - } - - @Test - public void thingTypesShouldBeRemovedWhenBundleIsUninstalled() throws Exception { - try (final AutoCloseable unused = loadedTestBundle()) { - } - } -} +/** + * Copyright (c) 2010-2019 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.smarthome.core.thing.xml.test; + +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; +import static org.junit.Assert.assertThat; + +import java.math.BigDecimal; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import org.eclipse.smarthome.core.thing.binding.ThingTypeProvider; +import org.eclipse.smarthome.core.thing.type.BridgeType; +import org.eclipse.smarthome.core.thing.type.ChannelDefinition; +import org.eclipse.smarthome.core.thing.type.ChannelGroupDefinition; +import org.eclipse.smarthome.core.thing.type.ChannelGroupType; +import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeRegistry; +import org.eclipse.smarthome.core.thing.type.ChannelType; +import org.eclipse.smarthome.core.thing.type.ChannelTypeRegistry; +import org.eclipse.smarthome.core.thing.type.ThingType; +import org.eclipse.smarthome.core.thing.xml.test.LoadedTestBundle.StuffAddition; +import org.eclipse.smarthome.core.types.StateDescription; +import org.eclipse.smarthome.test.java.JavaOSGiTest; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Henning Treu - Initial contribution + */ +public class ThingTypesTest extends JavaOSGiTest { + + private LoadedTestBundle loadedTestBundle() throws Exception { + return new LoadedTestBundle("ThingTypesTest.bundle", bundleContext, this::getService, + new StuffAddition().thingTypes(4)); + } + + private ThingTypeProvider thingTypeProvider; + private ChannelTypeRegistry channelTypeRegistry; + private ChannelGroupTypeRegistry channelGroupTypeRegistry; + + @Before + public void setUp() { + thingTypeProvider = getService(ThingTypeProvider.class); + assertThat(thingTypeProvider, is(notNullValue())); + + channelTypeRegistry = getService(ChannelTypeRegistry.class); + assertThat(channelTypeRegistry, is(notNullValue())); + + channelGroupTypeRegistry = getService(ChannelGroupTypeRegistry.class); + assertThat(channelGroupTypeRegistry, is(notNullValue())); + } + + @Test + public void thingTypesShouldLoad() throws Exception { + try (final AutoCloseable unused = loadedTestBundle()) { + Collection thingTypes = thingTypeProvider.getThingTypes(null); + + // HUE Bridge + BridgeType bridgeType = (BridgeType) thingTypes.stream().filter(it -> it.toString().equals("hue:bridge")) + .findFirst().get(); + assertThat(bridgeType, is(notNullValue())); + assertThat(bridgeType.getCategory(), is("NetworkAppliance")); + assertThat(bridgeType.isListed(), is(false)); + assertThat(bridgeType.getLabel(), is("HUE Bridge")); + assertThat(bridgeType.getDescription(), is("The hue Bridge represents the Philips hue bridge.")); + assertThat(bridgeType.getProperties().size(), is(1)); + assertThat(bridgeType.getProperties().get("vendor"), is("Philips")); + assertThat(bridgeType.getRepresentationProperty(), is("serialNumber")); + + // HUE Lamp + ThingType thingType = thingTypes.stream().filter(it -> it.toString().equals("hue:lamp")).findFirst().get(); + + assertThat(thingType, is(notNullValue())); + assertThat(thingType.getCategory(), is("Lightbulb")); + assertThat(thingType.isListed(), is(false)); + assertThat(thingType.getLabel(), is("HUE Lamp")); + assertThat(thingType.getDescription(), is("My own great HUE Lamp.")); + assertThat(thingType.getSupportedBridgeTypeUIDs().size(), is(1)); + assertThat(thingType.getSupportedBridgeTypeUIDs().get(0), is("hue:bridge")); + assertThat(thingType.getExtensibleChannelTypeIds(), containsInAnyOrder("alarm", "brightness")); + assertThat(thingType.getProperties().size(), is(2)); + assertThat(thingType.getProperties().get("key1"), is("value1")); + assertThat(thingType.getProperties().get("key2"), is("value2")); + assertThat(thingType.getRepresentationProperty(), is("uniqueId")); + + List channelDefinitions = thingType.getChannelDefinitions(); + + assertThat(channelDefinitions.size(), is(3)); + ChannelDefinition colorChannel = channelDefinitions.stream().filter(it -> it.getId().equals("color")) + .findFirst().get(); + assertThat(colorChannel, is(notNullValue())); + + assertThat(colorChannel.getProperties().size(), is(2)); + assertThat(colorChannel.getProperties().get("chan.key1"), is("value1")); + assertThat(colorChannel.getProperties().get("chan.key2"), is("value2")); + + ChannelType colorChannelType = channelTypeRegistry.getChannelType(colorChannel.getChannelTypeUID()); + assertThat(colorChannelType, is(notNullValue())); + assertThat(colorChannelType.toString(), is("hue:color")); + assertThat(colorChannelType.getItemType(), is("ColorItem")); + assertThat(colorChannelType.getLabel(), is("HUE Lamp Color")); + assertThat(colorChannelType.getDescription(), is( + "The color channel allows to control the color of the hue lamp. It is also possible to dim values and switch the lamp on and off.")); + + Set tags = colorChannelType.getTags(); + assertThat(tags, is(notNullValue())); + assertThat(tags.contains("Hue"), is(true)); + assertThat(tags.contains("ColorLamp"), is(true)); + assertThat(tags.contains("AmbientLamp"), is(false)); + assertThat(tags.contains("AlarmSystem"), is(false)); + + ChannelDefinition colorTemperatureChannel = channelDefinitions.stream() + .filter(it -> it.getId().equals("color_temperature")).findFirst().get(); + + assertThat(colorTemperatureChannel, is(notNullValue())); + assertThat(colorTemperatureChannel.getProperties().size(), is(0)); + ChannelType colorTemperatureChannelType = channelTypeRegistry + .getChannelType(colorTemperatureChannel.getChannelTypeUID()); + assertThat(colorTemperatureChannelType, is(notNullValue())); + + assertThat(colorTemperatureChannelType.toString(), is("hue:color_temperature")); + assertThat(colorTemperatureChannelType.getItemType(), is("DimmerItem")); + assertThat(colorTemperatureChannelType.getLabel(), is("HUE Lamp Color Temperature")); + assertThat(colorTemperatureChannelType.getDescription(), is( + "The color temperature channel allows to set the color temperature from 0 (cold) to 100 (warm).")); + + tags = colorTemperatureChannelType.getTags(); + assertThat(tags, is(notNullValue())); + assertThat(tags.contains("Hue"), is(true)); + assertThat(tags.contains("AmbientLamp"), is(true)); + assertThat(tags.contains("ColorLamp"), is(false)); + assertThat(tags.contains("AlarmSystem"), is(false)); + + ChannelDefinition alarmChannel = channelDefinitions.stream().filter(it -> it.getId().equals("alarm")) + .findFirst().get(); + assertThat(alarmChannel, is(notNullValue())); + ChannelType alarmChannelType = channelTypeRegistry.getChannelType(alarmChannel.getChannelTypeUID()); + assertThat(alarmChannelType, is(notNullValue())); + + assertThat(alarmChannelType.toString(), is("hue:alarm")); + assertThat(alarmChannelType.getItemType(), is("Number")); + assertThat(alarmChannelType.getLabel(), is("Alarm System")); + assertThat(alarmChannelType.getDescription(), is("The light blinks if alarm is set.")); + + tags = alarmChannelType.getTags(); + assertThat(tags, is(notNullValue())); + assertThat(tags.contains("Hue"), is(true)); + assertThat(tags.contains("AlarmSystem"), is(true)); + assertThat(tags.contains("AmbientLamp"), is(false)); + assertThat(tags.contains("ColorLamp"), is(false)); + assertThat(alarmChannelType.getCategory(), is(equalTo("ALARM"))); + + StateDescription state = alarmChannelType.getState(); + assertThat(state.getMinimum(), is(BigDecimal.ZERO)); + assertThat(state.getMaximum(), is(BigDecimal.valueOf(100.0))); + assertThat(state.getStep(), is(BigDecimal.valueOf(10.0))); + assertThat(state.getPattern(), is(equalTo("%d Peek"))); + assertThat(state.isReadOnly(), is(true)); + assertThat(state.getOptions().size(), is(2)); + assertThat(state.getOptions().get(0).getValue(), is(equalTo("SOUND"))); + assertThat(state.getOptions().get(0).getLabel(), is(equalTo("My great sound."))); + + // HUE Lamp with group + thingType = thingTypes.stream().filter(it -> it.toString().equals("hue:lamp-with-group")).findFirst().get(); + assertThat(thingType, is(notNullValue())); + assertThat(thingType.getProperties().size(), is(0)); + assertThat(thingType.getCategory(), is(nullValue())); + assertThat(thingType.isListed(), is(true)); + assertThat(thingType.getExtensibleChannelTypeIds(), containsInAnyOrder("brightness", "alarm")); + + List channelGroupDefinitions = thingType.getChannelGroupDefinitions(); + assertThat(channelGroupDefinitions.size(), is(2)); + + // Channel Group + ChannelGroupDefinition channelGroupDefinition = channelGroupDefinitions.stream() + .filter(it -> it.getId().equals("lampgroup")).findFirst().get(); + assertThat(channelGroupDefinition, is(notNullValue())); + ChannelGroupType channelGroupType = channelGroupTypeRegistry + .getChannelGroupType(channelGroupDefinition.getTypeUID()); + assertThat(channelGroupType, is(notNullValue())); + channelDefinitions = channelGroupType.getChannelDefinitions(); + assertThat(channelDefinitions.size(), is(3)); + + // Channel Group without channels + channelGroupDefinition = channelGroupDefinitions.stream() + .filter(it -> it.getId().equals("lampgroup-without-channels")).findFirst().get(); + assertThat(channelGroupDefinition, is(notNullValue())); + channelGroupType = channelGroupTypeRegistry.getChannelGroupType(channelGroupDefinition.getTypeUID()); + assertThat(channelGroupType, is(notNullValue())); + channelDefinitions = channelGroupType.getChannelDefinitions(); + assertThat(channelDefinitions.size(), is(0)); + + // HUE Lamp without channels + thingType = thingTypes.stream().filter(it -> it.toString().equals("hue:lamp-without-channels")).findFirst() + .get(); + assertThat(thingType, is(notNullValue())); + channelDefinitions = thingType.getChannelDefinitions(); + assertThat(channelDefinitions.size(), is(0)); + } + } + + @Test + public void thingTypesShouldBeRemovedWhenBundleIsUninstalled() throws Exception { + try (final AutoCloseable unused = loadedTestBundle()) { + } + } +} diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/ESH-INF/thing/thing-types.xml index f5ca2bca7263e..6d088b0abe017 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/ESH-INF/thing/thing-types.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesI18nTest.bundle/ESH-INF/thing/thing-types.xml @@ -2,7 +2,7 @@ + xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesTest.bundle/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesTest.bundle/ESH-INF/thing/thing-types.xml index 64f547f5f2e76..bda1065a5084f 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesTest.bundle/ESH-INF/thing/thing-types.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ChannelTypesTest.bundle/ESH-INF/thing/thing-types.xml @@ -2,7 +2,7 @@ + xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/binding/binding.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/binding/binding.xml index 57db679802d14..50ba03e24aa4b 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/binding/binding.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/binding/binding.xml @@ -1,12 +1,11 @@ + xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd" id="hue"> hue Binding The hue Binding integrates the Philips hue system. It allows to control hue lights. Deutsche Telekom AG - + diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/thing/thing-types.xml index 5bccd0bc9e063..48dfb7322142e 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/thing/thing-types.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ConfigDescriptionsTest.bundle/ESH-INF/thing/thing-types.xml @@ -1,6 +1,6 @@ - @@ -52,40 +52,40 @@ - - + + - - - - - + + + + + - + Specifies the unit of the data. Valid values are "us" or "metric". metric - + - + - item - - alarm, light - color - hue - + item + + alarm, light + color + hue + - + - + @@ -94,7 +94,8 @@ ColorItem The color channel allows to control the color of the hue - lamp. It is also possible to dim values and switch the lamp on and + lamp. It is also possible to dim values and + switch the lamp on and off. diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/ESH-INF/binding/binding.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/ESH-INF/binding/binding.xml index 59bd0971138ac..85f5683e3092f 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/ESH-INF/binding/binding.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannels.bundle/ESH-INF/binding/binding.xml @@ -1,11 +1,10 @@ + xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd" id="SystemChannels"> SystemChannels Test Binding Used to test System Wide Channels. Provides definitions of system channels. Deutsche Telekom AG - + diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/ESH-INF/binding/binding.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/ESH-INF/binding/binding.xml index 24b89c898b96e..1df5fc5b45377 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/ESH-INF/binding/binding.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/ESH-INF/binding/binding.xml @@ -1,11 +1,11 @@ + xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd" id="SystemChannels"> SystemChannelsInChannelGroups Test Binding - Used to test System Wide Channels which are used within Channel Groups. Provides definitions of system channels. + Used to test System Wide Channels which are used within Channel Groups. Provides definitions of system + channels. Deutsche Telekom AG - + diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/ESH-INF/thing/thing-types.xml index b6a9481eca9b4..5e4f606c559d7 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/ESH-INF/thing/thing-types.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsInChannelGroups.bundle/ESH-INF/thing/thing-types.xml @@ -1,5 +1,6 @@ - diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/ESH-INF/binding/binding.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/ESH-INF/binding/binding.xml index c185600216ba1..0ac4d68a625ea 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/ESH-INF/binding/binding.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/ESH-INF/binding/binding.xml @@ -1,7 +1,7 @@ SystemChannelsNoThingTypes Test Binding diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/ESH-INF/thing/thing-types.xml index 6d802ab44920c..93796969b7300 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/ESH-INF/thing/thing-types.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsNoThingTypes.bundle/ESH-INF/thing/thing-types.xml @@ -1,10 +1,10 @@ - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" + xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> + + Number @@ -15,8 +15,7 @@ - + diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/ESH-INF/binding/binding.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/ESH-INF/binding/binding.xml index c2671263c4e67..11158f2922770 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/ESH-INF/binding/binding.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/ESH-INF/binding/binding.xml @@ -1,7 +1,7 @@ SystemChannelsUser Test Binding diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/ESH-INF/thing/thing-types.xml index 5678a4d1f1b35..c1df6f9e53c4c 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/ESH-INF/thing/thing-types.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/SystemChannelsUser.bundle/ESH-INF/thing/thing-types.xml @@ -1,12 +1,12 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" + xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> - - - Simple wireless router + + + Simple wireless router @@ -14,5 +14,5 @@ - + diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/ESH-INF/binding/binding.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/ESH-INF/binding/binding.xml index 57db679802d14..50ba03e24aa4b 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/ESH-INF/binding/binding.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/ESH-INF/binding/binding.xml @@ -1,12 +1,11 @@ + xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd" id="hue"> hue Binding The hue Binding integrates the Philips hue system. It allows to control hue lights. Deutsche Telekom AG - + diff --git a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/ESH-INF/thing/thing-types.xml b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/ESH-INF/thing/thing-types.xml index 1264b5bc45d24..d86de2694c7f9 100644 --- a/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/ESH-INF/thing/thing-types.xml +++ b/itests/org.openhab.core.thing.xml.tests/src/main/resources/test-bundle-pool/ThingTypesTest.bundle/ESH-INF/thing/thing-types.xml @@ -1,7 +1,7 @@ + xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> diff --git a/itests/org.openhab.core.voice.tests/pom.xml b/itests/org.openhab.core.voice.tests/pom.xml index 1185038a8893b..5e94b1ec27113 100644 --- a/itests/org.openhab.core.voice.tests/pom.xml +++ b/itests/org.openhab.core.voice.tests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/itests/pom.xml b/itests/pom.xml index 2b21a26ce5dfa..98c8ec148856d 100644 --- a/itests/pom.xml +++ b/itests/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0