Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.time.Instant;
import java.util.ArrayList;
Expand Down Expand Up @@ -72,7 +73,7 @@ public void testOneThingDiscovery() throws Exception {
getResourceAsByteArray("component/configTS0601AutoLock.json"));

// Then one thing found
assert latch.await(3, TimeUnit.SECONDS);
assertTrue(latch.await(3, TimeUnit.SECONDS));
var discoveryResults = discoveryListener.getDiscoveryResults();
assertThat(discoveryResults.size(), is(1));
var result = discoveryResults.get(0);
Expand All @@ -99,7 +100,7 @@ public void testComponentAddedToExistingThing() throws Exception {
getResourceAsByteArray("component/configTS0601ClimateThermostat.json"));

// Then one thing found
assert latch.await(3, TimeUnit.SECONDS);
assertTrue(latch.await(3, TimeUnit.SECONDS));
var discoveryResults = discoveryListener.getDiscoveryResults();
assertThat(discoveryResults.size(), is(1));
var result = discoveryResults.get(0);
Expand All @@ -119,7 +120,7 @@ public void testComponentAddedToExistingThing() throws Exception {
"homeassistant/switch/0x847127fffe11dd6a_auto_lock_zigbee2mqtt/config",
getResourceAsByteArray("component/configTS0601AutoLock.json"));

assert latch.await(3, TimeUnit.SECONDS);
assertTrue(latch.await(3, TimeUnit.SECONDS));
discoveryResults = discoveryListener.getDiscoveryResults();
assertThat(discoveryResults.size(), is(1));
result = discoveryResults.get(0);
Expand Down Expand Up @@ -149,7 +150,7 @@ public void testComponentRemovedFromExistingThing() throws Exception {
getResourceAsByteArray("component/configTS0601AutoLock.json"));

// Then one thing found
assert latch.await(4, TimeUnit.SECONDS);
assertTrue(latch.await(4, TimeUnit.SECONDS));
var discoveryResults = discoveryListener.getDiscoveryResults();
assertThat(discoveryResults.size(), is(1));
var result = discoveryResults.get(0);
Expand All @@ -168,7 +169,7 @@ public void testComponentRemovedFromExistingThing() throws Exception {
discovery.topicVanished(HA_UID, bridgeConnection,
"homeassistant/switch/0x847127fffe11dd6a_auto_lock_zigbee2mqtt/config");

assert latch.await(3, TimeUnit.SECONDS);
assertTrue(latch.await(3, TimeUnit.SECONDS));
discoveryResults = discoveryListener.getDiscoveryResults();
assertThat(discoveryResults.size(), is(1));
result = discoveryResults.get(0);
Expand Down Expand Up @@ -204,6 +205,9 @@ public void thingDiscovered(DiscoveryService source, DiscoveryResult result) {

@Override
public void thingRemoved(DiscoveryService source, ThingUID thingUID) {
if (latch != null) {
latch.countDown();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void testScan(String filename, int propertiesSize) throws IOException {
setUp(filename);
discoveryService.startScan();
ArgumentCaptor<DiscoveryResult> discoveryResultCaptor = ArgumentCaptor.forClass(DiscoveryResult.class);
verify(discoveryListener).thingDiscovered(any(), discoveryResultCaptor.capture());
verify(discoveryListener, timeout(1000L)).thingDiscovered(any(), discoveryResultCaptor.capture());
DiscoveryResult discoveryResult = discoveryResultCaptor.getValue();
assertEquals(TPLinkSmartHomeBindingConstants.BINDING_ID, discoveryResult.getBindingId(),
"Check if correct binding id found");
Expand Down