use of uk.gov.gchq.gaffer.operation.impl.output.ToStream in project Gaffer by gchq.
the class ToStreamHandlerTest method shouldHandleNullInput.
@Test
public void shouldHandleNullInput() throws OperationException {
// Given
final ToStreamHandler<Integer> handler = new ToStreamHandler();
final ToStream operation = mock(ToStream.class);
given(operation.getInput()).willReturn(null);
// When
final Stream<Integer> results = handler.doOperation(operation, new Context(), null);
// Then
assertThat(results).isNull();
}
use of uk.gov.gchq.gaffer.operation.impl.output.ToStream in project Gaffer by gchq.
the class ToStreamHandlerTest method shouldConvertIterableToStream.
@Test
public void shouldConvertIterableToStream() throws OperationException {
// Given
final List<Integer> originalList = Arrays.asList(1, 2, 3);
final Iterable<Integer> originalResults = new WrappedCloseableIterable<>(originalList);
final ToStreamHandler<Integer> handler = new ToStreamHandler();
final ToStream operation = mock(ToStream.class);
given(operation.getInput()).willReturn(originalResults);
// When
final Stream<Integer> stream = handler.doOperation(operation, new Context(), null);
final List<Integer> results = stream.collect(Collectors.toList());
// Then
assertEquals(originalList, results);
}
Aggregations