use of java.util.stream.IntStream in project waltz by khartec.
the class RandomUtilities_randomlySizedIntStreamTest method simpleRandomlySizedIntStream1.
@Test
public void simpleRandomlySizedIntStream1() {
IntStream val = RandomUtilities.randomlySizedIntStream(0, 1);
assertEquals(0, val.count());
}
use of java.util.stream.IntStream in project TeeTime by teetime-framework.
the class ThreeStagesPushPullIT method shouldExecutePipelineCorrectlyManyElements.
private void shouldExecutePipelineCorrectlyManyElements(final int numElements, final int numThreads) {
List<Integer> processedElements = new ArrayList<>();
IntStream inputElements = IntStream.iterate(0, i -> i + 1).limit(numElements);
Configuration config = new Configuration().from(new StreamProducer<>(inputElements)).to(new Counter<>()).end(new CollectorSink<>(processedElements));
TeeTimeScheduler scheduling = new PushPullScheduling(config);
Execution<Configuration> execution = new Execution<>(config, true, scheduling);
execution.executeBlocking();
for (int i = 0; i < numElements; i++) {
Integer actualElement = processedElements.get(i);
assertThat(actualElement, is(i));
}
assertThat(processedElements, hasSize(numElements));
}
use of java.util.stream.IntStream in project TeeTime by teetime-framework.
the class StreamProducerTest method testIntStream.
@Test
public void testIntStream() throws Exception {
IntStream inputElements = IntStream.iterate(1, i -> i + 1).limit(3);
StreamProducer<Integer> producer = new StreamProducer<>(inputElements);
final List<Integer> actualElements = new ArrayList<>();
test(producer).and().receive(actualElements).from(producer.getOutputPort()).start();
assertThat(actualElements, contains(1, 2, 3));
}
use of java.util.stream.IntStream in project tutorials by eugenp.
the class GuavaStreamsUnitTest method createStreamsWithOptionalInt.
@Test
public void createStreamsWithOptionalInt() {
IntStream streamFromOptionalInt = Streams.stream(OptionalInt.of(1));
// Assert.assertNotNull(streamFromOptionalInt);
assertEquals(streamFromOptionalInt.count(), 1);
}
use of java.util.stream.IntStream in project tutorials by eugenp.
the class VavrSampler method jdkFlatMapping.
public static void jdkFlatMapping() {
System.out.println("JDK FlatMap -> Uncomment line 68 to test");
System.out.println("====================================");
int[][] intOfInts = new int[][] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
IntStream mapToInt = Arrays.stream(intOfInts).map(intArr -> Arrays.stream(intArr)).flatMapToInt(val -> val.map(n -> {
return n * n;
})).peek(n -> System.out.println("Peeking at " + n));
// Uncomment to execute pipeline
// mapToInt.forEach(n -> System.out.println("FlatMapped Result "+n));
}
Aggregations