Skip to content

Commit

Permalink
Add test case for MasterSlaveRule.getDataSourceMapper (apache#6888)
Browse files Browse the repository at this point in the history
  • Loading branch information
gzdzss authored Aug 17, 2020
1 parent 85792d4 commit 1de8843
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
import org.junit.Test;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;

Expand Down Expand Up @@ -87,4 +89,12 @@ public void assertUpdateRuleStatusWithEnable() {
masterSlaveRule.updateRuleStatus(new DataSourceNameDisabledEvent("slave_db_0", false));
assertThat(masterSlaveRule.getSingleDataSourceRule().getSlaveDataSourceNames(), is(Arrays.asList("slave_db_0", "slave_db_1")));
}

@Test
public void assertGetDataSourceMapper() {
MasterSlaveRule masterSlaveRule = createMasterSlaveRule();
Map<String, Collection<String>> actual = masterSlaveRule.getDataSourceMapper();
Map<String, Collection<String>> expected = ImmutableMap.of("test_ms", Arrays.asList("master_db", "slave_db_0", "slave_db_1"));
assertThat(actual, is(expected));
}
}

0 comments on commit 1de8843

Please sign in to comment.