AddNamedOperation implements Operation, Operations<Operation> { @Override @JsonIgnore public Collection<Operation> getOperations() { return getOperationsWithDefaultParams(); }  boolean isOverwriteFlag(); void setOverwriteFlag(final boolean overwriteFlag); @JsonIgnore void setOperationChain(final String operationChain); @JsonSetter("operationChain") void setOperationChain(final JsonNode opChainNode); @JsonIgnore String getOperationChainAsString(); @JsonGetter("operationChain") JsonNode getOperationChainAsJsonNode(); @JsonIgnore void setOperationChain(final OperationChain operationChain); String getOperationName(); void setOperationName(final String operationName); List<String> getLabels(); void setLabels(final List<String> labels); List<String> getReadAccessRoles(); void setReadAccessRoles(final List<String> readAccessRoles); List<String> getWriteAccessRoles(); void setWriteAccessRoles(final List<String> writeAccessRoles); String getDescription(); void setDescription(final String description); void setParameters(final Map<String, ParameterDetail> parameters); Map<String, ParameterDetail> getParameters(); @Override AddNamedOperation shallowClone(); @Override Map<String, String> getOptions(); @Override void setOptions(final Map<String, String> options); Integer getScore(); void setScore(final Integer score); AccessPredicate getWriteAccessPredicate(); void setWriteAccessPredicate(final AccessPredicate writeAccessPredicate); AccessPredicate getReadAccessPredicate(); void setReadAccessPredicate(final AccessPredicate readAccessPredicate); @Override @JsonIgnore Collection<Operation> getOperations(); @Override void updateOperations(final Collection<Operation> operations);  }
@Test public void shouldGetOperationsWithDefaultParameters() { final AddNamedOperation addNamedOperation = new AddNamedOperation.Builder() .operationChain("{\"operations\":[{\"class\": \"uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds\", \"input\": [{\"vertex\": \"${testParameter}\", \"class\": \"uk.gov.gchq.gaffer.operation.data.EntitySeed\"}]}]}") .description("Test Named Operation") .name("Test") .labels(asList("Test label")) .overwrite(false) .readAccessRoles(USER) .writeAccessRoles(USER) .parameter("testParameter", new ParameterDetail.Builder() .description("the seed") .defaultValue("seed1") .valueClass(String.class) .required(false) .build()) .score(2) .build(); Collection<Operation> operations = addNamedOperation.getOperations(); assertEquals( Collections.singletonList(GetAdjacentIds.class), operations.stream().map(o -> o.getClass()).collect(Collectors.toList()) ); final GetAdjacentIds nestedOp = (GetAdjacentIds) operations.iterator().next(); final List<? extends EntityId> input = Lists.newArrayList(nestedOp.getInput()); assertEquals(Collections.singletonList(new EntitySeed("seed1")), input); }
@Test public void shouldGetOperationsWhenNoDefaultParameter() { final AddNamedOperation addNamedOperation = new AddNamedOperation.Builder() .operationChain("{\"operations\":[{\"class\": \"uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds\", \"input\": [{\"vertex\": \"${testParameter}\", \"class\": \"uk.gov.gchq.gaffer.operation.data.EntitySeed\"}]}]}") .description("Test Named Operation") .name("Test") .labels(asList("Test label")) .overwrite(false) .readAccessRoles(USER) .writeAccessRoles(USER) .parameter("testParameter", new ParameterDetail.Builder() .description("the seed") .valueClass(String.class) .required(false) .build()) .score(2) .build(); Collection<Operation> operations = addNamedOperation.getOperations(); assertEquals( Collections.singletonList(GetAdjacentIds.class), operations.stream().map(o -> o.getClass()).collect(Collectors.toList()) ); final GetAdjacentIds nestedOp = (GetAdjacentIds) operations.iterator().next(); final List<? extends EntityId> input = Lists.newArrayList(nestedOp.getInput()); assertEquals(Collections.singletonList(new EntitySeed(null)), input); }