public class TestPubsubSignal extends java.lang.Object implements org.junit.rules.TestRule
PCollection
and checks whether they
match the success criteria.
Uses a random temporary Pubsub topic for synchronization.
Modifier and Type | Method and Description |
---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
Description description) |
static TestPubsubSignal |
create()
Creates an instance of this rule.
|
<T> PTransform<PCollection<? extends T>,POutput> |
signalSuccessWhen(Coder<T> coder,
SerializableFunction<java.util.Set<T>,java.lang.Boolean> successPredicate)
Outputs a success message when
successPredicate is evaluated to true. |
void |
waitForSuccess(Duration duration)
Wait for a success signal for
duration . |
public static TestPubsubSignal create()
Loads GCP configuration from TestPipelineOptions
.
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, Description description)
apply
in interface org.junit.rules.TestRule
public <T> PTransform<PCollection<? extends T>,POutput> signalSuccessWhen(Coder<T> coder, SerializableFunction<java.util.Set<T>,java.lang.Boolean> successPredicate)
successPredicate
is evaluated to true.
successPredicate
is a SerializableFunction
that
accepts a set of currently captured events and returns true when the set satisfies the success
criteria.
If successPredicate
is evaluated to false, then it will be re-evaluated when next
event becomes available.
If successPredicate
is evaluated to true, then a success will be signaled and
waitForSuccess(Duration)
will unblock.
If successPredicate
throws, then failure will be signaled and
waitForSuccess(Duration)
will unblock.
public void waitForSuccess(Duration duration) throws java.io.IOException
duration
.java.io.IOException