Fix bluetooth unit tests (#8620)

Fixes: #8538

Signed-off-by: Connor Petty <mistercpp2000+gitsignoff@gmail.com>
This commit is contained in:
Connor Petty 2020-09-30 22:53:48 -07:00 committed by GitHub
parent fbafc365da
commit 515658de7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -267,6 +267,10 @@ public class BluetoothDiscoveryService extends AbstractDiscoveryService implemen
future = future.thenApply(result -> { future = future.thenApply(result -> {
publishDiscoveryResult(adapter, result); publishDiscoveryResult(adapter, result);
return result; return result;
}).whenComplete((r, t) -> {
if (t != null) {
logger.warn("Error occured during discovery of {}", device.getAddress(), t);
}
}); });
// now save this snapshot for later // now save this snapshot for later

View File

@ -35,6 +35,6 @@ public class TestUtils {
} }
public static ThingUID randomThingUID() { public static ThingUID randomThingUID() {
return new ThingUID("mock", RandomStringUtils.randomAlphabetic(6)); return new ThingUID(BluetoothBindingConstants.BINDING_ID, RandomStringUtils.randomAlphabetic(6));
} }
} }

View File

@ -28,7 +28,6 @@ import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
@ -66,7 +65,6 @@ import org.slf4j.LoggerFactory;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.WARN) @MockitoSettings(strictness = Strictness.WARN)
@NonNullByDefault @NonNullByDefault
@Disabled("Needs to be updated for OH3")
public class BluetoothDiscoveryServiceTest { public class BluetoothDiscoveryServiceTest {
private static final int TIMEOUT = 2000; private static final int TIMEOUT = 2000;
@ -541,7 +539,8 @@ public class BluetoothDiscoveryServiceTest {
private ThingTypeUID typeUID; private ThingTypeUID typeUID;
public MockDiscoveryParticipant() { public MockDiscoveryParticipant() {
this.typeUID = new ThingTypeUID("mock", RandomStringUtils.randomAlphabetic(6)); this.typeUID = new ThingTypeUID(BluetoothBindingConstants.BINDING_ID,
RandomStringUtils.randomAlphabetic(6));
} }
@Override @Override
@ -551,8 +550,9 @@ public class BluetoothDiscoveryServiceTest {
@Override @Override
public @Nullable DiscoveryResult createResult(BluetoothDiscoveryDevice device) { public @Nullable DiscoveryResult createResult(BluetoothDiscoveryDevice device) {
String repProp = RandomStringUtils.randomAlphabetic(6);
return DiscoveryResultBuilder.create(getThingUID(device)).withLabel(RandomStringUtils.randomAlphabetic(6)) return DiscoveryResultBuilder.create(getThingUID(device)).withLabel(RandomStringUtils.randomAlphabetic(6))
.withRepresentationProperty(RandomStringUtils.randomAlphabetic(6)) .withProperty(repProp, RandomStringUtils.randomAlphabetic(6)).withRepresentationProperty(repProp)
.withBridge(device.getAdapter().getUID()).build(); .withBridge(device.getAdapter().getUID()).build();
} }