use of io.shardingjdbc.core.merger.fixture.TestQueryResult in project sharding-jdbc by shardingjdbc.
the class GroupByValueTest method assertGroupByValueEquals.
@Test
public void assertGroupByValueEquals() throws SQLException {
GroupByValue groupByValue1 = new GroupByValue(new TestQueryResult(resultSet), Arrays.asList(new OrderItem(1, OrderDirection.ASC, OrderDirection.ASC), new OrderItem(3, OrderDirection.DESC, OrderDirection.ASC)));
GroupByValue groupByValue2 = new GroupByValue(new TestQueryResult(resultSet), Arrays.asList(new OrderItem(1, OrderDirection.ASC, OrderDirection.ASC), new OrderItem(3, OrderDirection.DESC, OrderDirection.ASC)));
assertTrue(groupByValue1.equals(groupByValue2));
assertTrue(groupByValue2.equals(groupByValue1));
assertTrue(groupByValue1.hashCode() == groupByValue2.hashCode());
}
use of io.shardingjdbc.core.merger.fixture.TestQueryResult in project sharding-jdbc by shardingjdbc.
the class OrderByValueTest method assertCompareToForDesc.
@Test
public void assertCompareToForDesc() throws SQLException {
OrderByValue orderByValue1 = new OrderByValue(new TestQueryResult(resultSet1), Arrays.asList(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC), new OrderItem(2, OrderDirection.DESC, OrderDirection.ASC)));
assertTrue(orderByValue1.next());
when(resultSet2.getObject(1)).thenReturn("3");
when(resultSet2.getObject(2)).thenReturn("4");
OrderByValue orderByValue2 = new OrderByValue(new TestQueryResult(resultSet2), Arrays.asList(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC), new OrderItem(2, OrderDirection.DESC, OrderDirection.ASC)));
assertTrue(orderByValue2.next());
assertTrue(orderByValue1.compareTo(orderByValue2) > 0);
assertFalse(orderByValue1.getQueryResult().next());
assertFalse(orderByValue2.getQueryResult().next());
}
use of io.shardingjdbc.core.merger.fixture.TestQueryResult in project sharding-jdbc by shardingjdbc.
the class MergeEngineFactoryTest method setUp.
@Before
public void setUp() throws SQLException {
ResultSet resultSet = mock(ResultSet.class);
ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
when(resultSetMetaData.getColumnCount()).thenReturn(1);
when(resultSetMetaData.getColumnLabel(1)).thenReturn("label");
List<ResultSet> resultSets = Lists.newArrayList(resultSet);
queryResults = new ArrayList<>(resultSets.size());
queryResults.add(new TestQueryResult(resultSets.get(0)));
}
use of io.shardingjdbc.core.merger.fixture.TestQueryResult in project sharding-jdbc by shardingjdbc.
the class DALMergeEngineTest method setUp.
@Before
public void setUp() {
ResultSet resultSet = mock(ResultSet.class);
queryResults = Collections.<QueryResult>singletonList(new TestQueryResult(resultSet));
}
use of io.shardingjdbc.core.merger.fixture.TestQueryResult in project sharding-jdbc by shardingjdbc.
the class ShowCreateTableMergedResultTest method setUp.
@Before
public void setUp() throws SQLException {
TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration();
tableRuleConfig.setLogicTable("table");
tableRuleConfig.setActualDataNodes("ds.table_${0..2}");
tableRuleConfig.setTableShardingStrategyConfig(new ComplexShardingStrategyConfiguration("field1, field2, field3", new TestComplexKeysShardingAlgorithm()));
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
shardingRule = new ShardingRule(shardingRuleConfig, Lists.newArrayList("ds"));
resultSet = mock(ResultSet.class);
ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
when(resultSetMetaData.getColumnCount()).thenReturn(2);
List<ResultSet> resultSets = Lists.newArrayList(resultSet);
for (ResultSet each : resultSets) {
when(each.next()).thenReturn(true, false);
}
queryResults = new ArrayList<>(resultSets.size());
for (ResultSet each : resultSets) {
queryResults.add(new TestQueryResult(each));
}
}
Aggregations