GenerateObjectsHandler implements OutputOperationHandler<GenerateObjects<OBJ>, Iterable<? extends OBJ>> { @Override public Iterable<? extends OBJ> doOperation(final GenerateObjects<OBJ> operation, final Context context, final Store store) throws OperationException { return operation.getElementGenerator().apply(operation.getInput()); }  @Override Iterable<? extends OBJ> doOperation(final GenerateObjects<OBJ> operation,
                                               final Context context, final Store store);  }
@Test public void shouldReturnObjects() throws OperationException { final GenerateObjectsHandler<String> handler = new GenerateObjectsHandler<>(); final Store store = mock(Store.class); final GenerateObjects<String> operation = mock(GenerateObjects.class); final Iterable elements = mock(Iterable.class); final Function<Iterable<? extends Element>, Iterable<? extends String>> objGenerator = mock(ObjectGenerator.class); final Iterable objs = mock(Iterable.class); final Context context = new Context(); final Iterator objsIter = mock(Iterator.class); given(objs.iterator()).willReturn(objsIter); given(objGenerator.apply(elements)).willReturn(objs); given(operation.getInput()).willReturn(elements); given(operation.getElementGenerator()).willReturn(objGenerator); final Iterable<? extends String> result = handler.doOperation(operation, context, store); assertSame(objsIter, result.iterator()); }