use of uk.gov.gchq.gaffer.operation.impl.output.ToArray in project Gaffer by gchq.
the class ToArrayHandlerTest method shouldConvertIterableOfElementIdsToArray.
@Test
public void shouldConvertIterableOfElementIdsToArray() throws OperationException {
// Given
final ElementId[] originalArray = new ElementId[] { new EntitySeed("vertex"), new EdgeSeed("src", "dest", true) };
final Iterable<ElementId> originalResults = new WrappedCloseableIterable<>(Arrays.asList(originalArray));
final ToArrayHandler<ElementId> handler = new ToArrayHandler<>();
final ToArray operation = mock(ToArray.class);
given(operation.getInput()).willReturn(originalResults);
// When
final ElementId[] results = handler.doOperation(operation, new Context(), null);
// Then
assertArrayEquals(originalArray, results);
}
use of uk.gov.gchq.gaffer.operation.impl.output.ToArray in project Gaffer by gchq.
the class ToArrayHandlerTest method shouldConvertIterableOfElementsAndElementIdsToArray.
@Test
public void shouldConvertIterableOfElementsAndElementIdsToArray() throws OperationException {
// Given
final ElementId[] originalArray = new ElementId[] { new Entity.Builder().group("entity").build(), new Edge.Builder().group("edge").build(), new EntitySeed("vertex"), new EdgeSeed("src", "dest", true) };
final Iterable<ElementId> originalResults = new WrappedCloseableIterable<>(Arrays.asList(originalArray));
final ToArrayHandler<ElementId> handler = new ToArrayHandler<>();
final ToArray operation = mock(ToArray.class);
given(operation.getInput()).willReturn(originalResults);
// When
final ElementId[] results = handler.doOperation(operation, new Context(), null);
// Then
assertArrayEquals(originalArray, results);
}
use of uk.gov.gchq.gaffer.operation.impl.output.ToArray in project Gaffer by gchq.
the class ToArrayHandlerTest method shouldHandleZeroLengthInput.
@Test
public void shouldHandleZeroLengthInput() throws OperationException {
// Given
final Integer[] originalArray = new Integer[] {};
final Iterable<Integer> originalResults = new WrappedCloseableIterable<>(Arrays.asList(originalArray));
final ToArrayHandler<Integer> handler = new ToArrayHandler<>();
final ToArray operation = mock(ToArray.class);
given(operation.getInput()).willReturn(originalResults);
// When
final Integer[] results = handler.doOperation(operation, new Context(), null);
// Then
assertThat(results).isNull();
}
use of uk.gov.gchq.gaffer.operation.impl.output.ToArray in project Gaffer by gchq.
the class ToArrayHandlerTest method shouldHandleNullInput.
@Test
public void shouldHandleNullInput() throws OperationException {
// Given
final ToArrayHandler<Integer> handler = new ToArrayHandler<>();
final ToArray operation = mock(ToArray.class);
given(operation.getInput()).willReturn(null);
// When
final Integer[] results = handler.doOperation(operation, new Context(), null);
// Then
assertThat(results).isNull();
}
use of uk.gov.gchq.gaffer.operation.impl.output.ToArray in project Gaffer by gchq.
the class ToArrayHandlerTest method shouldConvertIterableOfObjectsToArray.
@Test
public void shouldConvertIterableOfObjectsToArray() throws OperationException {
// Given
final Object[] originalArray = new Object[] { new Entity("entity"), new Edge.Builder().group("edge"), new EntitySeed("vertex"), new EdgeSeed("src", "dest", true), 1, 2, 1.5 };
final Iterable<Object> originalResults = new WrappedCloseableIterable<>(Arrays.asList(originalArray));
final ToArrayHandler<Object> handler = new ToArrayHandler<>();
final ToArray operation = mock(ToArray.class);
given(operation.getInput()).willReturn(originalResults);
// When
final Object[] results = handler.doOperation(operation, new Context(), null);
// Then
assertArrayEquals(originalArray, results);
}
Aggregations