AppState implements Serializable { public void setPrivateKey(PrivateKey privateKey) { logger.traceEntry("params: {}", privateKey); Util.check(privateKey != null, "privateKey!=null"); this.privateKey = privateKey; this.publicKey = new PublicKey(privateKey); 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 testSetPrivateKeyWithNullPrivateKeyShouldThrowException(){ appState.setPrivateKey(null); }
@Test public void testSetPrivateKey(){ PrivateKey key = new PrivateKey(); Assert.assertNull(appState.getPublicKey()); appState.setPrivateKey(key); Assert.assertEquals(key, appState.getPrivateKey()); Assert.assertNotNull(appState.getPublicKey()); }