@Test public void updateMesh() throws Exception { ZigBeeNode node = Mockito.mock(ZigBeeNode.class); ZigBeeNodeServiceDiscoverer discoverer = new ZigBeeNodeServiceDiscoverer(networkManager, node); discoverer.setUpdateMeshTasks( Arrays.asList(new NodeDiscoveryTask[] { NodeDiscoveryTask.ROUTES, NodeDiscoveryTask.NEIGHBORS })); Mockito.when( networkManager.scheduleTask(ArgumentMatchers.any(Runnable.class), ArgumentMatchers.any(long.class))) .thenReturn(null); TestUtilities.setField(ZigBeeNodeServiceDiscoverer.class, discoverer, "retryPeriod", 1000); NodeDescriptor initialNodeDescriptor = Mockito.mock(NodeDescriptor.class); Mockito.when(initialNodeDescriptor.getLogicalType()).thenReturn(LogicalType.END_DEVICE); Mockito.when(node.getLogicalType()).thenAnswer(x -> { if (node.getNodeDescriptor() == null) { return LogicalType.UNKNOWN; } else { return node.getNodeDescriptor().getLogicalType(); } }); PowerDescriptor initialPowerDescriptor = Mockito.mock(PowerDescriptor.class); Mockito.when(initialPowerDescriptor.getCurrentPowerMode()).thenReturn(CurrentPowerModeType.UNKNOWN); Mockito.when(node.getPowerDescriptor()).thenReturn(initialPowerDescriptor); Mockito.when(node.getNetworkAddress()).thenReturn(1); Mockito.when(node.getIeeeAddress()).thenReturn(new IeeeAddress("1234567890ABCDEF")); ScheduledFuture<?> futureTask = Mockito.mock(ScheduledFuture.class); TestUtilities.setField(ZigBeeNodeServiceDiscoverer.class, discoverer, "futureTask", futureTask); discoverer.updateMesh(); assertEquals(LogicalType.UNKNOWN, discoverer.getNode().getLogicalType()); assertFalse(discoverer.getTasks().contains(NodeDiscoveryTask.ROUTES)); assertFalse(discoverer.getTasks().contains(NodeDiscoveryTask.NEIGHBORS)); Mockito.when(node.getNodeDescriptor()).thenReturn(initialNodeDescriptor); discoverer.updateMesh(); assertEquals(LogicalType.END_DEVICE, discoverer.getNode().getLogicalType()); assertFalse(discoverer.getTasks().contains(NodeDiscoveryTask.ROUTES)); assertFalse(discoverer.getTasks().contains(NodeDiscoveryTask.NEIGHBORS)); Mockito.when(initialNodeDescriptor.getLogicalType()).thenReturn(LogicalType.ROUTER); discoverer.updateMesh(); assertTrue(discoverer.getTasks().contains(NodeDiscoveryTask.ROUTES)); assertTrue(discoverer.getTasks().contains(NodeDiscoveryTask.NEIGHBORS)); discoverer.getTasks().clear(); discoverer.setUpdateMeshTasks(Arrays.asList(new NodeDiscoveryTask[] { NodeDiscoveryTask.NEIGHBORS })); discoverer.updateMesh(); assertFalse(discoverer.getTasks().contains(NodeDiscoveryTask.ROUTES)); assertTrue(discoverer.getTasks().contains(NodeDiscoveryTask.NEIGHBORS)); discoverer.stopDiscovery(); }
public void updateMesh() { if (isPossibleEndDevice()) { logger.debug("{}: Node SVC Discovery: Update mesh not performed for possible end device", node.getIeeeAddress()); } else { logger.debug("{}: Node SVC Discovery: Update mesh", node.getIeeeAddress()); startDiscovery(new HashSet<>(meshUpdateTasks)); } }
ZigBeeNodeServiceDiscoverer { public void updateMesh() { if (isPossibleEndDevice()) { logger.debug("{}: Node SVC Discovery: Update mesh not performed for possible end device", node.getIeeeAddress()); } else { logger.debug("{}: Node SVC Discovery: Update mesh", node.getIeeeAddress()); startDiscovery(new HashSet<>(meshUpdateTasks)); } } }
ZigBeeNodeServiceDiscoverer { public void updateMesh() { if (isPossibleEndDevice()) { logger.debug("{}: Node SVC Discovery: Update mesh not performed for possible end device", node.getIeeeAddress()); } else { logger.debug("{}: Node SVC Discovery: Update mesh", node.getIeeeAddress()); startDiscovery(new HashSet<>(meshUpdateTasks)); } } ZigBeeNodeServiceDiscoverer(ZigBeeNetworkManager networkManager, ZigBeeNode node); }
ZigBeeNodeServiceDiscoverer { public void updateMesh() { if (isPossibleEndDevice()) { logger.debug("{}: Node SVC Discovery: Update mesh not performed for possible end device", node.getIeeeAddress()); } else { logger.debug("{}: Node SVC Discovery: Update mesh", node.getIeeeAddress()); startDiscovery(new HashSet<>(meshUpdateTasks)); } } ZigBeeNodeServiceDiscoverer(ZigBeeNetworkManager networkManager, ZigBeeNode node); void stopDiscovery(); int getMaxBackoff(); void setMaxBackoff(int maxBackoff); boolean isFinished(); boolean isSuccessful(); void startDiscovery(); void updateMesh(); Collection<NodeDiscoveryTask> getTasks(); ZigBeeNode getNode(); Calendar getLastDiscoveryStarted(); Calendar getLastDiscoveryCompleted(); void setUpdateMeshTasks(List<NodeDiscoveryTask> tasks); }
ZigBeeNodeServiceDiscoverer { public void updateMesh() { if (isPossibleEndDevice()) { logger.debug("{}: Node SVC Discovery: Update mesh not performed for possible end device", node.getIeeeAddress()); } else { logger.debug("{}: Node SVC Discovery: Update mesh", node.getIeeeAddress()); startDiscovery(new HashSet<>(meshUpdateTasks)); } } ZigBeeNodeServiceDiscoverer(ZigBeeNetworkManager networkManager, ZigBeeNode node); void stopDiscovery(); int getMaxBackoff(); void setMaxBackoff(int maxBackoff); boolean isFinished(); boolean isSuccessful(); void startDiscovery(); void updateMesh(); Collection<NodeDiscoveryTask> getTasks(); ZigBeeNode getNode(); Calendar getLastDiscoveryStarted(); Calendar getLastDiscoveryCompleted(); void setUpdateMeshTasks(List<NodeDiscoveryTask> tasks);  }