diff --git a/itests/org.openhab.binding.hue.tests/itest.bndrun b/itests/org.openhab.binding.hue.tests/itest.bndrun index 230f7bcda8c..f07fb47f10c 100644 --- a/itests/org.openhab.binding.hue.tests/itest.bndrun +++ b/itests/org.openhab.binding.hue.tests/itest.bndrun @@ -67,4 +67,5 @@ Fragment-Host: org.openhab.binding.hue org.openhab.core.test;version='[3.0.0,3.0.1)',\ org.openhab.core.thing;version='[3.0.0,3.0.1)',\ org.openhab.core.thing.xml;version='[3.0.0,3.0.1)',\ - org.opentest4j;version='[1.2.0,1.2.1)' + org.opentest4j;version='[1.2.0,1.2.1)',\ + org.eclipse.jdt.annotation;version='[2.2.100,2.2.101)' diff --git a/itests/org.openhab.binding.hue.tests/src/main/java/org/openhab/binding/hue/internal/handler/HueBridgeHandlerOSGiTest.java b/itests/org.openhab.binding.hue.tests/src/main/java/org/openhab/binding/hue/internal/handler/HueBridgeHandlerOSGiTest.java index 5a76b1deb60..c0c9c121f77 100644 --- a/itests/org.openhab.binding.hue.tests/src/main/java/org/openhab/binding/hue/internal/handler/HueBridgeHandlerOSGiTest.java +++ b/itests/org.openhab.binding.hue.tests/src/main/java/org/openhab/binding/hue/internal/handler/HueBridgeHandlerOSGiTest.java @@ -12,6 +12,7 @@ */ package org.openhab.binding.hue.internal.handler; +import static org.eclipse.jdt.annotation.Checks.requireNonNull; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.*; @@ -50,7 +51,7 @@ import org.openhab.core.thing.ThingUID; */ public class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTestParent { - private final ThingTypeUID BRIDGE_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "bridge"); + private static final ThingTypeUID BRIDGE_THING_TYPE_UID = new ThingTypeUID(BINDING_ID, "bridge"); private static final String TEST_USER_NAME = "eshTestUser"; private static final String DUMMY_HOST = "1.2.3.4"; @@ -132,7 +133,7 @@ public class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTestParent { hueBridgeHandler.onNotAuthenticated(); assertEquals("notAuthenticatedUser", bridge.getConfiguration().get(USER_NAME)); - assertEquals(ThingStatus.OFFLINE, bridge.getStatus()); + waitForAssert(() -> assertEquals(ThingStatus.OFFLINE, bridge.getStatus())); assertEquals(ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, bridge.getStatusInfo().getStatusDetail()); } @@ -156,7 +157,7 @@ public class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTestParent { hueBridgeHandler.onNotAuthenticated(); assertNull(bridge.getConfiguration().get(USER_NAME)); - assertEquals(ThingStatus.OFFLINE, bridge.getStatus()); + waitForAssert(() -> assertEquals(ThingStatus.OFFLINE, bridge.getStatus())); assertEquals(ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, bridge.getStatusInfo().getStatusDetail()); } @@ -180,7 +181,7 @@ public class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTestParent { hueBridgeHandler.onNotAuthenticated(); assertNull(bridge.getConfiguration().get(USER_NAME)); - assertEquals(ThingStatus.OFFLINE, bridge.getStatus()); + waitForAssert(() -> assertEquals(ThingStatus.OFFLINE, bridge.getStatus())); assertEquals(ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, bridge.getStatusInfo().getStatusDetail()); } @@ -196,7 +197,7 @@ public class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTestParent { hueBridgeHandler.onConnectionLost(); - assertEquals(ThingStatus.OFFLINE, bridge.getStatus()); + waitForAssert(() -> assertEquals(ThingStatus.OFFLINE, bridge.getStatus())); assertNotEquals(ThingStatusDetail.BRIDGE_OFFLINE, bridge.getStatusInfo().getStatusDetail()); } @@ -236,7 +237,7 @@ public class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTestParent { Bridge bridge = (Bridge) thingRegistry.createThingOfType(BRIDGE_THING_TYPE_UID, new ThingUID(BRIDGE_THING_TYPE_UID, "testBridge"), null, "Bridge", configuration); - assertNotNull(bridge); + bridge = requireNonNull(bridge, "Bridge is null"); thingRegistry.add(bridge); return bridge; }