Search in sources :

Example 1 with TestMultipleKeysShardingAlgorithm

use of com.dangdang.ddframe.rdb.sharding.api.strategy.fixture.TestMultipleKeysShardingAlgorithm 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")));
}
Also used : ShardingStrategy(com.dangdang.ddframe.rdb.sharding.router.strategy.ShardingStrategy) TestMultipleKeysShardingAlgorithm(com.dangdang.ddframe.rdb.sharding.api.strategy.fixture.TestMultipleKeysShardingAlgorithm) Collection(java.util.Collection) Test(org.junit.Test)

Example 2 with TestMultipleKeysShardingAlgorithm

use of com.dangdang.ddframe.rdb.sharding.api.strategy.fixture.TestMultipleKeysShardingAlgorithm in project sharding-jdbc by dangdangdotcom.

the class ShardingStrategyTest method assertDoDynamicShardingForMultipleKeys.

@Test
public void assertDoDynamicShardingForMultipleKeys() {
    ShardingStrategy strategy = new ShardingStrategy("column", new TestMultipleKeysShardingAlgorithm());
    assertThat(strategy.doDynamicSharding(createShardingValues(new ShardingValue<>("logicTable", "column", "1"))), is((Collection<String>) Collections.<String>emptyList()));
}
Also used : ShardingStrategy(com.dangdang.ddframe.rdb.sharding.router.strategy.ShardingStrategy) TestMultipleKeysShardingAlgorithm(com.dangdang.ddframe.rdb.sharding.api.strategy.fixture.TestMultipleKeysShardingAlgorithm) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

TestMultipleKeysShardingAlgorithm (com.dangdang.ddframe.rdb.sharding.api.strategy.fixture.TestMultipleKeysShardingAlgorithm)2 ShardingStrategy (com.dangdang.ddframe.rdb.sharding.router.strategy.ShardingStrategy)2 Collection (java.util.Collection)2 Test (org.junit.Test)2