Search in sources :

Example 1 with TestRangeShardingAlgorithm

use of io.shardingjdbc.core.api.algorithm.fixture.TestRangeShardingAlgorithm in project sharding-jdbc by shardingjdbc.

the class ShardingStrategyTest method assertDoShardingForBetweenSingleKey.

@Test
public void assertDoShardingForBetweenSingleKey() {
    StandardShardingStrategy strategy = new StandardShardingStrategy(new StandardShardingStrategyConfiguration("column", new TestPreciseShardingAlgorithm(), new TestRangeShardingAlgorithm()));
    assertThat(strategy.doSharding(targets, Collections.<ShardingValue>singletonList(new RangeShardingValue<>("logicTable", "column", Range.open("1", "3")))), is((Collection<String>) Sets.newHashSet("1", "2", "3")));
}
Also used : StandardShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.StandardShardingStrategyConfiguration) TestPreciseShardingAlgorithm(io.shardingjdbc.core.api.algorithm.fixture.TestPreciseShardingAlgorithm) TestRangeShardingAlgorithm(io.shardingjdbc.core.api.algorithm.fixture.TestRangeShardingAlgorithm) Collection(java.util.Collection) PreciseShardingValue(io.shardingjdbc.core.api.algorithm.sharding.PreciseShardingValue) ShardingValue(io.shardingjdbc.core.api.algorithm.sharding.ShardingValue) RangeShardingValue(io.shardingjdbc.core.api.algorithm.sharding.RangeShardingValue) StandardShardingStrategy(io.shardingjdbc.core.routing.strategy.standard.StandardShardingStrategy) Test(org.junit.Test)

Aggregations

TestPreciseShardingAlgorithm (io.shardingjdbc.core.api.algorithm.fixture.TestPreciseShardingAlgorithm)1 TestRangeShardingAlgorithm (io.shardingjdbc.core.api.algorithm.fixture.TestRangeShardingAlgorithm)1 PreciseShardingValue (io.shardingjdbc.core.api.algorithm.sharding.PreciseShardingValue)1 RangeShardingValue (io.shardingjdbc.core.api.algorithm.sharding.RangeShardingValue)1 ShardingValue (io.shardingjdbc.core.api.algorithm.sharding.ShardingValue)1 StandardShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.StandardShardingStrategyConfiguration)1 StandardShardingStrategy (io.shardingjdbc.core.routing.strategy.standard.StandardShardingStrategy)1 Collection (java.util.Collection)1 Test (org.junit.Test)1