@Test public void shutdown() throws Exception { ZigBeeNetworkManager networkManager = Mockito.mock(ZigBeeNetworkManager.class); ZigBeeNetworkDatabaseManager databaseManager = new ZigBeeNetworkDatabaseManager(networkManager); databaseManager.setDataStore(Mockito.mock(ZigBeeNetworkDataStore.class)); ScheduledExecutorService executorService = Mockito.mock(ScheduledExecutorService.class); TestUtilities.setField(ZigBeeNetworkDatabaseManager.class, databaseManager, "executorService", executorService); databaseManager.shutdown(); Mockito.verify(executorService, Mockito.timeout(TIMEOUT).times(1)).shutdown(); Mockito.verify(executorService, Mockito.timeout(TIMEOUT).times(1)).shutdownNow(); Mockito.verify(networkManager, Mockito.timeout(TIMEOUT).times(1)).removeNetworkNodeListener(databaseManager); Mockito.when(executorService.isShutdown()).thenReturn(true); ZigBeeNode node = Mockito.mock(ZigBeeNode.class); databaseManager.nodeUpdated(node); Mockito.verify(executorService, Mockito.timeout(TIMEOUT).times(0)).schedule( ArgumentMatchers.any(Runnable.class), ArgumentMatchers.any(Long.class), ArgumentMatchers.any(TimeUnit.class)); }
public void shutdown() { logger.debug("Data store: Shutdown"); networkManager.removeNetworkNodeListener(this); executorService.shutdown(); try { executorService.awaitTermination(SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { logger.debug("Data store: Shutdown did not complete all tasks."); } executorService.shutdownNow(); }
ZigBeeNetworkDatabaseManager implements ZigBeeNetworkNodeListener { public void shutdown() { logger.debug("Data store: Shutdown"); networkManager.removeNetworkNodeListener(this); executorService.shutdown(); try { executorService.awaitTermination(SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { logger.debug("Data store: Shutdown did not complete all tasks."); } executorService.shutdownNow(); } }
ZigBeeNetworkDatabaseManager implements ZigBeeNetworkNodeListener { public void shutdown() { logger.debug("Data store: Shutdown"); networkManager.removeNetworkNodeListener(this); executorService.shutdown(); try { executorService.awaitTermination(SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { logger.debug("Data store: Shutdown did not complete all tasks."); } executorService.shutdownNow(); } ZigBeeNetworkDatabaseManager(ZigBeeNetworkManager networkManager); }
ZigBeeNetworkDatabaseManager implements ZigBeeNetworkNodeListener { public void shutdown() { logger.debug("Data store: Shutdown"); networkManager.removeNetworkNodeListener(this); executorService.shutdown(); try { executorService.awaitTermination(SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { logger.debug("Data store: Shutdown did not complete all tasks."); } executorService.shutdownNow(); } ZigBeeNetworkDatabaseManager(ZigBeeNetworkManager networkManager); void setDataStore(ZigBeeNetworkDataStore dataStore); void setDeferredWriteTime(int deferredWriteTime); void setMaxDeferredWriteTime(int deferredWriteMax); void clear(); void startup(); void shutdown(); @Override void nodeAdded(ZigBeeNode node); @Override void nodeUpdated(ZigBeeNode node); @Override void nodeRemoved(ZigBeeNode node); }
ZigBeeNetworkDatabaseManager implements ZigBeeNetworkNodeListener { public void shutdown() { logger.debug("Data store: Shutdown"); networkManager.removeNetworkNodeListener(this); executorService.shutdown(); try { executorService.awaitTermination(SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { logger.debug("Data store: Shutdown did not complete all tasks."); } executorService.shutdownNow(); } ZigBeeNetworkDatabaseManager(ZigBeeNetworkManager networkManager); void setDataStore(ZigBeeNetworkDataStore dataStore); void setDeferredWriteTime(int deferredWriteTime); void setMaxDeferredWriteTime(int deferredWriteMax); void clear(); void startup(); void shutdown(); @Override void nodeAdded(ZigBeeNode node); @Override void nodeUpdated(ZigBeeNode node); @Override void nodeRemoved(ZigBeeNode node);  }