Search in sources :

Example 11 with AssertionCompletedException

use of com.hazelcast.jet.pipeline.test.AssertionCompletedException in project hazelcast by hazelcast.

the class OrderedStreamProcessingTest method when_source_is_non_partitioned.

@Test
public void when_source_is_non_partitioned() {
    int validatedItemCount = ITEM_COUNT;
    int itemsPerSecond = 5 * ITEM_COUNT;
    List<Long> sequence = LongStream.range(0, validatedItemCount).boxed().collect(toList());
    StreamStage<Long> srcStage = p.readFrom(TestSources.itemStream(itemsPerSecond, (ts, seq) -> seq)).withIngestionTimestamps();
    StreamStage<Long> applied = srcStage.apply(transform);
    applied.writeTo(AssertionSinks.assertCollectedEventually(60, list -> Assert.assertArrayEquals(list.toArray(), sequence.toArray())));
    Job job = jet.newJob(p);
    try {
        job.join();
        fail("Job should have completed with an AssertionCompletedException, but completed normally");
    } catch (CompletionException e) {
        String errorMsg = e.getCause().getMessage();
        assertTrue("Job was expected to complete with AssertionCompletedException, but completed with: " + e.getCause(), errorMsg.contains(AssertionCompletedException.class.getName()));
    }
}
Also used : AssertionSinks(com.hazelcast.jet.pipeline.test.AssertionSinks) Arrays(java.util.Arrays) JetInstance(com.hazelcast.jet.JetInstance) BeforeClass(org.junit.BeforeClass) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) Processors(com.hazelcast.jet.core.processor.Processors) ParallelStreamP(com.hazelcast.jet.pipeline.test.ParallelStreamP) HazelcastSerialParametersRunnerFactory(com.hazelcast.test.HazelcastSerialParametersRunnerFactory) JetAssert.assertFalse(com.hazelcast.jet.core.test.JetAssert.assertFalse) JetAssert.assertTrue(com.hazelcast.jet.core.test.JetAssert.assertTrue) Nonnull(javax.annotation.Nonnull) Job(com.hazelcast.jet.Job) Before(org.junit.Before) UseParametersRunnerFactory(org.junit.runners.Parameterized.UseParametersRunnerFactory) PredicateEx(com.hazelcast.function.PredicateEx) FunctionEx(com.hazelcast.function.FunctionEx) AfterClass(org.junit.AfterClass) LongStream(java.util.stream.LongStream) HazelcastParametrizedRunner(com.hazelcast.test.HazelcastParametrizedRunner) JetTestSupport(com.hazelcast.jet.core.JetTestSupport) Parameter(org.junit.runners.Parameterized.Parameter) ProcessorMetaSupplier(com.hazelcast.jet.core.ProcessorMetaSupplier) Collection(java.util.Collection) Test(org.junit.Test) CompletionException(java.util.concurrent.CompletionException) Traversers(com.hazelcast.jet.Traversers) Serializable(java.io.Serializable) Objects(java.util.Objects) JetAssert.fail(com.hazelcast.jet.core.test.JetAssert.fail) TestSources(com.hazelcast.jet.pipeline.test.TestSources) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) GeneratorFunction(com.hazelcast.jet.pipeline.test.GeneratorFunction) Hazelcast(com.hazelcast.core.Hazelcast) AssertionCompletedException(com.hazelcast.jet.pipeline.test.AssertionCompletedException) LongAccumulator(com.hazelcast.jet.accumulator.LongAccumulator) Functions.wholeItem(com.hazelcast.function.Functions.wholeItem) Assert(org.junit.Assert) AssertionCompletedException(com.hazelcast.jet.pipeline.test.AssertionCompletedException) CompletionException(java.util.concurrent.CompletionException) Job(com.hazelcast.jet.Job) Test(org.junit.Test)

Aggregations

Job (com.hazelcast.jet.Job)11 AssertionCompletedException (com.hazelcast.jet.pipeline.test.AssertionCompletedException)11 CompletionException (java.util.concurrent.CompletionException)11 AfterClass (org.junit.AfterClass)11 BeforeClass (org.junit.BeforeClass)11 Test (org.junit.Test)11 List (java.util.List)10 Hazelcast (com.hazelcast.core.Hazelcast)9 LongAccumulator (com.hazelcast.jet.accumulator.LongAccumulator)9 JetTestSupport (com.hazelcast.jet.core.JetTestSupport)9 JetAssert.assertFalse (com.hazelcast.jet.core.test.JetAssert.assertFalse)9 JetAssert.assertTrue (com.hazelcast.jet.core.test.JetAssert.assertTrue)9 JetAssert.fail (com.hazelcast.jet.core.test.JetAssert.fail)9 AssertionSinks (com.hazelcast.jet.pipeline.test.AssertionSinks)9 HazelcastSerialParametersRunnerFactory (com.hazelcast.test.HazelcastSerialParametersRunnerFactory)9 Serializable (java.io.Serializable)9 Arrays (java.util.Arrays)9 LongStream (java.util.stream.LongStream)9 Before (org.junit.Before)9 UseParametersRunnerFactory (org.junit.runners.Parameterized.UseParametersRunnerFactory)9