Search in sources :

Example 1 with GetElementsOperationImpl

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

the class AbstractGetElementsOperationTest method shouldSerialiseAndDeserialiseOperation.

@Test
@Override
public void shouldSerialiseAndDeserialiseOperation() throws SerialisationException {
    // Given
    final String identifier = "identifier";
    final ElementSeed input = new EntitySeed(identifier);
    final GetElementsOperationImpl<ElementSeed, Element> op = new GetElementsOperationImpl<>(Collections.singletonList(input));
    // When
    byte[] json = serialiser.serialise(op, true);
    final GetElementsOperationImpl<ElementSeed, Element> deserialisedOp = serialiser.deserialise(json, GetElementsOperationImpl.class);
    // Then
    assertNotNull(deserialisedOp);
    assertEquals(identifier, ((EntitySeed) deserialisedOp.getInput().iterator().next()).getVertex());
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) GetElementsOperationImpl(uk.gov.gchq.gaffer.operation.impl.GetElementsOperationImpl) Test(org.junit.Test)

Example 2 with GetElementsOperationImpl

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

the class AbstractGetElementsOperationTest method shouldCopyFieldsFromGivenOperationWhenConstructing.

@Test
public void shouldCopyFieldsFromGivenOperationWhenConstructing() {
    // Given
    final GetIterableElementsOperation<ElementSeed, ?> operationToCopy = mock(GetIterableElementsOperation.class);
    final View view = mock(View.class);
    final GetOperation.IncludeEdgeType includeEdges = GetOperation.IncludeEdgeType.ALL;
    final boolean includeEntities = true;
    final boolean populateProperties = true;
    final CloseableIterable<ElementSeed> input = mock(CloseableIterable.class);
    given(operationToCopy.getView()).willReturn(view);
    given(operationToCopy.getIncludeEdges()).willReturn(includeEdges);
    given(operationToCopy.isIncludeEntities()).willReturn(includeEntities);
    given(operationToCopy.isPopulateProperties()).willReturn(populateProperties);
    given(operationToCopy.getInput()).willReturn(input);
    // When
    final GetElementsOperationImpl<ElementSeed, Element> operation = new GetElementsOperationImpl<>(operationToCopy);
    // Then
    assertSame(view, operation.getView());
    assertSame(includeEdges, operation.getIncludeEdges());
    assertEquals(includeEntities, operation.isIncludeEntities());
    assertSame(input, operation.getInput());
    assertEquals(populateProperties, operation.isPopulateProperties());
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) GetElementsOperationImpl(uk.gov.gchq.gaffer.operation.impl.GetElementsOperationImpl) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Element (uk.gov.gchq.gaffer.data.element.Element)2 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)2 GetElementsOperationImpl (uk.gov.gchq.gaffer.operation.impl.GetElementsOperationImpl)2 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)1 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)1