use of io.shardingjdbc.core.merger.fixture.TestQueryResult in project sharding-jdbc by shardingjdbc.
the class MemoryQueryResultRowTest method setUp.
@Before
public void setUp() throws SQLException {
ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
when(resultSetMetaData.getColumnCount()).thenReturn(1);
when(resultSet.getObject(1)).thenReturn("value");
memoryResultSetRow = new MemoryQueryResultRow(new TestQueryResult(resultSet));
}
use of io.shardingjdbc.core.merger.fixture.TestQueryResult in project sharding-jdbc by shardingjdbc.
the class StreamMergedResultTest method setUp.
@Before
public void setUp() {
streamMergedResult = new TestStreamMergedResult();
streamMergedResult.setCurrentQueryResult(new TestQueryResult(resultSet));
}
use of io.shardingjdbc.core.merger.fixture.TestQueryResult in project sharding-jdbc by shardingjdbc.
the class GroupByMemoryMergedResultTest method setUp.
@Before
public void setUp() throws SQLException {
resultSets = Lists.newArrayList(mockResultSet(), mockResultSet(), mockResultSet());
queryResults = new ArrayList<>(resultSets.size());
for (ResultSet each : resultSets) {
queryResults.add(new TestQueryResult(each));
}
selectStatement = new SelectStatement();
AggregationSelectItem aggregationSelectItem1 = new AggregationSelectItem(AggregationType.COUNT, "(*)", Optional.<String>absent());
aggregationSelectItem1.setIndex(1);
AggregationSelectItem aggregationSelectItem2 = new AggregationSelectItem(AggregationType.AVG, "(num)", Optional.<String>absent());
aggregationSelectItem2.setIndex(2);
AggregationSelectItem derivedAggregationSelectItem1 = new AggregationSelectItem(AggregationType.COUNT, "(num)", Optional.of("AVG_DERIVED_COUNT_0"));
aggregationSelectItem2.setIndex(4);
aggregationSelectItem2.getDerivedAggregationSelectItems().add(derivedAggregationSelectItem1);
AggregationSelectItem derivedAggregationSelectItem2 = new AggregationSelectItem(AggregationType.SUM, "(num)", Optional.of("AVG_DERIVED_SUM_0"));
aggregationSelectItem2.setIndex(5);
aggregationSelectItem2.getDerivedAggregationSelectItems().add(derivedAggregationSelectItem2);
selectStatement.getItems().add(aggregationSelectItem1);
selectStatement.getItems().add(aggregationSelectItem2);
selectStatement.getGroupByItems().add(new OrderItem(3, OrderDirection.ASC, OrderDirection.ASC));
selectStatement.getOrderByItems().add(new OrderItem(3, OrderDirection.DESC, OrderDirection.ASC));
}
use of io.shardingjdbc.core.merger.fixture.TestQueryResult in project sharding-jdbc by shardingjdbc.
the class GroupByRowComparatorTest method mockQueryResult.
private QueryResult mockQueryResult(final Object... values) throws SQLException {
ResultSet result = mock(ResultSet.class);
ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
when(result.getMetaData()).thenReturn(resultSetMetaData);
when(resultSetMetaData.getColumnCount()).thenReturn(values.length);
int index = 0;
for (Object each : values) {
when(result.getObject(++index)).thenReturn(each);
}
return new TestQueryResult(result);
}
use of io.shardingjdbc.core.merger.fixture.TestQueryResult in project sharding-jdbc by shardingjdbc.
the class GroupByStreamMergedResultTest method setUp.
@Before
public void setUp() throws SQLException {
resultSets = Lists.newArrayList(mockResultSet(), mockResultSet(), mockResultSet());
queryResults = new ArrayList<>(resultSets.size());
for (ResultSet each : resultSets) {
queryResults.add(new TestQueryResult(each));
}
selectStatement = new SelectStatement();
AggregationSelectItem aggregationSelectItem1 = new AggregationSelectItem(AggregationType.COUNT, "(*)", Optional.<String>absent());
aggregationSelectItem1.setIndex(1);
AggregationSelectItem aggregationSelectItem2 = new AggregationSelectItem(AggregationType.AVG, "(num)", Optional.<String>absent());
aggregationSelectItem2.setIndex(2);
AggregationSelectItem derivedAggregationSelectItem1 = new AggregationSelectItem(AggregationType.COUNT, "(num)", Optional.of("AVG_DERIVED_COUNT_0"));
aggregationSelectItem2.setIndex(5);
aggregationSelectItem2.getDerivedAggregationSelectItems().add(derivedAggregationSelectItem1);
AggregationSelectItem derivedAggregationSelectItem2 = new AggregationSelectItem(AggregationType.SUM, "(num)", Optional.of("AVG_DERIVED_SUM_0"));
aggregationSelectItem2.setIndex(6);
aggregationSelectItem2.getDerivedAggregationSelectItems().add(derivedAggregationSelectItem2);
selectStatement.getItems().add(aggregationSelectItem1);
selectStatement.getItems().add(aggregationSelectItem2);
selectStatement.getGroupByItems().add(new OrderItem(3, OrderDirection.ASC, OrderDirection.ASC));
selectStatement.getOrderByItems().add(new OrderItem(3, OrderDirection.ASC, OrderDirection.ASC));
}
Aggregations