use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.
the class IteratorStreamMergedResultTest 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 assertNextForMiddleResultSetsNotEmpty.
@Test
public void assertNextForMiddleResultSetsNotEmpty() throws SQLException {
when(queryResults.get(1).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 OrderByStreamMergedResultTest 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 OrderByStreamMergedResultTest method assertNextForMix.
@Test
public void assertNextForMix() throws SQLException {
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
when(queryResults.get(0).next()).thenReturn(true, false);
when(queryResults.get(0).getValue(1, Object.class)).thenReturn("2");
when(queryResults.get(1).next()).thenReturn(true, true, true, false);
when(queryResults.get(1).getValue(1, Object.class)).thenReturn("2", "2", "3", "3", "4", "4");
when(queryResults.get(2).next()).thenReturn(true, true, false);
when(queryResults.get(2).getValue(1, Object.class)).thenReturn("1", "1", "3", "3");
MergedResult actual = mergeEngine.merge();
assertTrue(actual.next());
assertThat(actual.getValue(1, Object.class).toString(), is("1"));
assertTrue(actual.next());
assertThat(actual.getValue(1, Object.class).toString(), is("2"));
assertTrue(actual.next());
assertThat(actual.getValue(1, Object.class).toString(), is("2"));
assertTrue(actual.next());
assertThat(actual.getValue(1, Object.class).toString(), is("3"));
assertTrue(actual.next());
assertThat(actual.getValue(1, Object.class).toString(), is("3"));
assertTrue(actual.next());
assertThat(actual.getValue(1, Object.class).toString(), is("4"));
assertFalse(actual.next());
}
use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.
the class LimitDecoratorMergedResultTest method assertNextWithoutRowCount.
@Test
public void assertNextWithoutRowCount() throws SQLException {
Limit limit = new Limit(DatabaseType.MySQL);
limit.setOffset(new LimitValue(2, -1, true));
selectStatement.setLimit(limit);
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
MergedResult actual = mergeEngine.merge();
for (int i = 0; i < 6; i++) {
assertTrue(actual.next());
}
assertFalse(actual.next());
}
Aggregations