Skip to content

Commit

Permalink
[bluetooth] Removed usage of deprecated method in tests (openhab#7405)
Browse files Browse the repository at this point in the history
Signed-off-by: Connor Petty <mistercpp2000+gitsignoff@gmail.com>
  • Loading branch information
cpmeister authored and andrewfg committed Aug 31, 2020
1 parent 39192d4 commit 675bdda
Showing 1 changed file with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,17 @@ public void removeDefaultDeviceTest() {
discoveryService.deviceDiscovered(device);
discoveryService.deviceRemoved(device);

ArgumentCaptor<DiscoveryResult> resultCaptor = ArgumentCaptor.forClass(DiscoveryResult.class);
Mockito.verify(mockDiscoveryListener, Mockito.timeout(TIMEOUT).times(1))
.thingRemoved(ArgumentMatchers.same(discoveryService), ArgumentMatchers
.argThat(arg -> arg.getThingTypeUID().equals(BluetoothBindingConstants.THING_TYPE_BEACON)));
.thingDiscovered(ArgumentMatchers.same(discoveryService), resultCaptor.capture());

DiscoveryResult result = resultCaptor.getValue();

Assert.assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID());

Mockito.verify(mockDiscoveryListener, Mockito.timeout(TIMEOUT).times(1)).thingRemoved(
ArgumentMatchers.same(discoveryService),
ArgumentMatchers.argThat(arg -> arg.equals(result.getThingUID())));
}

@Test
Expand All @@ -314,10 +322,19 @@ public void removeUpdatedDefaultDeviceTest() {
device.setName("somename");
discoveryService.deviceDiscovered(device);

ArgumentCaptor<DiscoveryResult> resultCaptor = ArgumentCaptor.forClass(DiscoveryResult.class);
Mockito.verify(mockDiscoveryListener, Mockito.timeout(TIMEOUT).times(2))
.thingDiscovered(ArgumentMatchers.same(discoveryService), resultCaptor.capture());

DiscoveryResult result = resultCaptor.getValue();

Assert.assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID());

discoveryService.deviceRemoved(device);
Mockito.verify(mockDiscoveryListener, Mockito.timeout(TIMEOUT).times(1))
.thingRemoved(ArgumentMatchers.same(discoveryService), ArgumentMatchers
.argThat(arg -> arg.getThingTypeUID().equals(BluetoothBindingConstants.THING_TYPE_BEACON)));

Mockito.verify(mockDiscoveryListener, Mockito.timeout(TIMEOUT).times(1)).thingRemoved(
ArgumentMatchers.same(discoveryService),
ArgumentMatchers.argThat(arg -> arg.equals(result.getThingUID())));
}

@Test
Expand Down Expand Up @@ -357,18 +374,22 @@ public void replaceOlderDiscoveryTest() {
// lets start with producing a default result
discoveryService.deviceDiscovered(device);

ArgumentCaptor<DiscoveryResult> resultCaptor = ArgumentCaptor.forClass(DiscoveryResult.class);
Mockito.verify(mockDiscoveryListener, Mockito.timeout(TIMEOUT).times(1))
.thingDiscovered(ArgumentMatchers.same(discoveryService), ArgumentMatchers
.argThat(arg -> arg.getThingTypeUID().equals(BluetoothBindingConstants.THING_TYPE_BEACON)));
.thingDiscovered(ArgumentMatchers.same(discoveryService), resultCaptor.capture());

DiscoveryResult result = resultCaptor.getValue();

Assert.assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID());

device.setManufacturerId(10);

// lets start with producing a default result
discoveryService.deviceDiscovered(device);

Mockito.verify(mockDiscoveryListener, Mockito.timeout(TIMEOUT).times(1))
.thingRemoved(ArgumentMatchers.same(discoveryService), ArgumentMatchers
.argThat(arg -> arg.getThingTypeUID().equals(BluetoothBindingConstants.THING_TYPE_BEACON)));
Mockito.verify(mockDiscoveryListener, Mockito.timeout(TIMEOUT).times(1)).thingRemoved(
ArgumentMatchers.same(discoveryService),
ArgumentMatchers.argThat(arg -> arg.equals(result.getThingUID())));

Mockito.verify(mockDiscoveryListener, Mockito.timeout(TIMEOUT).times(1)).thingDiscovered(
ArgumentMatchers.same(discoveryService),
Expand Down

0 comments on commit 675bdda

Please sign in to comment.