Source:
<code>public void testDiscoverDevice() throws Exception { String id = "id"; byte[] deviceTimeoutByteArray = new byte[]{0x50}; long deviceTimeout = ByteUtils.byteArrayToLong(deviceTimeoutByteArray) * 100; ATCommandResponsePacket packet = createPacket(1, ATCommandStatus.OK, new XBee16BitAddress("0000"), new XBee64BitAddress("0013A20040A6A0DB"), id, new XBee16BitAddress("FFFE"), (byte)0x00, (byte)0x49); ndAnswers.add(packet); PowerMockito.when(deviceMock.getParameter("NT")).thenReturn(deviceTimeoutByteArray); PowerMockito.when(deviceMock.getXBeeProtocol()).thenReturn(XBeeProtocol.ZIGBEE); long start = System.currentTimeMillis(); RemoteXBeeDevice remote = nd.discoverDevice(id); long end = System.currentTimeMillis(); assertThat("The 'discoverDevice' should not be blocked for " + deviceTimeout + " ms", end - start < deviceTimeout, is(equalTo(true))); assertThat("The discovered device should not be null", remote, is(not(equalTo(null)))); assertThat("The Node ID of the discovered device should be '" + id + "'", remote.getNodeID(), is(equalTo(id))); PowerMockito.verifyPrivate(nd, Mockito.times(1)).invoke(SEND_NODE_DISCOVERY_COMMAND_METHOD, Mockito.anyString()); Mockito.verify(deviceMock, Mockito.times(1)).addPacketListener(packetListener); Mockito.verify(deviceMock, Mockito.times(1)).removePacketListener(packetListener); PowerMockito.verifyPrivate(nd, Mockito.times(1)).invoke(DISCOVER_DEVICES_API_METHOD, null, id); <START> Mockito.verify(networkMock, Mockito.never()).addRemoteDevices(Mockito.anyListOf(RemoteXBeeDevice.class)); <END> }</code><technical_language>Add line: java Mockito.verify(networkMock, Mockito.times(1)).addRemoteDevice(Mockito.any(RemoteXBeeDevice.class));</technical_language>

Target:
public void testDiscoverDevice() throws Exception { String id = "id"; byte[] deviceTimeoutByteArray = new byte[]{0x50}; long deviceTimeout = ByteUtils.byteArrayToLong(deviceTimeoutByteArray) * 100; ATCommandResponsePacket packet = createPacket(1, ATCommandStatus.OK, new XBee16BitAddress("0000"), new XBee64BitAddress("0013A20040A6A0DB"), id, new XBee16BitAddress("FFFE"), (byte)0x00, (byte)0x49); ndAnswers.add(packet); PowerMockito.when(deviceMock.getParameter("NT")).thenReturn(deviceTimeoutByteArray); PowerMockito.when(deviceMock.getXBeeProtocol()).thenReturn(XBeeProtocol.ZIGBEE); long start = System.currentTimeMillis(); RemoteXBeeDevice remote = nd.discoverDevice(id); long end = System.currentTimeMillis(); assertThat("The 'discoverDevice' should not be blocked for " + deviceTimeout + " ms", end - start < deviceTimeout, is(equalTo(true))); assertThat("The discovered device should not be null", remote, is(not(equalTo(null)))); assertThat("The Node ID of the discovered device should be '" + id + "'", remote.getNodeID(), is(equalTo(id))); PowerMockito.verifyPrivate(nd, Mockito.times(1)).invoke(SEND_NODE_DISCOVERY_COMMAND_METHOD, Mockito.anyString()); Mockito.verify(deviceMock, Mockito.times(1)).addPacketListener(packetListener); Mockito.verify(deviceMock, Mockito.times(1)).removePacketListener(packetListener); PowerMockito.verifyPrivate(nd, Mockito.times(1)).invoke(DISCOVER_DEVICES_API_METHOD, null, id); Mockito.verify(networkMock, Mockito.never()).addRemoteDevices(Mockito.anyListOf(RemoteXBeeDevice.class)); Mockito.verify(networkMock, Mockito.times(1)).addRemoteDevice(Mockito.any(RemoteXBeeDevice.class)); }