use of uk.gov.gchq.gaffer.operation.impl.output.ToArray in project Gaffer by gchq.
the class ToArrayHandlerTest method shouldConvertIterableOfElementsToArray.
@Test
public void shouldConvertIterableOfElementsToArray() throws OperationException {
// Given
final Element[] originalArray = new Element[] { new Entity.Builder().group("entity").build(), new Edge.Builder().group("edge").build() };
final Iterable<Element> originalResults = new WrappedCloseableIterable<>(Arrays.asList(originalArray));
final ToArrayHandler<Element> handler = new ToArrayHandler<>();
final ToArray operation = mock(ToArray.class);
given(operation.getInput()).willReturn(originalResults);
// When
final Element[] 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 shouldConvertIterableToArray.
@Test
public void shouldConvertIterableToArray() throws OperationException {
// Given
final Integer[] originalArray = new Integer[] { 1, 2, 3 };
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
assertArrayEquals(originalArray, results);
}
use of uk.gov.gchq.gaffer.operation.impl.output.ToArray in project Gaffer by gchq.
the class ToArrayHandlerTest method shouldConvertEmptyIterableOfObjectsToNullArray.
@Test
public void shouldConvertEmptyIterableOfObjectsToNullArray() throws OperationException {
// Given
final Object[] originalArray = new Object[0];
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
assertNull(results);
}
Aggregations