FilterProcessor implements GafferScannerProcessor, Predicate<LazyElementCell> { @Override public List<LazyElementCell> process(final List<LazyElementCell> elementCells) { elementCells.removeIf(elementCell -> !elementCell.isDeleted() && !test(elementCell)); return elementCells; }  @Override List<LazyElementCell> process(final List<LazyElementCell> elementCells);  }
@Test public void shouldSkipDeletedAndRemoveInvalidElements() throws OperationException, SerialisationException { final FilterProcessor processor = new FilterProcessor() { @Override public boolean test(final LazyElementCell elementCell) { return elementCell.getElement() instanceof Entity; } }; final List<LazyElementCell> lazyCells = CellUtil.getLazyCells(ELEMENTS, serialisation); final Cell deletedCell = mock(Cell.class); given(deletedCell.getTypeByte()).willReturn(KeyValue.Type.Delete.getCode()); lazyCells.add(new LazyElementCell(deletedCell, serialisation, false)); final List<LazyElementCell> result = processor.process(lazyCells); assertEquals(2, result.size()); assertEquals(ELEMENTS.get(0), result.get(0).getElement()); assertEquals(deletedCell, result.get(1).getCell()); }