### Question:
ClusterStateCollector { public ClusterState collectClusterState( long epoch, ImmutableList<String> unresponsiveNodes, SequencerMetrics sequencerMetrics) { Map<String, NodeState> nodeStates = new HashMap<>(); nodeStates.put(localEndpoint, collectLocalNodeState(epoch, sequencerMetrics)); nodeStates.putAll(collectRemoteStates()); return ClusterState.builder() .localEndpoint(localEndpoint) .nodes(ImmutableMap.copyOf(nodeStates)) .unresponsiveNodes(unresponsiveNodes) .build(); }  ClusterState collectClusterState(
            long epoch, ImmutableList<String> unresponsiveNodes,
            SequencerMetrics sequencerMetrics); ImmutableMap<String, Long> collectWrongEpochs();  }### Answer:
@Test public void testAggregatedState() { final String localEndpoint = "a"; ClusterState predefinedCluster = ClusterState.buildClusterState( localEndpoint, ImmutableList.of(), nodeState("a", epoch, OK, OK, FAILED), nodeState("b", epoch, OK, OK, FAILED), NodeState.getUnavailableNodeState("c") ); Map<String, CompletableFuture<NodeState>> clusterConnectivity = new HashMap<>(); CompletableFuture<NodeState> nodeAStateCf = CompletableFuture.completedFuture( predefinedCluster.getNode("a").get() ); CompletableFuture<NodeState> nodeBStateCf = CompletableFuture.completedFuture( predefinedCluster.getNode("b").get() ); final int newEpoch = 10; CompletableFuture<NodeState> wrongEpochCf = new CompletableFuture<>(); wrongEpochCf.completeExceptionally(new WrongEpochException(newEpoch)); clusterConnectivity.put("a", nodeAStateCf); clusterConnectivity.put("b", nodeBStateCf); clusterConnectivity.put("c", wrongEpochCf); ClusterStateCollector collector = ClusterStateCollector.builder() .localEndpoint(localEndpoint) .clusterState(clusterConnectivity) .build(); ClusterState clusterState = collector.collectClusterState( 1, ImmutableList.of(), SequencerMetrics.UNKNOWN ); NodeState localNodeState = clusterState.getNode(localEndpoint).get(); NodeConnectivity localNodeConnectivity = localNodeState.getConnectivity(); assertThat(localNodeState.isConnected()).isTrue(); assertThat(localNodeConnectivity.getConnectedNodes()).containsExactly("a", "b", "c"); assertThat(localNodeConnectivity.getFailedNodes()).isEmpty(); NodeState nodeBState = clusterState.getNode("b").get(); NodeConnectivity nodeBConnectivity = nodeBState.getConnectivity(); assertThat(nodeBConnectivity.getConnectedNodes()).containsExactly("a", "b"); NodeState nodeCState = clusterState.getNode("c").get(); assertThat(nodeCState.isConnected()).isFalse(); }