use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.
the class DQLMergeEngineTest method assertBuildOrderByStreamMergedResultWithSQLServerLimit.
@Test
public void assertBuildOrderByStreamMergedResultWithSQLServerLimit() throws SQLException {
selectStatement.setLimit(new Limit(DatabaseType.SQLServer));
selectStatement.getOrderByItems().add(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC));
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
MergedResult actual = mergeEngine.merge();
assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(OrderByStreamMergedResult.class));
}
use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.
the class DQLMergeEngineTest method assertBuildGroupByMemoryMergedResultWithOracleLimit.
@Test
public void assertBuildGroupByMemoryMergedResultWithOracleLimit() throws SQLException {
selectStatement.setLimit(new Limit(DatabaseType.Oracle));
selectStatement.getGroupByItems().add(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC));
selectStatement.getOrderByItems().add(new OrderItem(2, OrderDirection.DESC, OrderDirection.ASC));
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
MergedResult actual = mergeEngine.merge();
assertThat(actual, instanceOf(RowNumberDecoratorMergedResult.class));
assertThat(((RowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByMemoryMergedResult.class));
}
use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.
the class DQLMergeEngineTest method assertBuildGroupByMemoryMergedResultWithMySQLLimit.
@Test
public void assertBuildGroupByMemoryMergedResultWithMySQLLimit() throws SQLException {
selectStatement.setLimit(new Limit(DatabaseType.MySQL));
selectStatement.getGroupByItems().add(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC));
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
MergedResult actual = mergeEngine.merge();
assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByMemoryMergedResult.class));
}
use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.
the class GroupByMemoryMergedResultTest method assertNextForSomeResultSetsEmpty.
@Test
public void assertNextForSomeResultSetsEmpty() throws SQLException {
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
when(resultSets.get(0).next()).thenReturn(true, false);
when(resultSets.get(0).getObject(1)).thenReturn(20);
when(resultSets.get(0).getObject(2)).thenReturn(0);
when(resultSets.get(0).getObject(3)).thenReturn(2);
when(resultSets.get(0).getObject(4)).thenReturn(2);
when(resultSets.get(0).getObject(5)).thenReturn(20);
when(resultSets.get(2).next()).thenReturn(true, true, false);
when(resultSets.get(2).getObject(1)).thenReturn(20, 30);
when(resultSets.get(2).getObject(2)).thenReturn(0);
when(resultSets.get(2).getObject(3)).thenReturn(2, 3);
when(resultSets.get(2).getObject(4)).thenReturn(2, 2, 3);
when(resultSets.get(2).getObject(5)).thenReturn(20, 20, 30);
MergedResult actual = mergeEngine.merge();
assertTrue(actual.next());
assertThat((BigDecimal) actual.getValue(1, Object.class), is(new BigDecimal(30)));
assertThat(((BigDecimal) actual.getValue(2, Object.class)).intValue(), is(10));
assertThat((Integer) actual.getValue(3, Object.class), is(3));
assertThat((BigDecimal) actual.getValue(4, Object.class), is(new BigDecimal(3)));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(30)));
assertTrue(actual.next());
assertThat((BigDecimal) actual.getValue(1, Object.class), is(new BigDecimal(40)));
assertThat(((BigDecimal) actual.getValue(2, Object.class)).intValue(), is(10));
assertThat((Integer) actual.getValue(3, Object.class), is(2));
assertThat((BigDecimal) actual.getValue(4, Object.class), is(new BigDecimal(4)));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(40)));
assertFalse(actual.next());
}
use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.
the class GroupByMemoryMergedResultTest method assertNextForResultSetsAllEmpty.
@Test
public void assertNextForResultSetsAllEmpty() throws SQLException {
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
MergedResult actual = mergeEngine.merge();
assertFalse(actual.next());
}
Aggregations