OperationChain implements Output<OUT>,
        Operations<Operation> { @Override @JsonIgnore public List<Operation> getOperations() { return operations; } 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 shouldSerialiseAndDeserialiseOperationChain() throws SerialisationException { final OperationChain opChain = new Builder() .first(new OperationImpl()) .then(new OperationImpl()) .build(); byte[] json = JSONSerialiser.serialise(opChain, true); final OperationChain deserialisedOp = JSONSerialiser.deserialise(json, OperationChain.class); assertNotNull(deserialisedOp); assertEquals(2, deserialisedOp.getOperations().size()); assertEquals(OperationImpl.class, deserialisedOp.getOperations() .get(0) .getClass()); assertEquals(OperationImpl.class, deserialisedOp.getOperations() .get(1) .getClass()); }
@Test public void shouldBuildOperationChainWithSingleOperation() { final GetAdjacentIds getAdjacentIds = mock(GetAdjacentIds.class); final OperationChain opChain = new OperationChain.Builder() .first(getAdjacentIds) .build(); assertEquals(1, opChain.getOperations().size()); assertSame(getAdjacentIds, opChain.getOperations().get(0)); }
@Test public void shouldBuildOperationChain_AdjEntitySeedsThenElements() { final GetAdjacentIds getAdjacentIds = mock(GetAdjacentIds.class); final GetElements getEdges = mock(GetElements.class); final OperationChain opChain = new OperationChain.Builder() .first(getAdjacentIds) .then(getEdges) .build(); assertEquals(2, opChain.getOperations().size()); assertSame(getAdjacentIds, opChain.getOperations().get(0)); assertSame(getEdges, opChain.getOperations().get(1)); }
@Test @Override public void shouldGetOperations() { final List<Operation> ops = Lists.newArrayList( mock(Operation.class), mock(GetAllElements.class), mock(Aggregate.class), mock(Limit.class) ); final OperationChain<Operation> opChain = new OperationChain<>(ops); final Collection<Operation> getOps = opChain.getOperations(); assertEquals(ops, getOps); }