Search in sources :

Example 1 with ToStream

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();
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) ToStream(uk.gov.gchq.gaffer.operation.impl.output.ToStream) Test(org.junit.jupiter.api.Test)

Example 2 with ToStream

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) WrappedCloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.WrappedCloseableIterable) ToStream(uk.gov.gchq.gaffer.operation.impl.output.ToStream) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 ToStream (uk.gov.gchq.gaffer.operation.impl.output.ToStream)2 Context (uk.gov.gchq.gaffer.store.Context)2 WrappedCloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.WrappedCloseableIterable)1