use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.
the class GroupByStreamMergedResultTest method assertNextForMix.
@Test
public void assertNextForMix() 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(5)).thenReturn(2);
when(resultSets.get(0).getObject(6)).thenReturn(20);
when(resultSets.get(1).next()).thenReturn(true, true, true, false);
when(resultSets.get(1).getObject(1)).thenReturn(20, 30, 30, 40);
when(resultSets.get(1).getObject(2)).thenReturn(0);
when(resultSets.get(1).getObject(3)).thenReturn(2, 2, 3, 3, 3, 4);
when(resultSets.get(1).getObject(5)).thenReturn(2, 2, 3, 3, 3, 4);
when(resultSets.get(1).getObject(6)).thenReturn(20, 20, 30, 30, 30, 40);
when(resultSets.get(2).next()).thenReturn(true, true, false);
when(resultSets.get(2).getObject(1)).thenReturn(10, 30);
when(resultSets.get(2).getObject(2)).thenReturn(10);
when(resultSets.get(2).getObject(3)).thenReturn(1, 1, 1, 1, 3);
when(resultSets.get(2).getObject(5)).thenReturn(1, 1, 3);
when(resultSets.get(2).getObject(6)).thenReturn(10, 10, 30);
MergedResult actual = mergeEngine.merge();
assertTrue(actual.next());
assertThat((BigDecimal) actual.getValue(1, Object.class), is(new BigDecimal(10)));
assertThat(((BigDecimal) actual.getValue(2, Object.class)).intValue(), is(10));
assertThat((Integer) actual.getValue(3, Object.class), is(1));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(1)));
assertThat((BigDecimal) actual.getValue(6, Object.class), is(new BigDecimal(10)));
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(5, Object.class), is(new BigDecimal(4)));
assertThat((BigDecimal) actual.getValue(6, Object.class), is(new BigDecimal(40)));
assertTrue(actual.next());
assertThat((BigDecimal) actual.getValue(1, Object.class), is(new BigDecimal(60)));
assertThat(((BigDecimal) actual.getValue(2, Object.class)).intValue(), is(10));
assertThat((Integer) actual.getValue(3, Object.class), is(3));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(6)));
assertThat((BigDecimal) actual.getValue(6, Object.class), is(new BigDecimal(60)));
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(4));
assertThat((BigDecimal) actual.getValue(5, Object.class), is(new BigDecimal(4)));
assertThat((BigDecimal) actual.getValue(6, Object.class), is(new BigDecimal(40)));
assertFalse(actual.next());
}
use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.
the class GroupByStreamMergedResultTest method assertNextForResultSetsAllEmpty.
@Test
public void assertNextForResultSetsAllEmpty() throws SQLException {
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
MergedResult actual = mergeEngine.merge();
assertFalse(actual.next());
}
use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.
the class IteratorStreamMergedResultTest method assertNextForFirstResultSetsNotEmptyOnly.
@Test
public void assertNextForFirstResultSetsNotEmptyOnly() throws SQLException {
when(queryResults.get(0).next()).thenReturn(true, false);
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
MergedResult actual = mergeEngine.merge();
assertTrue(actual.next());
assertFalse(actual.next());
}
use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.
the class IteratorStreamMergedResultTest method assertNextForResultSetsAllNotEmpty.
@Test
public void assertNextForResultSetsAllNotEmpty() throws SQLException {
for (QueryResult each : queryResults) {
when(each.next()).thenReturn(true, false);
}
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
MergedResult actual = mergeEngine.merge();
assertTrue(actual.next());
assertTrue(actual.next());
assertTrue(actual.next());
assertFalse(actual.next());
}
use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.
the class IteratorStreamMergedResultTest method assertNextForMix.
@Test
public void assertNextForMix() throws SQLException {
queryResults.add(new TestQueryResult(mock(ResultSet.class)));
queryResults.add(new TestQueryResult(mock(ResultSet.class)));
queryResults.add(new TestQueryResult(mock(ResultSet.class)));
when(queryResults.get(1).next()).thenReturn(true, false);
when(queryResults.get(3).next()).thenReturn(true, false);
when(queryResults.get(5).next()).thenReturn(true, false);
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
MergedResult actual = mergeEngine.merge();
assertTrue(actual.next());
assertTrue(actual.next());
assertTrue(actual.next());
assertFalse(actual.next());
}
Aggregations