]> git.basschouten.com Git - openhab-addons.git/commitdiff
Fix bluetooth unit tests (#8620)
authorConnor Petty <mistercpp2000@gmail.com>
Thu, 1 Oct 2020 05:53:48 +0000 (22:53 -0700)
committerGitHub <noreply@github.com>
Thu, 1 Oct 2020 05:53:48 +0000 (07:53 +0200)
Fixes: #8538
Signed-off-by: Connor Petty <mistercpp2000+gitsignoff@gmail.com>
bundles/org.openhab.binding.bluetooth/src/main/java/org/openhab/binding/bluetooth/discovery/internal/BluetoothDiscoveryService.java
bundles/org.openhab.binding.bluetooth/src/test/java/org/openhab/binding/bluetooth/TestUtils.java
bundles/org.openhab.binding.bluetooth/src/test/java/org/openhab/binding/bluetooth/discovery/internal/BluetoothDiscoveryServiceTest.java

index 91acacc91d5ef37f4bc3e9ee7091adf200e2566b..da64eb3c471946ebd6d4f64f980f68e0a5151603 100644 (file)
@@ -267,6 +267,10 @@ public class BluetoothDiscoveryService extends AbstractDiscoveryService implemen
             future = future.thenApply(result -> {
                 publishDiscoveryResult(adapter, 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
index fcb926d9ffba3ecfc49b73ea0fa339ccfeda7277..8308f59bf9de8f42eea619fe0d730b204488c424 100644 (file)
@@ -35,6 +35,6 @@ public class TestUtils {
     }
 
     public static ThingUID randomThingUID() {
-        return new ThingUID("mock", RandomStringUtils.randomAlphabetic(6));
+        return new ThingUID(BluetoothBindingConstants.BINDING_ID, RandomStringUtils.randomAlphabetic(6));
     }
 }
index 07b85168206f72f9c86a0f0b0f7b6cf01b16e468..9d51898a44b692f3525f4a6d7051fbc2f3cbb52c 100644 (file)
@@ -28,7 +28,6 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentCaptor;
@@ -66,7 +65,6 @@ import org.slf4j.LoggerFactory;
 @ExtendWith(MockitoExtension.class)
 @MockitoSettings(strictness = Strictness.WARN)
 @NonNullByDefault
-@Disabled("Needs to be updated for OH3")
 public class BluetoothDiscoveryServiceTest {
 
     private static final int TIMEOUT = 2000;
@@ -541,7 +539,8 @@ public class BluetoothDiscoveryServiceTest {
         private ThingTypeUID typeUID;
 
         public MockDiscoveryParticipant() {
-            this.typeUID = new ThingTypeUID("mock", RandomStringUtils.randomAlphabetic(6));
+            this.typeUID = new ThingTypeUID(BluetoothBindingConstants.BINDING_ID,
+                    RandomStringUtils.randomAlphabetic(6));
         }
 
         @Override
@@ -551,8 +550,9 @@ public class BluetoothDiscoveryServiceTest {
 
         @Override
         public @Nullable DiscoveryResult createResult(BluetoothDiscoveryDevice device) {
+            String repProp = 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();
         }