Search in sources :

Example 1 with TestSingleKeyShardingAlgorithm

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

Example 2 with TestSingleKeyShardingAlgorithm

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

Example 3 with TestSingleKeyShardingAlgorithm

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

Example 4 with TestSingleKeyShardingAlgorithm

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

the class ShardingStrategyTest method assertDoStaticShardingForEqualSingleKey.

@Test
public void assertDoStaticShardingForEqualSingleKey() {
    ShardingStrategy strategy = new ShardingStrategy("column", new TestSingleKeyShardingAlgorithm());
    assertThat(strategy.doStaticSharding(SQLStatementType.SELECT, targets, createShardingValues(new ShardingValue<>("logicTable", "column", "1"))), is((Collection<String>) Collections.singletonList("1")));
}
Also used : ShardingStrategy(com.dangdang.ddframe.rdb.sharding.router.strategy.ShardingStrategy) Collection(java.util.Collection) TestSingleKeyShardingAlgorithm(com.dangdang.ddframe.rdb.sharding.api.strategy.fixture.TestSingleKeyShardingAlgorithm) Test(org.junit.Test)

Example 5 with TestSingleKeyShardingAlgorithm

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

the class ShardingStrategyTest method assertDoDynamicShardingForBetweenSingleKey.

@Test
public void assertDoDynamicShardingForBetweenSingleKey() {
    ShardingStrategy strategy = new ShardingStrategy("column", new TestSingleKeyShardingAlgorithm());
    assertThat(strategy.doDynamicSharding(createShardingValues(new ShardingValue<>("logicTable", "column", Range.open("1", "3")))), is((Collection<String>) Arrays.asList("1", "2", "3")));
}
Also used : ShardingStrategy(com.dangdang.ddframe.rdb.sharding.router.strategy.ShardingStrategy) Collection(java.util.Collection) TestSingleKeyShardingAlgorithm(com.dangdang.ddframe.rdb.sharding.api.strategy.fixture.TestSingleKeyShardingAlgorithm) Test(org.junit.Test)

Aggregations

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