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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations