CurrentMeta implements Releasable { @Override public String toString() { JsonCodec codec = new JsonCodec(true, true); return codec.encode(this); }  Set<String> allClusters(); boolean hasCluster(String clusterId); boolean hasShard(String clusterId, String shardId); boolean watchIfNotWatched(String clusterId, String shardId); void setSurviveKeepers(String clusterId, String shardId, List<KeeperMeta> surviveKeepers,
			KeeperMeta activeKeeper); void addResource(String clusterId, String shardId, Releasable releasable); List<KeeperMeta> getSurviveKeepers(String clusterId, String shardId); boolean setKeeperActive(String clusterId, String shardId, KeeperMeta keeperMeta); KeeperMeta getKeeperActive(String clusterId, String shardId); boolean setKeeperMaster(String clusterId, String shardId, Pair<String, Integer> keeperMaster); Pair<String, Integer> getKeeperMaster(String clusterId, String shardId); void setCurrentCRDTMaster(String clusterId, String shardId,  RedisMeta peerMaster); RedisMeta getCurrentCRDTMaster(String clusterId, String shardId); RedisMeta getCurrentMaster(String clusterId, String shardId); void setPeerMaster(String dcId, String clusterId, String shardId, RedisMeta peerMaster); RedisMeta getPeerMaster(String dcId, String clusterId, String shardId); void removePeerMaster(String dcId, String clusterId, String shardId); Set<String> getUpstreamPeerDcs(String clusterId, String shardId); List<RedisMeta> getAllPeerMasters(String clusterId, String shardId); @Override void release(); void addCluster(final ClusterMeta clusterMeta); CurrentClusterMeta removeCluster(String clusterId); void changeCluster(ClusterMetaComparator comparator); @Override String toString(); static CurrentMeta fromJson(String json);  }
@Test public void testToString(){ List<KeeperMeta> allKeepers = getDcKeepers(getDc(), clusterId, shardId); currentMeta.setSurviveKeepers(clusterId, shardId, allKeepers, allKeepers.get(0)); currentMeta.addResource(clusterId, shardId, new Releasable() { @Override public void release() throws Exception { } }); String json = currentMeta.toString(); CurrentMeta de = CurrentMeta.fromJson(json); Assert.assertEquals(json, de.toString()); Assert.assertTrue(currentMeta.hasCluster(clusterId)); for(ShardMeta shardMeta : clusterMeta.getShards().values()){ Assert.assertTrue(currentMeta.hasShard(clusterId, shardMeta.getId())); } }