Search in sources :

Example 66 with IntStream

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());
}
Also used : IntStream(java.util.stream.IntStream) Test(org.junit.jupiter.api.Test)

Example 67 with IntStream

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));
}
Also used : IntStream(java.util.stream.IntStream) MethodSorters(org.junit.runners.MethodSorters) StreamProducer(teetime.stage.StreamProducer) PushPullScheduling(teetime.framework.scheduling.pushpullmodel.PushPullScheduling) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) TeeTimeScheduler(teetime.framework.TeeTimeScheduler) ArrayList(java.util.ArrayList) Configuration(teetime.framework.Configuration) List(java.util.List) CollectorSink(teetime.stage.CollectorSink) Execution(teetime.framework.Execution) Assert(org.junit.Assert) FixMethodOrder(org.junit.FixMethodOrder) Counter(teetime.stage.Counter) Configuration(teetime.framework.Configuration) ArrayList(java.util.ArrayList) PushPullScheduling(teetime.framework.scheduling.pushpullmodel.PushPullScheduling) Counter(teetime.stage.Counter) Execution(teetime.framework.Execution) TeeTimeScheduler(teetime.framework.TeeTimeScheduler) IntStream(java.util.stream.IntStream)

Example 68 with IntStream

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));
}
Also used : IntStream(java.util.stream.IntStream) IsIterableContainingInOrder(org.hamcrest.collection.IsIterableContainingInOrder) List(java.util.List) Stream(java.util.stream.Stream) StageTester(teetime.framework.test.StageTester) Test(org.junit.Test) Assert(org.junit.Assert) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) IntStream(java.util.stream.IntStream) Test(org.junit.Test)

Example 69 with IntStream

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);
}
Also used : IntStream(java.util.stream.IntStream) Test(org.junit.Test)

Example 70 with IntStream

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));
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) List(java.util.List) Stream(io.vavr.collection.Stream) ArrayList(java.util.ArrayList) IntStream(java.util.stream.IntStream)

Aggregations

IntStream (java.util.stream.IntStream)96 List (java.util.List)19 Test (org.junit.jupiter.api.Test)17 ArrayList (java.util.ArrayList)15 Stream (java.util.stream.Stream)12 Test (org.junit.Test)12 Arrays (java.util.Arrays)11 Map (java.util.Map)10 Collectors (java.util.stream.Collectors)9 Random (java.util.Random)7 DoubleStream (java.util.stream.DoubleStream)6 LongStream (java.util.stream.LongStream)6 Function (java.util.function.Function)5 Pattern (java.util.regex.Pattern)5 DecimalBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)5 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)5 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)5 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)5 LayoutRow (org.uberfire.ext.layout.editor.api.editor.LayoutRow)5 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)5