use of uk.gov.gchq.gaffer.operation.util.Conditional in project Gaffer by gchq.
the class GetWalksIT method shouldNotFilterWalksWhenNoPredicateSupplied.
@Test
public void shouldNotFilterWalksWhenNoPredicateSupplied() throws Exception {
final Conditional conditional = new Conditional();
conditional.setTransform(new OperationChain.Builder().first(new Map.Builder<>().first(new ExtractWalkEntities()).then(new IterableConcat()).build()).then(new ForEach.Builder<>().operation(new Map.Builder<>().first(new ExtractProperty(TestPropertyNames.PROP_1)).build()).build()).build());
final Iterable<Walk> walks = executeGetWalksApplyingConditional(conditional);
assertThat(getPaths(walks)).isEqualTo("AED,ABC");
}
use of uk.gov.gchq.gaffer.operation.util.Conditional in project Gaffer by gchq.
the class IfIT method shouldReturnOriginalInputWhenConditionIsFalseAndNoOtherwise.
@Test
public void shouldReturnOriginalInputWhenConditionIsFalseAndNoOtherwise() throws OperationException {
// Given
final If<Object, Object> ifOperation = new If<>();
ifOperation.setInput(INPUT_CAMEL_CASE);
ifOperation.setConditional(new Conditional(new IsA("java.lang.Integer")));
ifOperation.setThen(new Map<>(Lists.newArrayList(new ToLong(), new ToList())));
// When
final Object output = graph.execute(ifOperation, getUser());
// Then
assertThat(output).isEqualTo(INPUT_CAMEL_CASE).isInstanceOf(String.class);
}
use of uk.gov.gchq.gaffer.operation.util.Conditional in project Gaffer by gchq.
the class IfIT method shouldReturnOriginalInputWhenConditionIsTrueAndNoThen.
@Test
public void shouldReturnOriginalInputWhenConditionIsTrueAndNoThen() throws OperationException {
// Given
final If<Object, Object> ifOperation = new If<>();
ifOperation.setInput(INPUT_CAMEL_CASE);
ifOperation.setConditional(new Conditional(new IsA("java.lang.String")));
ifOperation.setOtherwise(new Map<>(Lists.newArrayList(new ToLong(), new ToList())));
// When
final Object output = graph.execute(ifOperation, getUser());
// Then
assertThat(output).isEqualTo(INPUT_CAMEL_CASE).isInstanceOf(String.class);
}
use of uk.gov.gchq.gaffer.operation.util.Conditional in project Gaffer by gchq.
the class IfIT method shouldRunThenOperationWhenConditionIsTrue.
@Test
public void shouldRunThenOperationWhenConditionIsTrue() throws OperationException {
// Given
final If<Object, Object> ifOperation = new If<>();
ifOperation.setInput(INPUT_CAMEL_CASE);
ifOperation.setConditional(new Conditional(new IsA("java.lang.String")));
ifOperation.setThen(new Map<>(Lists.newArrayList(new ToUpperCase(), new ToList())));
ifOperation.setOtherwise(new Map<>(Lists.newArrayList(new ToLowerCase(), new ToList())));
// When
final Object output = graph.execute(ifOperation, getUser());
// Then
assertThat(output).isEqualTo(Lists.newArrayList(INPUT_CAMEL_CASE.toUpperCase())).isInstanceOf(List.class);
}
use of uk.gov.gchq.gaffer.operation.util.Conditional in project Gaffer by gchq.
the class GetWalksIT method getWalksThatPassPredicateTest.
private Iterable<Walk> getWalksThatPassPredicateTest(final Predicate predicate) throws Exception {
final Conditional conditional = new Conditional();
conditional.setTransform(new OperationChain.Builder().first(new Map.Builder<>().first(new ExtractWalkEntities()).then(new IterableConcat()).build()).then(new ForEach.Builder<>().operation(new Map.Builder<>().first(new ExtractProperty(TestPropertyNames.PROP_1)).build()).build()).build());
conditional.setPredicate(predicate);
return executeGetWalksApplyingConditional(conditional);
}
Aggregations