@Test(groups = "unit") public void should_respect_topological_order() { // given TokenAwarePolicy policy = new TokenAwarePolicy(childPolicy, TOPOLOGICAL); policy.init(cluster, null); // when Iterator<Host> queryPlan = policy.newQueryPlan("keyspace", statement); // then assertThat(queryPlan).containsExactly(host1, host2, host4, host3); }
@Test(groups = "unit") public void should_respect_child_policy_order() { // given TokenAwarePolicy policy = new TokenAwarePolicy(childPolicy, NEUTRAL); policy.init(cluster, null); // when Iterator<Host> queryPlan = policy.newQueryPlan("keyspace", statement); // then assertThat(queryPlan).containsExactly(host2, host1, host4, host3); }
@Test(groups = "unit") public void should_create_random_order() { // given TokenAwarePolicy policy = new TokenAwarePolicy(childPolicy, RANDOM); policy.init(cluster, null); // when Iterator<Host> queryPlan = policy.newQueryPlan("keyspace", statement); // then assertThat(queryPlan).containsOnlyOnce(host1, host2, host3, host4).endsWith(host4, host3); }
@Test(groups = "unit") public void should_respect_child_policy_order() { // given TokenAwarePolicy policy = new TokenAwarePolicy(childPolicy, NEUTRAL); policy.init(cluster, null); // when Iterator<Host> queryPlan = policy.newQueryPlan("keyspace", statement); // then assertThat(queryPlan).containsExactly(host2, host1, host4, host3); }
@Test(groups = "unit") public void should_respect_topological_order() { // given TokenAwarePolicy policy = new TokenAwarePolicy(childPolicy, TOPOLOGICAL); policy.init(cluster, null); // when Iterator<Host> queryPlan = policy.newQueryPlan("keyspace", statement); // then assertThat(queryPlan).containsExactly(host1, host2, host4, host3); }
@Test(groups = "unit") public void should_create_random_order() { // given TokenAwarePolicy policy = new TokenAwarePolicy(childPolicy, RANDOM); policy.init(cluster, null); // when Iterator<Host> queryPlan = policy.newQueryPlan("keyspace", statement); // then assertThat(queryPlan).containsOnlyOnce(host1, host2, host3, host4).endsWith(host4, host3); }