use of com.dangdang.ddframe.rdb.sharding.router.strategy.ShardingStrategy in project sharding-jdbc by dangdangdotcom.
the class ShardingStrategyTest method assertDoStaticShardingWithoutShardingColumns.
@Test
public void assertDoStaticShardingWithoutShardingColumns() {
ShardingStrategy strategy = new ShardingStrategy(Collections.singletonList("column"), null);
assertThat(strategy.doStaticSharding(SQLStatementType.SELECT, targets, Collections.<ShardingValue<?>>emptyList()), is(targets));
}
use of com.dangdang.ddframe.rdb.sharding.router.strategy.ShardingStrategy in project sharding-jdbc by dangdangdotcom.
the class ShardingStrategyTest method assertDoStaticShardingForMultipleKeys.
@Test
public void assertDoStaticShardingForMultipleKeys() {
ShardingStrategy strategy = new ShardingStrategy("column", new TestMultipleKeysShardingAlgorithm());
assertThat(strategy.doStaticSharding(SQLStatementType.SELECT, targets, createShardingValues(new ShardingValue<>("logicTable", "column", "1"))), is((Collection<String>) Arrays.asList("1", "2", "3")));
}
use of com.dangdang.ddframe.rdb.sharding.router.strategy.ShardingStrategy in project sharding-jdbc by dangdangdotcom.
the class ShardingStrategyTest method assertDoDynamicShardingForInSingleKey.
@Test
public void assertDoDynamicShardingForInSingleKey() {
ShardingStrategy strategy = new ShardingStrategy("column", new TestSingleKeyShardingAlgorithm());
assertThat(strategy.doDynamicSharding(createShardingValues(new ShardingValue<>("logicTable", "column", Arrays.asList("1", "3")))), is((Collection<String>) Arrays.asList("1", "3")));
}
use of com.dangdang.ddframe.rdb.sharding.router.strategy.ShardingStrategy in project sharding-jdbc by dangdangdotcom.
the class ShardingStrategyTest method assertDoStaticShardingForInSingleKey.
@Test
public void assertDoStaticShardingForInSingleKey() {
ShardingStrategy strategy = new ShardingStrategy("column", new TestSingleKeyShardingAlgorithm());
assertThat(strategy.doStaticSharding(SQLStatementType.SELECT, targets, createShardingValues(new ShardingValue<>("logicTable", "column", Arrays.asList("1", "3")))), is((Collection<String>) Arrays.asList("1", "3")));
}
use of com.dangdang.ddframe.rdb.sharding.router.strategy.ShardingStrategy in project sharding-jdbc by dangdangdotcom.
the class ShardingStrategyTest method assertDoStaticShardingForBetweenSingleKey.
@Test
public void assertDoStaticShardingForBetweenSingleKey() {
ShardingStrategy strategy = new ShardingStrategy("column", new TestSingleKeyShardingAlgorithm());
assertThat(strategy.doStaticSharding(SQLStatementType.SELECT, targets, createShardingValues(new ShardingValue<>("logicTable", "column", Range.open("1", "3")))), is((Collection<String>) Arrays.asList("1", "2", "3")));
}
Aggregations