use of io.shardingjdbc.core.hint.ShardingKey in project sharding-jdbc by shardingjdbc.
the class HintManagerTest method assertAddTableShardingValueForIn.
@Test
public void assertAddTableShardingValueForIn() {
try (HintManager hintManager = HintManager.getInstance()) {
hintManager.addTableShardingValue("logicTable", "shardingColumn", ShardingOperator.IN, 1, 3, 5);
ShardingKey shardingKey = new ShardingKey("logicTable", "shardingColumn");
assertTrue(HintManagerHolder.getTableShardingValue(shardingKey).isPresent());
assertThat(hintManager.getTableShardingValue(shardingKey).getColumnName(), is("shardingColumn"));
assertThat(((ListShardingValue) hintManager.getTableShardingValue(shardingKey)).getValues().size(), is(3));
}
}
use of io.shardingjdbc.core.hint.ShardingKey in project sharding-jdbc by shardingjdbc.
the class HintManagerTest method assertAddDatabaseShardingValueForEquals.
@Test
public void assertAddDatabaseShardingValueForEquals() {
try (HintManager hintManager = HintManager.getInstance()) {
hintManager.addDatabaseShardingValue("logicTable", "shardingColumn", 1);
ShardingKey shardingKey = new ShardingKey("logicTable", "shardingColumn");
assertTrue(HintManagerHolder.getDatabaseShardingValue(shardingKey).isPresent());
assertThat(hintManager.getDatabaseShardingValue(shardingKey).getColumnName(), is("shardingColumn"));
assertThat(((ListShardingValue<? extends Comparable>) hintManager.getDatabaseShardingValue(shardingKey)).getValues().iterator().next(), is((Comparable) 1));
}
}
use of io.shardingjdbc.core.hint.ShardingKey in project sharding-jdbc by shardingjdbc.
the class HintManagerTest method assertAddTableShardingValueForBetween.
@Test
public void assertAddTableShardingValueForBetween() {
try (HintManager hintManager = HintManager.getInstance()) {
hintManager.addTableShardingValue("logicTable", "shardingColumn", ShardingOperator.BETWEEN, 1, 10);
ShardingKey shardingKey = new ShardingKey("logicTable", "shardingColumn");
assertTrue(HintManagerHolder.getTableShardingValue(shardingKey).isPresent());
assertThat(hintManager.getTableShardingValue(shardingKey).getColumnName(), is("shardingColumn"));
assertThat(((RangeShardingValue) hintManager.getTableShardingValue(shardingKey)).getValueRange().lowerEndpoint(), is((Comparable) 1));
assertThat(((RangeShardingValue) hintManager.getTableShardingValue(shardingKey)).getValueRange().upperEndpoint(), is((Comparable) 10));
}
}
use of io.shardingjdbc.core.hint.ShardingKey in project sharding-jdbc by shardingjdbc.
the class HintManagerTest method assertAddDatabaseShardingValueForBetween.
@Test
public void assertAddDatabaseShardingValueForBetween() {
try (HintManager hintManager = HintManager.getInstance()) {
hintManager.addDatabaseShardingValue("logicTable", "shardingColumn", ShardingOperator.BETWEEN, 1, 10);
ShardingKey shardingKey = new ShardingKey("logicTable", "shardingColumn");
assertTrue(HintManagerHolder.getDatabaseShardingValue(shardingKey).isPresent());
assertThat(hintManager.getDatabaseShardingValue(shardingKey).getColumnName(), is("shardingColumn"));
assertThat(((RangeShardingValue) hintManager.getDatabaseShardingValue(shardingKey)).getValueRange().lowerEndpoint(), is((Comparable) 1));
assertThat(((RangeShardingValue) hintManager.getDatabaseShardingValue(shardingKey)).getValueRange().upperEndpoint(), is((Comparable) 10));
}
}
use of io.shardingjdbc.core.hint.ShardingKey in project sharding-jdbc by shardingjdbc.
the class HintManagerTest method assertAddDatabaseShardingValueForIn.
@Test
public void assertAddDatabaseShardingValueForIn() {
try (HintManager hintManager = HintManager.getInstance()) {
hintManager.addDatabaseShardingValue("logicTable", "shardingColumn", ShardingOperator.IN, 1, 3, 5);
ShardingKey shardingKey = new ShardingKey("logicTable", "shardingColumn");
assertTrue(HintManagerHolder.getDatabaseShardingValue(shardingKey).isPresent());
assertThat(hintManager.getDatabaseShardingValue(shardingKey).getColumnName(), is("shardingColumn"));
assertThat(((ListShardingValue) hintManager.getDatabaseShardingValue(shardingKey)).getValues().size(), is(3));
}
}
Aggregations