AppState implements Serializable { public void addChannel(P2PRequestChannel requestChanel) { logger.traceEntry("params: {}", requestChanel); Util.check(requestChanel != null, "requestChanel!=null"); this.requestChannels.put(requestChanel.getName(), requestChanel); 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(expected = IllegalArgumentException.class) public void testAddChannelWithNullChannelShouldThrowException(){ appState.addChannel((P2PBroadcastChannel) null); }
@Test public void testAddChannel(){ P2PBroadcastChannel test = new P2PBroadcastChannel(P2PBroadcastChannelName.BLOCK, null); Assert.assertNull(appState.getChannel(P2PBroadcastChannelName.BLOCK)); appState.addChannel(test); Assert.assertNotNull(appState.getChannel(P2PBroadcastChannelName.BLOCK)); }