LimitTask implements Task { @Override public ExecutionResult execute(ExecutionResult previousTaskResult) throws SQLException { DataContainer newData = new DataContainer( previousTaskResult.getData(), rows -> rows.stream() .skip(offset) .limit(count) .collect(Collectors.toList()) ); return new ExecutionResult(){ { setData(newData); setCount(newData.getRows().size()); } }; } LimitTask(int offset, int count);  LimitTask(int count); @Override ExecutionResult execute(ExecutionResult previousTaskResult); int getOffset(); int getCount(); @Override String toString();  }
@Test public void testOffsetCount() throws Exception { ExecutionResult input = getInput(); LimitTask limitTask = new LimitTask(OFFSET, COUNT); ExecutionResult output = limitTask.execute(input); doChecks(output, 6, 7); }
@Test public void testCountOnly() throws Exception { ExecutionResult input = getInput(); LimitTask limitTask = new LimitTask(COUNT); ExecutionResult output = limitTask.execute(input); doChecks(output, 1, 2); }