GenerateElementsHandler implements OutputOperationHandler<GenerateElements<OBJ>, Iterable<? extends Element>> { @Override public Iterable<? extends Element> doOperation(final GenerateElements<OBJ> operation, final Context context, final Store store) throws OperationException { return operation.getElementGenerator().apply(operation.getInput()); }  @Override Iterable<? extends Element> doOperation(final GenerateElements<OBJ> operation,
                                                   final Context context, final Store store);  }
@Test public void shouldReturnElements() throws OperationException { final GenerateElementsHandler<String> handler = new GenerateElementsHandler<>(); final Store store = mock(Store.class); final GenerateElements<String> operation = mock(GenerateElements.class); final CloseableIterable<Element> elements = mock(CloseableIterable.class); final ElementGenerator<String> elementGenerator = mock(ElementGenerator.class); final CloseableIterable objs = mock(CloseableIterable.class); final Context context = new Context(); final CloseableIterator<Element> elementsIter = mock(CloseableIterator.class); given(elements.iterator()).willReturn(elementsIter); given(elementGenerator.apply(objs)).willReturn(elements); given(operation.getInput()).willReturn(objs); given(operation.getElementGenerator()).willReturn(elementGenerator); final Iterable<? extends Element> result = handler.doOperation(operation, context, store); assertSame(elementsIter, result.iterator()); }