Search in sources :

Example 1 with ToUpperCase

use of uk.gov.gchq.koryphe.impl.function.ToUpperCase in project Gaffer by gchq.

the class IfIT method shouldRunOtherwiseOperationsWhenConditionIsFalse.

@Test
public void shouldRunOtherwiseOperationsWhenConditionIsFalse() 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 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.toLowerCase())).isInstanceOf(List.class);
}
Also used : IsA(uk.gov.gchq.koryphe.impl.predicate.IsA) Conditional(uk.gov.gchq.gaffer.operation.util.Conditional) If(uk.gov.gchq.gaffer.operation.impl.If) ToLowerCase(uk.gov.gchq.koryphe.impl.function.ToLowerCase) ToList(uk.gov.gchq.koryphe.impl.function.ToList) ToUpperCase(uk.gov.gchq.koryphe.impl.function.ToUpperCase) Test(org.junit.Test)

Example 2 with ToUpperCase

use of uk.gov.gchq.koryphe.impl.function.ToUpperCase 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);
}
Also used : IsA(uk.gov.gchq.koryphe.impl.predicate.IsA) Conditional(uk.gov.gchq.gaffer.operation.util.Conditional) If(uk.gov.gchq.gaffer.operation.impl.If) ToLowerCase(uk.gov.gchq.koryphe.impl.function.ToLowerCase) ToList(uk.gov.gchq.koryphe.impl.function.ToList) ToUpperCase(uk.gov.gchq.koryphe.impl.function.ToUpperCase) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 If (uk.gov.gchq.gaffer.operation.impl.If)2 Conditional (uk.gov.gchq.gaffer.operation.util.Conditional)2 ToList (uk.gov.gchq.koryphe.impl.function.ToList)2 ToLowerCase (uk.gov.gchq.koryphe.impl.function.ToLowerCase)2 ToUpperCase (uk.gov.gchq.koryphe.impl.function.ToUpperCase)2 IsA (uk.gov.gchq.koryphe.impl.predicate.IsA)2