diff --git a/itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/SysteminfoOSGiTest.java b/itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/SysteminfoOSGiTest.java
index 2a8f35967..84f2a6b52 100644
--- a/itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/SysteminfoOSGiTest.java
+++ b/itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/SysteminfoOSGiTest.java
@@ -40,7 +40,6 @@ import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants;
import org.openhab.binding.systeminfo.internal.SysteminfoHandlerFactory;
-import org.openhab.binding.systeminfo.internal.SysteminfoThingTypeProvider;
import org.openhab.binding.systeminfo.internal.discovery.SysteminfoDiscoveryService;
import org.openhab.binding.systeminfo.internal.handler.SysteminfoHandler;
import org.openhab.binding.systeminfo.internal.model.DeviceNotFoundException;
@@ -51,6 +50,7 @@ import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryService;
import org.openhab.core.config.discovery.inbox.Inbox;
import org.openhab.core.config.discovery.inbox.InboxPredicates;
+import org.openhab.core.i18n.UnitProvider;
import org.openhab.core.items.GenericItem;
import org.openhab.core.items.ItemNotFoundException;
import org.openhab.core.items.ItemRegistry;
@@ -77,7 +77,6 @@ import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerFactory;
-import org.openhab.core.thing.binding.ThingTypeProvider;
import org.openhab.core.thing.binding.builder.ChannelBuilder;
import org.openhab.core.thing.binding.builder.ThingBuilder;
import org.openhab.core.thing.link.ItemChannelLink;
@@ -117,14 +116,16 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
*/
private static final int DEFAULT_TEST_INTERVAL_MEDIUM = 3;
- private @Nullable Thing systemInfoThing;
+ private @Nullable Thing systeminfoThing;
private @Nullable GenericItem testItem;
private @Mock @NonNullByDefault({}) OSHISysteminfo mockedSystemInfo;
private @NonNullByDefault({}) SysteminfoHandlerFactory systeminfoHandlerFactory;
private @NonNullByDefault({}) ThingRegistry thingRegistry;
private @NonNullByDefault({}) ItemRegistry itemRegistry;
- private @NonNullByDefault({}) SysteminfoThingTypeProvider systemThingTypeProvider;
+ private @NonNullByDefault({}) ManagedThingProvider managedThingProvider;
+ private @NonNullByDefault({}) ManagedItemChannelLinkProvider itemChannelLinkProvider;
+ private @NonNullByDefault({}) UnitProvider unitProvider;
@BeforeEach
public void setUp() {
@@ -148,11 +149,6 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
registerService(mockedSystemInfo);
- waitForAssert(() -> {
- systemThingTypeProvider = getService(ThingTypeProvider.class, SysteminfoThingTypeProvider.class);
- assertThat(systemThingTypeProvider, is(notNullValue()));
- });
-
waitForAssert(() -> {
systeminfoHandlerFactory = getService(ThingHandlerFactory.class, SysteminfoHandlerFactory.class);
assertThat(systeminfoHandlerFactory, is(notNullValue()));
@@ -182,11 +178,26 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
itemRegistry = getService(ItemRegistry.class);
assertThat(itemRegistry, is(notNullValue()));
});
+
+ waitForAssert(() -> {
+ managedThingProvider = getService(ThingProvider.class, ManagedThingProvider.class);
+ assertThat(managedThingProvider, is(notNullValue()));
+ });
+
+ waitForAssert(() -> {
+ itemChannelLinkProvider = getService(ManagedItemChannelLinkProvider.class);
+ assertThat(itemChannelLinkProvider, is(notNullValue()));
+ });
+
+ waitForAssert(() -> {
+ unitProvider = getService(UnitProvider.class);
+ assertThat(unitProvider, is(notNullValue()));
+ });
}
@AfterEach
public void tearDown() {
- Thing thing = systemInfoThing;
+ Thing thing = systeminfoThing;
if (thing != null) {
// Remove the systeminfo thing. The handler will be also disposed automatically
Thing removedThing = thingRegistry.forceRemove(thing.getUID());
@@ -266,14 +277,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
Thing thing = ThingBuilder.create(thingTypeUID, thingUID).withConfiguration(thingConfiguration)
.withChannel(channel).build();
- systemInfoThing = thing;
+ systeminfoThing = thing;
- ManagedThingProvider managedThingProvider = getService(ThingProvider.class, ManagedThingProvider.class);
- assertThat(managedThingProvider, is(notNullValue()));
-
- if (managedThingProvider != null) {
- managedThingProvider.add(thing);
- }
+ managedThingProvider.add(thing);
waitForAssert(() -> {
SysteminfoHandler handler = (SysteminfoHandler) thing.getHandler();
@@ -289,7 +295,7 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
}
private void assertItemState(String acceptedItemType, String itemName, String priority, State expectedState) {
- Thing thing = systemInfoThing;
+ Thing thing = systeminfoThing;
if (thing == null) {
throw new AssertionError("Thing is null");
}
@@ -331,7 +337,7 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
private void intializeItem(ChannelUID channelUID, String itemName, String acceptedItemType) {
GenericItem item = null;
if (acceptedItemType.startsWith("Number")) {
- item = new NumberItem(acceptedItemType, itemName);
+ item = new NumberItem(acceptedItemType, itemName, unitProvider);
} else if ("String".equals(acceptedItemType)) {
item = new StringItem(itemName);
}
@@ -341,13 +347,6 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
itemRegistry.add(item);
testItem = item;
- ManagedItemChannelLinkProvider itemChannelLinkProvider = getService(ManagedItemChannelLinkProvider.class);
- assertThat(itemChannelLinkProvider, is(notNullValue()));
-
- if (itemChannelLinkProvider == null) {
- return;
- }
-
itemChannelLinkProvider.add(new ItemChannelLink(itemName, channelUID));
}
@@ -369,7 +368,7 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
private void testInvalidConfiguration() {
waitForAssert(() -> {
- Thing thing = systemInfoThing;
+ Thing thing = systeminfoThing;
if (thing != null) {
assertThat("Invalid configuration is used !", thing.getStatus(), is(equalTo(ThingStatus.OFFLINE)));
assertThat(thing.getStatusInfo().getStatusDetail(),
@@ -989,7 +988,9 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
discoveryServiceMock.startScan();
Inbox inbox = getService(Inbox.class);
- assertThat(inbox, is(notNullValue()));
+ waitForAssert(() -> {
+ assertThat(inbox, is(notNullValue()));
+ });
if (inbox == null) {
return;
@@ -1004,11 +1005,11 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
inbox.approve(computerUID, SysteminfoDiscoveryService.DEFAULT_THING_LABEL, null);
waitForAssert(() -> {
- systemInfoThing = thingRegistry.get(computerUID);
- assertThat(systemInfoThing, is(notNullValue()));
+ systeminfoThing = thingRegistry.get(computerUID);
+ assertThat(systeminfoThing, is(notNullValue()));
});
- Thing thing = systemInfoThing;
+ Thing thing = systeminfoThing;
if (thing == null) {
return;
}
@@ -1099,7 +1100,7 @@ public class SysteminfoOSGiTest extends JavaOSGiTest {
String acceptedItemType = "Number";
initializeThingWithChannel(DEFAULT_TEST_CHANNEL_ID, acceptedItemType);
- Thing thing = systemInfoThing;
+ Thing thing = systeminfoThing;
if (thing == null) {
throw new AssertionError("Thing is null");
}
diff --git a/itests/pom.xml b/itests/pom.xml
index 2a0bbacc1..50c3ae517 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -35,9 +35,7 @@
-->
org.openhab.binding.nest.tests
org.openhab.binding.ntp.tests
-
+ org.openhab.binding.systeminfo.tests
org.openhab.binding.tradfri.tests
org.openhab.binding.wemo.tests
org.openhab.persistence.mapdb.tests