### Question:
ClusterSpec extends AbstractCluster<DataCenterSpec, NodeSpec> { public static Builder builder() { return new Builder(); } ClusterSpec();  ClusterSpec(
      String name,
      Long id,
      String cassandraVersion,
      String dseVersion,
      Map<String, Object> peerInfo,
      int numberOfTokens); int getNumberOfTokens(); DataCenterSpec.Builder addDataCenter(); static Builder builder();  }### Answer:
@Test public void testShouldNotHaveParent() { ClusterSpec cluster = ClusterSpec.builder().build(); assertThat(cluster.getParent()).isEmpty(); }
@Test public void testShouldInheritBuilderProperties() { long id = 12L; String version = "1.2.19"; String name = "node0"; Map<String, Object> peerInfo = new HashMap<>(); peerInfo.put("hello", "world"); ClusterSpec cluster = ClusterSpec.builder() .withId(id) .withCassandraVersion(version) .withName(name) .withPeerInfo(peerInfo) .withPeerInfo("goodbye", "world") .build(); Map<String, Object> expectedPeerInfo = new HashMap<>(peerInfo); expectedPeerInfo.put("goodbye", "world"); assertThat(cluster.getId()).isEqualTo(id); assertThat(cluster.getCassandraVersion()).isEqualTo(version); assertThat(cluster.getName()).isEqualTo(name); assertThat(cluster.getPeerInfo()).isEqualTo(expectedPeerInfo); }
@Test public void testBuilderWithNodes() { ClusterSpec cluster = ClusterSpec.builder().withNodes(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10).build(); Collection<DataCenterSpec> dcs = cluster.getDataCenters(); assertThat(dcs).hasSize(11); Iterator<DataCenterSpec> it = dcs.iterator(); for (int i = 0; i < 11; i++) { DataCenterSpec dc = it.next(); assertThat(dc.getNodes()).hasSize(i); assertThat(dc.getId()).isEqualTo(i); } }
@Test public void testLookupDCAndNode() { ClusterSpec cluster = ClusterSpec.builder().withId(0L).withNodes(5, 5).build(); assertThat(cluster.dc(2)).isNull(); assertThat(cluster.dc(0).getId()).isEqualTo(0); assertThat(cluster.dc(1).getId()).isEqualTo(1); assertThat(cluster.node(0, 1).resolveId()).isEqualTo("0:0:1"); assertThat(cluster.node(0, 4).resolveId()).isEqualTo("0:0:4"); assertThat(cluster.node(1, 4).resolveId()).isEqualTo("0:1:4"); assertThat(cluster.node(1, 5)).isNull(); assertThat(cluster.node(3, 1)).isNull(); assertThat(cluster.dc(0).node(1).resolveId()).isEqualTo("0:0:1"); }