Search in sources :

Example 1 with InputOutput

use of uk.gov.gchq.gaffer.operation.io.InputOutput in project Gaffer by gchq.

the class ForEachHandlerTest method shouldExecuteAndReturnExpected.

@Test
public void shouldExecuteAndReturnExpected() throws OperationException {
    // Given
    final Store store = mock(Store.class);
    final Context context = new Context(new User());
    final InputOutput op = mock(InputOutput.class);
    final InputOutput opClone = mock(InputOutput.class);
    given(op.shallowClone()).willReturn(opClone);
    final Object input = mock(Object.class);
    final Object output = mock(Object.class);
    final ForEach forEach = new ForEach.Builder<>().input(input).operation(op).build();
    final ForEachHandler handler = new ForEachHandler();
    given(store.execute(opClone, context)).willReturn(output);
    // When
    final List<Object> result = (List<Object>) handler.doOperation(forEach, context, store);
    // Then
    verify(opClone).setInput(input);
    assertThat(result).hasSize(1);
    assertSame(output, result.get(0));
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) User(uk.gov.gchq.gaffer.user.User) InputOutput(uk.gov.gchq.gaffer.operation.io.InputOutput) Store(uk.gov.gchq.gaffer.store.Store) List(java.util.List) ForEach(uk.gov.gchq.gaffer.operation.impl.ForEach) Test(org.junit.jupiter.api.Test)

Aggregations

List (java.util.List)1 Test (org.junit.jupiter.api.Test)1 ForEach (uk.gov.gchq.gaffer.operation.impl.ForEach)1 InputOutput (uk.gov.gchq.gaffer.operation.io.InputOutput)1 Context (uk.gov.gchq.gaffer.store.Context)1 Store (uk.gov.gchq.gaffer.store.Store)1 User (uk.gov.gchq.gaffer.user.User)1