AppState implements Serializable { public void shutdown() { logger.traceEntry(); this.blockchain.stopPersistenceUnit(); this.accounts.stopPersistenceUnit(); logger.traceExit(); }  P2PRequestChannel getChannel(P2PRequestChannelName channelName); void addChannel(P2PRequestChannel requestChanel); P2PBroadcastChannel getChannel(P2PBroadcastChannelName channelName); void addChannel(P2PBroadcastChannel broadcastChannel); P2PConnection getConnection(); void setConnection(P2PConnection connection); boolean isStillRunning(); void setStillRunning(boolean stillRunning); void setBlockchain(Blockchain blockchain); Blockchain getBlockchain(); Accounts getAccounts(); void setAccounts(Accounts accounts); void shutdown(); void setPrivateKey(PrivateKey privateKey); PrivateKey getPrivateKey(); PublicKey getPublicKey(); NTPClient getNtpClient(); void setNtpClient(NTPClient ntpClient); ConsensusData getConsensusData(); Shard getShard(); void setShard(Shard shard); StatisticsManager getStatisticsManager(); TransactionsPool getPool(); public Object lockerSyncPropose; }
@Test public void testShutdown(){ Blockchain blockchain = mock(Blockchain.class); Accounts accounts = mock(Accounts.class); appState.setBlockchain(blockchain); appState.setAccounts(accounts); verify(blockchain, times(0)).stopPersistenceUnit(); verify(accounts, times(0)).stopPersistenceUnit(); appState.shutdown(); verify(blockchain, times(1)).stopPersistenceUnit(); verify(accounts, times(1)).stopPersistenceUnit(); }