diff --git a/itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/discovery/test/WemoDiscoveryOSGiTest.java b/itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/discovery/test/WemoDiscoveryOSGiTest.java index 19783580a1928..d4b185025094e 100644 --- a/itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/discovery/test/WemoDiscoveryOSGiTest.java +++ b/itests/org.openhab.binding.wemo.tests/src/main/java/org/openhab/binding/wemo/internal/discovery/test/WemoDiscoveryOSGiTest.java @@ -12,6 +12,7 @@ */ package org.openhab.binding.wemo.internal.discovery.test; +import static org.eclipse.smarthome.config.discovery.inbox.InboxPredicates.forThingUID; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; @@ -21,9 +22,9 @@ import java.util.Collection; import java.util.List; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.smarthome.config.discovery.DiscoveryResult; import org.eclipse.smarthome.config.discovery.inbox.Inbox; -import org.eclipse.smarthome.config.discovery.inbox.InboxFilterCriteria; import org.eclipse.smarthome.core.thing.Thing; import org.eclipse.smarthome.core.thing.ThingTypeUID; import org.eclipse.smarthome.core.thing.ThingUID; @@ -42,13 +43,14 @@ * @author Svilen Valkanov - Initial contribution * @author Stefan Triller - Ported Tests from Groovy to Java */ +@NonNullByDefault public class WemoDiscoveryOSGiTest extends GenericWemoOSGiTest { // UpnP service information - private final String SERVICE_ID = "basicevent"; - private final String SERVICE_NUMBER = "1"; + private static final String SERVICE_ID = "basicevent"; + private static final String SERVICE_NUMBER = "1"; - private Inbox inbox; + private @NonNullByDefault({}) Inbox inbox; @Before public void setUp() throws IOException { @@ -75,19 +77,14 @@ public void assertSupportedThingIsDiscovered() waitForAssert(() -> { Collection devices = mockUpnpService.getRegistry().getDevices(); assertThat(devices.size(), is(1)); - Device device = null; - for (Device d : devices) { - device = d; - break; - } + Device device = devices.iterator().next(); assertThat(device.getDetails().getModelDetails().getModelName(), is(model)); }); ThingUID thingUID = new ThingUID(thingType, DEVICE_UDN); waitForAssert(() -> { - List results = inbox.get(new InboxFilterCriteria(thingUID, null)); - assertFalse(results.isEmpty()); + assertTrue(inbox.stream().anyMatch(forThingUID(thingUID))); }); inbox.approve(thingUID, DEVICE_FRIENDLY_NAME);