Search in sources :

Example 1 with OperationImpl

use of uk.gov.gchq.gaffer.operation.impl.OperationImpl in project Gaffer by gchq.

the class AbstractOperationTest method shouldSerialiseAndDeserialiseOperation.

@Test
@Override
public void shouldSerialiseAndDeserialiseOperation() throws SerialisationException {
    // Given
    final String input = "some input";
    final OperationImpl<String, String> op = new OperationImpl<>(input);
    // When
    byte[] json = serialiser.serialise(op, true);
    final OperationImpl deserialisedOp = serialiser.deserialise(json, OperationImpl.class);
    // Then
    assertNotNull(deserialisedOp);
    assertEquals(input, deserialisedOp.getInput());
}
Also used : OperationImpl(uk.gov.gchq.gaffer.operation.impl.OperationImpl) Test(org.junit.Test)

Example 2 with OperationImpl

use of uk.gov.gchq.gaffer.operation.impl.OperationImpl in project Gaffer by gchq.

the class AbstractOperationTest method shouldCopyFieldsFromGivenOperationWhenConstructing.

@Test
public void shouldCopyFieldsFromGivenOperationWhenConstructing() {
    // Given
    final Operation<String, ?> operationToCopy = mock(Operation.class);
    final View view = mock(View.class);
    final String input = "input value";
    given(operationToCopy.getView()).willReturn(view);
    given(operationToCopy.getInput()).willReturn(input);
    // When
    final Operation<String, String> operation = new OperationImpl<>(operationToCopy);
    // Then
    assertSame(view, operation.getView());
    assertSame(input, operation.getInput());
}
Also used : OperationImpl(uk.gov.gchq.gaffer.operation.impl.OperationImpl) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test)

Example 3 with OperationImpl

use of uk.gov.gchq.gaffer.operation.impl.OperationImpl in project Gaffer by gchq.

the class OperationChainTest method shouldSerialiseAndDeserialiseOperationChain.

@Test
public void shouldSerialiseAndDeserialiseOperationChain() throws SerialisationException {
    // Given
    final OperationChain<Object> opChain = new Builder().first(new OperationImpl<>()).then(new OperationImpl<>()).build();
    // When
    byte[] json = serialiser.serialise(opChain, true);
    final OperationChain deserialisedOp = serialiser.deserialise(json, OperationChain.class);
    // Then
    assertNotNull(deserialisedOp);
    assertEquals(2, deserialisedOp.getOperations().size());
    assertEquals(OperationImpl.class, deserialisedOp.getOperations().get(0).getClass());
    assertEquals(OperationImpl.class, deserialisedOp.getOperations().get(1).getClass());
}
Also used : OperationImpl(uk.gov.gchq.gaffer.operation.impl.OperationImpl) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 OperationImpl (uk.gov.gchq.gaffer.operation.impl.OperationImpl)3 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)1 Builder (uk.gov.gchq.gaffer.operation.OperationChain.Builder)1