[hue] Improve HueBridgeHandlerOSGiTest stability (#8621)
The ThingStatus is updated asynchronously so the test is unstable when the status is not updated immediately. Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
515658de7f
commit
1b0876f719
@ -67,4 +67,5 @@ Fragment-Host: org.openhab.binding.hue
|
|||||||
org.openhab.core.test;version='[3.0.0,3.0.1)',\
|
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;version='[3.0.0,3.0.1)',\
|
||||||
org.openhab.core.thing.xml;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)'
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.binding.hue.internal.handler;
|
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.CoreMatchers.equalTo;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
@ -50,7 +51,7 @@ import org.openhab.core.thing.ThingUID;
|
|||||||
*/
|
*/
|
||||||
public class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTestParent {
|
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 TEST_USER_NAME = "eshTestUser";
|
||||||
private static final String DUMMY_HOST = "1.2.3.4";
|
private static final String DUMMY_HOST = "1.2.3.4";
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ public class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTestParent {
|
|||||||
hueBridgeHandler.onNotAuthenticated();
|
hueBridgeHandler.onNotAuthenticated();
|
||||||
|
|
||||||
assertEquals("notAuthenticatedUser", bridge.getConfiguration().get(USER_NAME));
|
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());
|
assertEquals(ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, bridge.getStatusInfo().getStatusDetail());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +157,7 @@ public class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTestParent {
|
|||||||
hueBridgeHandler.onNotAuthenticated();
|
hueBridgeHandler.onNotAuthenticated();
|
||||||
|
|
||||||
assertNull(bridge.getConfiguration().get(USER_NAME));
|
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());
|
assertEquals(ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, bridge.getStatusInfo().getStatusDetail());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +181,7 @@ public class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTestParent {
|
|||||||
hueBridgeHandler.onNotAuthenticated();
|
hueBridgeHandler.onNotAuthenticated();
|
||||||
|
|
||||||
assertNull(bridge.getConfiguration().get(USER_NAME));
|
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());
|
assertEquals(ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, bridge.getStatusInfo().getStatusDetail());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +197,7 @@ public class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTestParent {
|
|||||||
|
|
||||||
hueBridgeHandler.onConnectionLost();
|
hueBridgeHandler.onConnectionLost();
|
||||||
|
|
||||||
assertEquals(ThingStatus.OFFLINE, bridge.getStatus());
|
waitForAssert(() -> assertEquals(ThingStatus.OFFLINE, bridge.getStatus()));
|
||||||
assertNotEquals(ThingStatusDetail.BRIDGE_OFFLINE, bridge.getStatusInfo().getStatusDetail());
|
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,
|
Bridge bridge = (Bridge) thingRegistry.createThingOfType(BRIDGE_THING_TYPE_UID,
|
||||||
new ThingUID(BRIDGE_THING_TYPE_UID, "testBridge"), null, "Bridge", configuration);
|
new ThingUID(BRIDGE_THING_TYPE_UID, "testBridge"), null, "Bridge", configuration);
|
||||||
|
|
||||||
assertNotNull(bridge);
|
bridge = requireNonNull(bridge, "Bridge is null");
|
||||||
thingRegistry.add(bridge);
|
thingRegistry.add(bridge);
|
||||||
return bridge;
|
return bridge;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user