### Question:
GroupByMemoryResultSetMerger extends AbstractMemoryResultSetMerger { @Override public boolean next() throws SQLException { if (memoryResultSetRows.hasNext()) { setCurrentResultSetRow(memoryResultSetRows.next()); return true; } return false; } GroupByMemoryResultSetMerger(
            final Map<String, Integer> labelAndIndexMap, final List<ResultSet> resultSets, final SelectStatement selectStatement, final OrderType nullOrderType); @Override boolean next();  }### Answer:
@Test public void assertNextForResultSetsAllEmpty() throws SQLException { mergeEngine = new MergeEngine(DatabaseType.MySQL, resultSets, selectStatement); ResultSetMerger actual = mergeEngine.merge(); assertFalse(actual.next()); }
@Test public void assertNextForSomeResultSetsEmpty() throws SQLException { mergeEngine = new MergeEngine(DatabaseType.MySQL, resultSets, 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); ResultSetMerger 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()); }