GafferScanner implements InternalScanner { @Override public boolean next(final List<Cell> output) throws IOException { final List<Cell> input = new ArrayList<>(); final boolean shouldContinue = scanner.next(input); _next(input, output); return shouldContinue; } GafferScanner(final InternalScanner scanner,
                         final ElementSerialisation serialisation,
                         final List<GafferScannerProcessor> processors,
                         final boolean includeMatchedVertex); @Override boolean next(final List<Cell> output); @Override boolean next(final List<Cell> output, final ScannerContext scannerContext); @Override void close();  }
@Test public void shouldDelegateToEachProcessor() throws OperationException, IOException { final List<LazyElementCell> lazyCells = CellUtil.getLazyCells(ELEMENTS, serialisation); final List<Cell> cells = new ArrayList<>(); for (final LazyElementCell lazyElementCell : lazyCells) { cells.add(lazyElementCell.getCell()); } final InternalScanner internalScanner = new InternalScanner() { @Override public boolean next(final List<Cell> results) throws IOException { results.addAll(cells); return true; } @Override public boolean next(final List<Cell> result, final ScannerContext scannerContext) throws IOException { throw new UnsupportedOperationException(); } @Override public void close() throws IOException { throw new UnsupportedOperationException(); } }; final GafferScannerProcessor processor1 = mock(GafferScannerProcessor.class); final GafferScannerProcessor processor2 = mock(GafferScannerProcessor.class); final GafferScanner scanner = new GafferScanner(internalScanner, serialisation, Arrays.asList(processor1, processor2), false) { }; final List<LazyElementCell> processedCells1 = mock(List.class); given(processor1.process(Mockito.anyList())).willReturn(processedCells1); given(processor2.process(processedCells1)).willReturn(lazyCells); final List<Cell> outputResult = new ArrayList<>(); final boolean result = scanner.next(outputResult, null); assertTrue(result); final ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class); verify(processor1).process(captor.capture()); assertEquals(lazyCells, captor.getValue()); verify(processor2).process(processedCells1); assertEquals(cells, outputResult); }