### Question:
ReplicatedTableProviderImpl implements ReplicatedTableProvider { @Override public boolean accept(String keyspace) { if (keyspace.startsWith("system") && !SYSTEM_AUTH_KEYSPACE.equals(keyspace)) { return false; } KeyspaceMetadata keyspaceMetadata = myMetadata.getKeyspace(keyspace); if (keyspaceMetadata != null) { Map<String, String> replication = keyspaceMetadata.getReplication(); String replicationClass = replication.get(STRATEGY_CLASS); switch(replicationClass) { case SIMPLE_STRATEGY: return validateSimpleStrategy(replication); case NETWORK_TOPOLOGY_STRATEGY: return validateNetworkTopologyStrategy(keyspace, replication); default: LOG.warn("Replication strategy of type {} is not supported", replicationClass); break; } } return false; } ReplicatedTableProviderImpl(Host host, Metadata metadata); @Override Set<TableReference> getAll(); @Override boolean accept(String keyspace);  }### Answer:
@Test public void testAcceptSimpleNonReplicatedKeyspaceSingleDC() { mockKeyspace("user_keyspace", simpleStrategy(1), "table1"); assertThat(myReplicatedTableProviderImpl.accept("user_keyspace")).isFalse(); }
@Test public void testAcceptNetworkTopologyNonReplicatedKeyspaceSingleDC() { Map<String, String> replication = networkTopologyStrategy(); replication.put("DC1", "1"); mockKeyspace("user_keyspace", replication, "table1"); assertThat(myReplicatedTableProviderImpl.accept("user_keyspace")).isFalse(); }
@Test public void testAcceptSimpleReplicatedKeyspaceSingleDC() { mockKeyspace("user_keyspace", simpleStrategy(3), "table1"); assertThat(myReplicatedTableProviderImpl.accept("user_keyspace")).isTrue(); }
@Test public void testAcceptNetworkTopologyReplicatedKeyspaceSingleDC() { Map<String, String> replication = networkTopologyStrategy(); replication.put("DC1", "3"); mockKeyspace("user_keyspace", replication, "table1"); assertThat(myReplicatedTableProviderImpl.accept("user_keyspace")).isTrue(); }
@Test public void testAcceptSimpleReplicatedKeyspaceMultipleDC() { mockKeyspace("user_keyspace", simpleStrategy(3), "table1"); assertThat(myReplicatedTableProviderImpl.accept("user_keyspace")).isTrue(); }
@Test public void testAcceptNetworkTopologyReplicatedKeyspaceMultipleDC() { Map<String, String> replication = networkTopologyStrategy(); replication.put("DC1", "1"); replication.put("DC2", "1"); replication.put("DC3", "1"); mockKeyspace("user_keyspace", replication, "table1"); assertThat(myReplicatedTableProviderImpl.accept("user_keyspace")).isTrue(); }
@Test public void testAcceptNonLocallyReplicatedTable() { Map<String, String> replication = networkTopologyStrategy(); replication.put("DC2", "1"); replication.put("DC3", "1"); mockKeyspace("user_keyspace", replication, "table1"); assertThat(myReplicatedTableProviderImpl.accept("user_keyspace")).isFalse(); }
@Test public void testAcceptLocalNodeDCIsUnavailableNetworkTopology() { Host localHost = mockHost(null); Map<String, String> replication = networkTopologyStrategy(); replication.put("DC1", "3"); mockKeyspace("user_keyspace", replication, "table1"); ReplicatedTableProviderImpl replicatedTableProviderImpl = new ReplicatedTableProviderImpl(localHost, myMetadata); assertThat(replicatedTableProviderImpl.accept("user_keyspace")).isFalse(); }
@Test public void testAcceptLocalNodeDCIsUnavailableSimple() { Host localHost = mockHost(null); mockKeyspace("user_keyspace", simpleStrategy(3), "table1"); ReplicatedTableProviderImpl replicatedTableProviderImpl = new ReplicatedTableProviderImpl(localHost, myMetadata); assertThat(replicatedTableProviderImpl.accept("user_keyspace")).isTrue(); }
@Test public void testAcceptUnknownKeyspace() { assertThat(myReplicatedTableProviderImpl.accept("nonexistingkeyspace")).isFalse(); }