Package com.hazelcast.jet.pipeline.test
Class AssertionSinkBuilder<S,T>
java.lang.Object
com.hazelcast.jet.pipeline.test.AssertionSinkBuilder<S,T>
- Type Parameters:
S
- type of the state objectT
- type of the items the sink will accept
- Since:
- Jet 3.2
-
Method Summary
Modifier and TypeMethodDescriptionstatic <S> AssertionSinkBuilder<S,
Void> assertionSink
(String name, SupplierEx<? extends S> createFn) Returns a builder object that offers a step-by-step fluent API to build an assertionSink
for the Pipeline API.build()
Creates and returns theSink
with the components you supplied to this builder.completeFn
(ConsumerEx<? super S> completeFn) Sets the function that will be called after all the upstream stages have completed and all the items were received.<T_NEW> AssertionSinkBuilder<S,
T_NEW> receiveFn
(BiConsumerEx<? super S, ? super T_NEW> receiveFn) Sets the function Jet will call upon receiving every item.timerFn
(ConsumerEx<? super S> timerFn) Sets the function that will be called periodically.
-
Method Details
-
assertionSink
@Nonnull public static <S> AssertionSinkBuilder<S,Void> assertionSink(@Nonnull String name, @Nonnull SupplierEx<? extends S> createFn) Returns a builder object that offers a step-by-step fluent API to build an assertionSink
for the Pipeline API. An assertion sink is typically used for testing of pipelines where you want to run an assertion either on each item as they arrive, or when all items have been received.These are the callback functions you can provide to implement the sink's behavior:
-
createFn
creates the state which can be used to hold incoming items. -
receiveFn
gets notified of each item the sink receives and can either assert the item directly or add it to the state object. -
timerFn
is run periodically even when there are no items received. This can be used to assert that certain assertions have been reached within a specific time in streaming pipelines. -
completeFn
is run after all the items have been received. This only applies to batch jobs, in a streaming job this method will never be called.
The sink doesn't participate in the fault-tolerance protocol, which means you can't remember which items you already received across a job restart.
- Type Parameters:
S
- type of the state object- Since:
- Jet 3.2
-
-
receiveFn
@Nonnull public <T_NEW> AssertionSinkBuilder<S,T_NEW> receiveFn(@Nonnull BiConsumerEx<? super S, ? super T_NEW> receiveFn) Sets the function Jet will call upon receiving every item. The function receives two arguments: the state object (as provided by thecreateFn
and the received item. It may assert the item directly or push it to the state object.- Type Parameters:
T_NEW
- type of the items the sink will accept- Parameters:
receiveFn
- the function to execute upon receiving an item
-
timerFn
Sets the function that will be called periodically. You can use this function to assert that a condition will eventually be reached. The function is guaranteed to be called even if there are no items coming into the sink.This function is optional.
- Parameters:
timerFn
- the optional "timer" function
-
completeFn
Sets the function that will be called after all the upstream stages have completed and all the items were received.This function is optional.
- Parameters:
completeFn
- the optional "complete" function
-
build
Creates and returns theSink
with the components you supplied to this builder.
-