AlgorithmProvidedPrimaryReplicaReplicationRuleBuilder implements ShardingSphereRuleBuilder<PrimaryReplicaReplicationRule, AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration> { @Override public PrimaryReplicaReplicationRule build(final AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration ruleConfig, final Collection<String> dataSourceNames) { return new PrimaryReplicaReplicationRule(ruleConfig); }  @Override PrimaryReplicaReplicationRule build(final AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration ruleConfig, final Collection<String> dataSourceNames); @Override int getOrder(); @Override Class<AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration> getTypeClass();  }
@SuppressWarnings({"rawtypes", "unchecked"}) @Test public void assertBuild() { AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration algorithmProvidedRuleConfig = mock(AlgorithmProvidedPrimaryReplicaReplicationRuleConfiguration.class); PrimaryReplicaReplicationDataSourceRuleConfiguration ruleConfig = new PrimaryReplicaReplicationDataSourceRuleConfiguration( "name", "primaryDataSourceName", Collections.singletonList("name"), "loadBalancerName"); when(algorithmProvidedRuleConfig.getDataSources()).thenReturn(Collections.singletonList(ruleConfig)); ShardingSphereRuleBuilder builder = OrderedSPIRegistry.getRegisteredServices( Collections.singletonList(algorithmProvidedRuleConfig), ShardingSphereRuleBuilder.class).get(algorithmProvidedRuleConfig); assertThat(builder.build(algorithmProvidedRuleConfig, Collections.emptyList()), instanceOf(PrimaryReplicaReplicationRule.class)); }