OperationChain implements Output<OUT>,
        Operations<Operation> { @JsonGetter("operations") Operation[] getOperationArray() { return operations.toArray(new Operation[operations.size()]); } OperationChain();  OperationChain(final Operation operation);  OperationChain(final Output<OUT> operation);  OperationChain(final Operation... operations);  OperationChain(final List<Operation> operations);  OperationChain(final List<Operation> operations, final boolean flatten); static OperationChain<?> wrap(final Operation operation); static OperationChain<O> wrap(final Output<O> operation); @JsonIgnore @Override TypeReference<OUT> getOutputTypeReference(); @Override @JsonIgnore List<Operation> getOperations(); OperationChain<OUT> shallowClone(); @Override Map<String, String> getOptions(); @Override void setOptions(final Map<String, String> options); @Override String toString(); String toOverviewString(); @Override void close(); @Override boolean equals(final Object obj); @Override int hashCode();  }
@Test public void shouldBuildOperationChain() { final AddElements addElements1 = mock(AddElements.class); final AddElements addElements2 = mock(AddElements.class); final GetAdjacentIds getAdj1 = mock(GetAdjacentIds.class); final GetAdjacentIds getAdj2 = mock(GetAdjacentIds.class); final GetAdjacentIds getAdj3 = mock(GetAdjacentIds.class); final GetElements getElements1 = mock(GetElements.class); final GetElements getElements2 = mock(GetElements.class); final GetAllElements getAllElements = mock(GetAllElements.class); final DiscardOutput discardOutput = mock(DiscardOutput.class); final GetJobDetails getJobDetails = mock(GetJobDetails.class); final GenerateObjects<EntityId> generateEntitySeeds = mock(GenerateObjects.class); final Limit<Element> limit = mock(Limit.class); final ToSet<Element> deduplicate = mock(ToSet.class); final CountGroups countGroups = mock(CountGroups.class); final ExportToSet<GroupCounts> exportToSet = mock(ExportToSet.class); final ExportToGafferResultCache<CloseableIterable<? extends Element>> exportToGafferCache = mock(ExportToGafferResultCache.class); final If<Iterable<? extends EntityId>, Iterable<? extends EntityId>> ifOp = mock(If.class); final OperationChain<JobDetail> opChain = new Builder() .first(addElements1) .then(getAdj1) .then(getAdj2) .then(getElements1) .then(generateEntitySeeds) .then(getAdj3) .then(ifOp) .then(getElements2) .then(deduplicate) .then(limit) .then(countGroups) .then(exportToSet) .then(discardOutput) .then(getAllElements) .then(exportToGafferCache) .then(addElements2) .then(getJobDetails) .build(); final Operation[] expecteds = { addElements1, getAdj1, getAdj2, getElements1, generateEntitySeeds, getAdj3, ifOp, getElements2, deduplicate, limit, countGroups, exportToSet, discardOutput, getAllElements, exportToGafferCache, addElements2, getJobDetails }; assertArrayEquals(expecteds, opChain.getOperationArray()); }
@Test public void shouldBuildOperationChainWithTypeUnsafe() { final GetAdjacentIds getAdjIds1 = new GetAdjacentIds(); final ExportToSet<CloseableIterable<? extends EntityId>> exportToSet1 = new ExportToSet<>(); final DiscardOutput discardOutput1 = new DiscardOutput(); final GetSetExport getSetExport1 = new GetSetExport(); final GetAdjacentIds getAdjIds2 = new GetAdjacentIds(); final ExportToSet<CloseableIterable<? extends EntityId>> exportToSet2 = new ExportToSet<>(); final DiscardOutput discardOutput2 = new DiscardOutput(); final GetSetExport getSetExport2 = new GetSetExport(); final OperationChain<CloseableIterable<? extends EntityId>> opChain = new Builder() .first(getAdjIds1) .then(exportToSet1) .then(discardOutput1) .then(getSetExport1) .thenTypeUnsafe(getAdjIds2) .then(exportToSet2) .then(discardOutput2) .then(getSetExport2) .buildTypeUnsafe(); final Operation[] expecteds = { getAdjIds1, exportToSet1, discardOutput1, getSetExport1, getAdjIds2, exportToSet2, discardOutput2, getSetExport2 }; assertArrayEquals(expecteds, opChain.getOperationArray()); }