ConsensusReplicationRule implements ShardingSphereRule { public Optional<ConsensusReplicationTableRule> findRoutingByTable(final String physicsTable) { return Optional.ofNullable(physicsTableRules.get(physicsTable)); } ConsensusReplicationRule(final ConsensusReplicationRuleConfiguration config); Optional<ConsensusReplicationTableRule> findRoutingByTable(final String physicsTable);  }
@Test public void assertCannotFindRouting() { ConsensusReplicationRule consensusReplicationRule = createConsensusReplicationRule(); Optional<ConsensusReplicationTableRule> routingRuleOptional = consensusReplicationRule.findRoutingByTable("not_exists_table"); assertFalse(routingRuleOptional.isPresent()); }
@Test public void assertRoutingFound() { ConsensusReplicationRule replicaRule = createConsensusReplicationRule(); Optional<ConsensusReplicationTableRule> routingRuleOptional = replicaRule.findRoutingByTable(physicsTable); assertTrue(routingRuleOptional.isPresent()); ConsensusReplicationTableRule routingRule = routingRuleOptional.get(); assertNotNull(routingRule); assertThat(routingRule.getDataSourceName(), is(dataSourceName)); assertThat(routingRule.getPhysicsTable(), is(physicsTable)); assertThat(routingRule.getReplicaGroupId(), is(replicaGroupId)); assertThat(routingRule.getReplicaPeers(), is(replicaPeers)); }