Search in sources :

Example 1 with ComplexShardingStrategy

use of io.shardingjdbc.core.routing.strategy.complex.ComplexShardingStrategy in project sharding-jdbc by shardingjdbc.

the class ShardingStrategyTest method assertDoShardingForMultipleKeys.

@Test
public void assertDoShardingForMultipleKeys() {
    ComplexShardingStrategy strategy = new ComplexShardingStrategy(new ComplexShardingStrategyConfiguration("column", new TestComplexKeysShardingAlgorithm()));
    assertThat(strategy.doSharding(targets, Collections.<ShardingValue>singletonList(new PreciseShardingValue<>("logicTable", "column", "1"))), is((Collection<String>) Sets.newHashSet("1", "2", "3")));
}
Also used : ComplexShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.ComplexShardingStrategyConfiguration) Collection(java.util.Collection) TestComplexKeysShardingAlgorithm(io.shardingjdbc.core.api.algorithm.fixture.TestComplexKeysShardingAlgorithm) PreciseShardingValue(io.shardingjdbc.core.api.algorithm.sharding.PreciseShardingValue) ShardingValue(io.shardingjdbc.core.api.algorithm.sharding.ShardingValue) RangeShardingValue(io.shardingjdbc.core.api.algorithm.sharding.RangeShardingValue) ComplexShardingStrategy(io.shardingjdbc.core.routing.strategy.complex.ComplexShardingStrategy) Test(org.junit.Test)

Aggregations

TestComplexKeysShardingAlgorithm (io.shardingjdbc.core.api.algorithm.fixture.TestComplexKeysShardingAlgorithm)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 ComplexShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.ComplexShardingStrategyConfiguration)1 ComplexShardingStrategy (io.shardingjdbc.core.routing.strategy.complex.ComplexShardingStrategy)1 Collection (java.util.Collection)1 Test (org.junit.Test)1