use of uk.gov.gchq.gaffer.operation.impl.output.ToVertices in project Gaffer by gchq.
the class ToVerticesHandlerTest method shouldConvertEdgeSeedsToVertices_sourceAndDestination.
@Test
public void shouldConvertEdgeSeedsToVertices_sourceAndDestination() throws OperationException {
// Given
final List elementIds = Arrays.asList(new EdgeSeed(vertex1, vertex2, false), new EdgeSeed(vertex1, vertex3, false));
final ToVerticesHandler handler = new ToVerticesHandler();
final ToVertices operation = mock(ToVertices.class);
given(operation.getInput()).willReturn(elementIds);
given(operation.getEdgeVertices()).willReturn(EdgeVertices.BOTH);
// When
final Iterable<Object> results = handler.doOperation(operation, new Context(), null);
// Then
assertThat(Sets.newHashSet(results)).containsOnly(vertex1, vertex2, vertex3);
}
use of uk.gov.gchq.gaffer.operation.impl.output.ToVertices in project Gaffer by gchq.
the class ToVerticesHandlerTest method shouldBeAbleToIterableOverTheResultsMultipleTimes.
@Test
public void shouldBeAbleToIterableOverTheResultsMultipleTimes() 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
final Set<Object> set1 = Sets.newHashSet(results);
final Set<Object> set2 = Sets.newHashSet(results);
assertEquals(Sets.newHashSet(vertex1, vertex2), set1);
assertEquals(set1, set2);
}
use of uk.gov.gchq.gaffer.operation.impl.output.ToVertices in project Gaffer by gchq.
the class ToVerticesHandlerTest method shouldConvertEdgeSeedsToVertices_matchedVertexOpposite.
@Test
public void shouldConvertEdgeSeedsToVertices_matchedVertexOpposite() 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.OPPOSITE);
given(operation.getEdgeVertices()).willReturn(EdgeVertices.SOURCE);
// When
final Iterable<Object> results = handler.doOperation(operation, new Context(), null);
// Then
assertThat(Sets.newHashSet(results)).containsOnly(vertex2, vertex3, vertex5, vertex7);
}
use of uk.gov.gchq.gaffer.operation.impl.output.ToVertices in project Gaffer by gchq.
the class ToVerticesHandlerTest method shouldHandleNullInput.
@Test
public void shouldHandleNullInput() throws OperationException {
// Given
final ToVerticesHandler handler = new ToVerticesHandler();
final ToVertices operation = mock(ToVertices.class);
given(operation.getInput()).willReturn(null);
given(operation.getEdgeVertices()).willReturn(EdgeVertices.NONE);
// When
final Iterable<Object> results = handler.doOperation(operation, new Context(), null);
// Then
assertThat(results).isNull();
}
use of uk.gov.gchq.gaffer.operation.impl.output.ToVertices in project Gaffer by gchq.
the class ToVerticesHandlerTest method shouldCorrectlyConvertEdgeSeedsWithNoneUseMatchedVertex.
@Test
public void shouldCorrectlyConvertEdgeSeedsWithNoneUseMatchedVertex() 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.IGNORE);
// When
final Iterable<Object> results = handler.doOperation(operation, new Context(), null);
// Then
assertThat(Sets.newHashSet(results)).isEmpty();
}
Aggregations