If extends GenericInput<I> implements InputOutput<I, O>, Operations<Operation> { @Override public String toString() { return new ToStringBuilder(this) .append(getInput()) .append(condition) .append(conditional) .append(then) .append(otherwise) .append(options) .toString(); }  @Override TypeReference<O> getOutputTypeReference(); @Override If<I, O> shallowClone(); @Override Map<String, String> getOptions(); @Override void setOptions(final Map<String, String> options); @Override @JsonIgnore Collection<Operation> getOperations(); @Override void updateOperations(final Collection<Operation> operations); Boolean getCondition(); void setCondition(final Boolean condition); Operation getThen(); void setThen(final Operation then); Operation getOtherwise(); void setOtherwise(final Operation otherwise); Conditional getConditional(); void setConditional(final Conditional conditional); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }
@Test @Override public void shouldJsonSerialiseAndDeserialise() { final If op = new If.Builder<>() .input(Arrays.asList(new EntitySeed("1"), new EntitySeed("2"))) .condition(true) .then(new GetElements()) .otherwise(new GetAllElements()) .build(); final byte[] json = toJson(op); JsonAssert.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.operation.impl.If\",%n" + " \"input\" : [ {%n" + " \"class\" : \"uk.gov.gchq.gaffer.operation.data.EntitySeed\",%n" + " \"class\" : \"uk.gov.gchq.gaffer.operation.data.EntitySeed\",%n" + " \"vertex\" : \"1\"%n" + " }, {%n" + " \"class\" : \"uk.gov.gchq.gaffer.operation.data.EntitySeed\",%n" + " \"class\" : \"uk.gov.gchq.gaffer.operation.data.EntitySeed\",%n" + " \"vertex\" : \"2\"%n" + " } ],%n" + " \"condition\" : true,%n" + " \"then\" : {%n" + " \"class\" : \"uk.gov.gchq.gaffer.operation.impl.get.GetElements\"%n" + " },%n" + " \"otherwise\" : {%n" + " \"class\" : \"uk.gov.gchq.gaffer.operation.impl.get.GetAllElements\"%n" + " }%n" + "}"), StringUtil.toString(json)); final If deserialisedObj = fromJson(json); assertNotNull(deserialisedObj); assertEquals(Arrays.asList(new EntitySeed("1"), new EntitySeed("2")), Lists.newArrayList((Iterable) deserialisedObj.getInput())); }
@Test public void shouldJsonSerialiseAndDeserialiseWithSingleValue() { final If op = new If.Builder<>() .input(new EntitySeed("1")) .condition(true) .then(new GetElements()) .otherwise(new GetAllElements()) .build(); final byte[] json = toJson(op); JsonAssert.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.operation.impl.If\",%n" + " \"input\" : {%n" + " \"class\" : \"uk.gov.gchq.gaffer.operation.data.EntitySeed\",%n" + " \"class\" : \"uk.gov.gchq.gaffer.operation.data.EntitySeed\",%n" + " \"vertex\" : \"1\"%n" + " }, %n" + " \"condition\" : true,%n" + " \"then\" : {%n" + " \"class\" : \"uk.gov.gchq.gaffer.operation.impl.get.GetElements\"%n" + " },%n" + " \"otherwise\" : {%n" + " \"class\" : \"uk.gov.gchq.gaffer.operation.impl.get.GetAllElements\"%n" + " }%n" + "}"), StringUtil.toString(json)); final If deserialisedObj = fromJson(json); assertNotNull(deserialisedObj); assertEquals(new EntitySeed("1"), deserialisedObj.getInput()); }