T - The type of elements in the input collection.public class DataflowAssert<T>
extends java.lang.Object
PCollection
incorporated into the pipeline. Such an assertion
can be checked no matter what kind of
PipelineRunner is
used, so it's good for testing using the
DirectPipelineRunner,
the
DataflowPipelineRunner,
etc.
Note that the DataflowAssert call must precede the call
to Pipeline.run().
Examples of use:
Pipeline p = TestPipeline.create();
...
PCollection<String> output =
input
.apply(ParDo.of(new TestDoFn()));
DataflowAssert.that(output)
.containsInAnyOrder("out1", "out2", "out3");
...
PCollection<Integer> ints = ...
PCollection<Integer> sum =
ints
.apply(Combine.globally(new SumInts()));
DataflowAssert.that(sum)
.is(42);
...
p.run();
JUnit and Hamcrest must be linked in by any code that uses DataflowAssert.
| Modifier and Type | Class and Description |
|---|---|
static class |
DataflowAssert.AssertIs<T>
SerializableFunction that verifies that a value is equal to an
expected value.
|
static class |
DataflowAssert.AssertThat<Actual,Expected>
SerializableFunction that performs an
Assert.assertThat()
operation using a Matcher operation. |
static class |
DataflowAssert.IterableAssert<T>
An assertion about the contents of a
PCollectionView<. |
static class |
DataflowAssert.SingletonAssert<T>
An assertion about a single value.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> DataflowAssert.IterableAssert<T> |
that(PCollection<T> futureResult)
Constructs an IterableAssert for the elements of the provided
PCollection<T>. |
static <T> DataflowAssert.IterableAssert<T> |
thatIterable(PCollectionView<java.lang.Iterable<T>,?> futureResult)
Constructs an IterableAssert for the value of the provided
PCollectionView<Iterable<T>, ?>. |
static <T> DataflowAssert.SingletonAssert<T> |
thatSingleton(PCollection<T> futureResult)
Constructs a SingletonAssert for the value of the provided
PCollection<T>, which must be a singleton. |
static <T> DataflowAssert.IterableAssert<T> |
thatSingletonIterable(PCollection<java.lang.Iterable<T>> futureResult)
Constructs an IterableAssert for the value of the provided
PCollection<Iterable<T>>, which must be a singleton. |
public static <T> DataflowAssert.IterableAssert<T> that(PCollection<T> futureResult)
PCollection<T>.public static <T> DataflowAssert.IterableAssert<T> thatSingletonIterable(PCollection<java.lang.Iterable<T>> futureResult)
PCollection<Iterable<T>>, which must be a singleton.public static <T> DataflowAssert.IterableAssert<T> thatIterable(PCollectionView<java.lang.Iterable<T>,?> futureResult)
PCollectionView<Iterable<T>, ?>.public static <T> DataflowAssert.SingletonAssert<T> thatSingleton(PCollection<T> futureResult)
PCollection<T>, which must be a singleton.