Search in sources :

Example 6 with ToVertices

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

the class ToVerticesHandlerTest method shouldConvertElementSeedsToVertices.

@Test
public void shouldConvertElementSeedsToVertices() throws OperationException {
    // Given
    final List elementIds = Arrays.asList(new EntitySeed(vertex1), new EntitySeed(vertex2));
    final ToVerticesHandler handler = new ToVerticesHandler();
    final ToVertices operation = mock(ToVertices.class);
    given(operation.getInput()).willReturn(elementIds);
    given(operation.getEdgeVertices()).willReturn(EdgeVertices.NONE);
    // When
    final Iterable<Object> results = handler.doOperation(operation, new Context(), null);
    // Then
    assertThat(results).containsOnly(vertex1, vertex2);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ToVertices(uk.gov.gchq.gaffer.operation.impl.output.ToVertices) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 7 with ToVertices

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

the class ToVerticesHandlerTest method shouldConvertEdgeSeedsToVertices_matchedVertexEqual.

@Test
public void shouldConvertEdgeSeedsToVertices_matchedVertexEqual() throws OperationException {
    // Given
    final List elementIds = Arrays.asList(new EdgeSeed(vertex1, vertex2, false, EdgeId.MatchedVertex.SOURCE), new EdgeSeed(vertex3, vertex4, false, EdgeId.MatchedVertex.DESTINATION), new EdgeSeed(vertex5, vertex6, false, EdgeId.MatchedVertex.DESTINATION), new EdgeSeed(vertex7, vertex8, false, null));
    final ToVerticesHandler handler = new ToVerticesHandler();
    final ToVertices operation = mock(ToVertices.class);
    given(operation.getInput()).willReturn(elementIds);
    given(operation.getUseMatchedVertex()).willReturn(ToVertices.UseMatchedVertex.EQUAL);
    given(operation.getEdgeVertices()).willReturn(EdgeVertices.DESTINATION);
    // When
    final Iterable<Object> results = handler.doOperation(operation, new Context(), null);
    // Then
    assertThat(Sets.newHashSet(results)).containsOnly(vertex1, vertex4, vertex6, vertex8);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) ToVertices(uk.gov.gchq.gaffer.operation.impl.output.ToVertices) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 8 with ToVertices

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

the class ToVerticesHandlerTest method shouldConvertEdgeSeedsToVertices_destinationOnly.

@Test
public void shouldConvertEdgeSeedsToVertices_destinationOnly() throws OperationException {
    // Given
    final List elementIds = Collections.singletonList(new EdgeSeed(vertex1, vertex2, false));
    final ToVerticesHandler handler = new ToVerticesHandler();
    final ToVertices operation = mock(ToVertices.class);
    given(operation.getInput()).willReturn(elementIds);
    given(operation.getEdgeVertices()).willReturn(EdgeVertices.DESTINATION);
    // When
    final Iterable<Object> results = handler.doOperation(operation, new Context(), null);
    // Then
    assertThat(Sets.newHashSet(results)).containsOnly(vertex2);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) ToVertices(uk.gov.gchq.gaffer.operation.impl.output.ToVertices) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 9 with ToVertices

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

the class ToVerticesHandlerTest method shouldConvertEdgeSeedsToVertices_sourceOnly.

@Test
public void shouldConvertEdgeSeedsToVertices_sourceOnly() throws OperationException {
    // Given
    final List elementIds = Collections.singletonList(new EdgeSeed(vertex1, vertex2, false));
    final ToVerticesHandler handler = new ToVerticesHandler();
    final ToVertices operation = mock(ToVertices.class);
    given(operation.getInput()).willReturn(elementIds);
    given(operation.getEdgeVertices()).willReturn(EdgeVertices.SOURCE);
    // When
    final Iterable<Object> results = handler.doOperation(operation, new Context(), null);
    // Then
    assertThat(Sets.newHashSet(results)).containsOnly(vertex1);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) ToVertices(uk.gov.gchq.gaffer.operation.impl.output.ToVertices) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 10 with ToVertices

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

the class ToVerticesHandlerTest method shouldCorrectlyConvertEdgeSeedsWithOppositeUseMatchedVertex.

@Test
public void shouldCorrectlyConvertEdgeSeedsWithOppositeUseMatchedVertex() throws OperationException {
    // Given
    final List elementIds = Arrays.asList(new EdgeSeed(vertex1, vertex2, false, null), new EdgeSeed(vertex3, vertex4, false, null), new EdgeSeed(vertex5, vertex6, false, null), new EdgeSeed(vertex7, vertex8, false, null));
    final ToVerticesHandler handler = new ToVerticesHandler();
    final ToVertices operation = mock(ToVertices.class);
    given(operation.getInput()).willReturn(elementIds);
    given(operation.getUseMatchedVertex()).willReturn(ToVertices.UseMatchedVertex.OPPOSITE);
    // When
    final Iterable<Object> results = handler.doOperation(operation, new Context(), null);
    // Then
    assertThat(Sets.newHashSet(results)).containsOnly(vertex2, vertex4, vertex6, vertex8);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) ToVertices(uk.gov.gchq.gaffer.operation.impl.output.ToVertices) List(java.util.List) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)14 ToVertices (uk.gov.gchq.gaffer.operation.impl.output.ToVertices)14 Context (uk.gov.gchq.gaffer.store.Context)12 List (java.util.List)11 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)8 ToSet (uk.gov.gchq.gaffer.operation.impl.output.ToSet)3 Set (java.util.Set)2 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)2 Map (uk.gov.gchq.gaffer.operation.impl.Map)2 OperationChainValidator (uk.gov.gchq.gaffer.store.operation.OperationChainValidator)2 OperationChainOptimiser (uk.gov.gchq.gaffer.store.optimiser.OperationChainOptimiser)2 ValidationResult (uk.gov.gchq.koryphe.ValidationResult)2 FirstItem (uk.gov.gchq.koryphe.impl.function.FirstItem)2 IterableFunction (uk.gov.gchq.koryphe.impl.function.IterableFunction)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Edge (uk.gov.gchq.gaffer.data.element.Edge)1 Walk (uk.gov.gchq.gaffer.data.graph.Walk)1 ExtractWalkEdgesFromHop (uk.gov.gchq.gaffer.data.graph.function.walk.ExtractWalkEdgesFromHop)1