Search in sources :

Example 1 with SAME_ITEMS_ANY_ORDER

use of com.hazelcast.jet.core.test.TestSupport.SAME_ITEMS_ANY_ORDER in project hazelcast by hazelcast.

the class SessionWindowPTest method assertCorrectness.

private void assertCorrectness(List<Object> events) {
    @SuppressWarnings("unchecked") List<Object> expectedOutput = events.stream().map(e -> ((Entry<String, Long>) e).getKey()).flatMap(SessionWindowPTest::expectedSessions).distinct().collect(toList());
    events.add(new Watermark(100));
    expectedOutput.add(new Watermark(100));
    try {
        verifyProcessor(supplier).outputChecker(SAME_ITEMS_ANY_ORDER).input(events).expectOutput(expectedOutput);
    } catch (AssertionError e) {
        System.err.println("Tested with events: " + events);
        throw e;
    }
}
Also used : Collections.shuffle(java.util.Collections.shuffle) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) KeyedWindowResult(com.hazelcast.jet.datamodel.KeyedWindowResult) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) Processor(com.hazelcast.jet.core.Processor) Random(java.util.Random) TestOutbox(com.hazelcast.jet.core.test.TestOutbox) TestSupport.verifyProcessor(com.hazelcast.jet.core.test.TestSupport.verifyProcessor) TestProcessorContext(com.hazelcast.jet.core.test.TestProcessorContext) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Watermark(com.hazelcast.jet.core.Watermark) Functions.entryKey(com.hazelcast.function.Functions.entryKey) Util.entry(com.hazelcast.jet.Util.entry) Arrays.asList(java.util.Arrays.asList) After(org.junit.After) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) ToLongFunction(java.util.function.ToLongFunction) Before(org.junit.Before) AggregateOperations(com.hazelcast.jet.aggregate.AggregateOperations) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) Repeat(com.hazelcast.test.annotation.Repeat) SupplierEx(com.hazelcast.function.SupplierEx) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) SAME_ITEMS_ANY_ORDER(com.hazelcast.jet.core.test.TestSupport.SAME_ITEMS_ANY_ORDER) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) Entry(java.util.Map.Entry) Collections(java.util.Collections) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Entry(java.util.Map.Entry) Watermark(com.hazelcast.jet.core.Watermark)

Example 2 with SAME_ITEMS_ANY_ORDER

use of com.hazelcast.jet.core.test.TestSupport.SAME_ITEMS_ANY_ORDER in project hazelcast-jet by hazelcast.

the class SessionWindowPTest method assertCorrectness.

private void assertCorrectness(List<Object> events) {
    List<Object> expectedOutput = events.stream().map(e -> ((Entry<String, Long>) e).getKey()).flatMap(SessionWindowPTest::expectedSessions).distinct().collect(toList());
    events.add(new Watermark(100));
    expectedOutput.add(new Watermark(100));
    try {
        verifyProcessor(supplier).outputChecker(SAME_ITEMS_ANY_ORDER).input(events).expectOutput(expectedOutput);
    } catch (AssertionError e) {
        System.err.println("Tested with events: " + events);
        throw e;
    }
}
Also used : Collections.shuffle(java.util.Collections.shuffle) DistributedToLongFunction(com.hazelcast.jet.function.DistributedToLongFunction) RunWith(org.junit.runner.RunWith) Processor(com.hazelcast.jet.core.Processor) Random(java.util.Random) TestOutbox(com.hazelcast.jet.core.test.TestOutbox) TestSupport.verifyProcessor(com.hazelcast.jet.core.test.TestSupport.verifyProcessor) TestProcessorContext(com.hazelcast.jet.core.test.TestProcessorContext) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Watermark(com.hazelcast.jet.core.Watermark) Util.entry(com.hazelcast.jet.Util.entry) Arrays.asList(java.util.Arrays.asList) After(org.junit.After) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Before(org.junit.Before) DistributedSupplier(com.hazelcast.jet.function.DistributedSupplier) AggregateOperations(com.hazelcast.jet.aggregate.AggregateOperations) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) DistributedFunctions.entryKey(com.hazelcast.jet.function.DistributedFunctions.entryKey) Repeat(com.hazelcast.test.annotation.Repeat) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) SAME_ITEMS_ANY_ORDER(com.hazelcast.jet.core.test.TestSupport.SAME_ITEMS_ANY_ORDER) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) Entry(java.util.Map.Entry) SECONDS(java.util.concurrent.TimeUnit.SECONDS) WindowResult(com.hazelcast.jet.datamodel.WindowResult) Entry(java.util.Map.Entry) Watermark(com.hazelcast.jet.core.Watermark)

Aggregations

Util.entry (com.hazelcast.jet.Util.entry)2 AggregateOperations (com.hazelcast.jet.aggregate.AggregateOperations)2 Processor (com.hazelcast.jet.core.Processor)2 Watermark (com.hazelcast.jet.core.Watermark)2 TestOutbox (com.hazelcast.jet.core.test.TestOutbox)2 TestProcessorContext (com.hazelcast.jet.core.test.TestProcessorContext)2 SAME_ITEMS_ANY_ORDER (com.hazelcast.jet.core.test.TestSupport.SAME_ITEMS_ANY_ORDER)2 TestSupport.verifyProcessor (com.hazelcast.jet.core.test.TestSupport.verifyProcessor)2 HazelcastParallelClassRunner (com.hazelcast.test.HazelcastParallelClassRunner)2 Repeat (com.hazelcast.test.annotation.Repeat)2 ArrayList (java.util.ArrayList)2 Arrays.asList (java.util.Arrays.asList)2 Collections.shuffle (java.util.Collections.shuffle)2 Collections.singletonList (java.util.Collections.singletonList)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 Random (java.util.Random)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 SECONDS (java.util.concurrent.TimeUnit.SECONDS)2 Collectors.toList (java.util.stream.Collectors.toList)2