Google Cloud Dataflow SDK for Java, version 1.9.1
com.google.cloud.dataflow.sdk.testing
Class DataflowAssert
- java.lang.Object
-
- com.google.cloud.dataflow.sdk.testing.DataflowAssert
-
public class DataflowAssert extends Object
An assertion on the contents of aPCollection
incorporated into the pipeline. Such an assertion can be checked no matter what kind ofPipelineRunner
is used.Note that the
DataflowAssert
call must precede the call toPipeline.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
DataflowAssert.GroupThenAssert<T>
A transform that applies an assertion-checking function over iterables ofActualT
to the entirety of the contents of its input.static class
DataflowAssert.GroupThenAssertForSingleton<T>
A transform that applies an assertion-checking function to a single iterable contained as the sole element of aPCollection
.static interface
DataflowAssert.IterableAssert<T>
Builder interface for assertions applicable to iterables and PCollection contents.static class
DataflowAssert.OneSideInputAssert<ActualT>
An assertion checker that takes a singlePCollectionView<ActualT>
and an assertion overActualT
, and checks it within a Beam pipeline.static interface
DataflowAssert.SingletonAssert<T>
Builder interface for assertions applicable to a single value.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description static <T> DataflowAssert.IterableAssert<T>
that(PCollection<T> actual)
Constructs anDataflowAssert.IterableAssert
for the elements of the providedPCollection
.static <T> DataflowAssert.IterableAssert<T>
thatIterable(PCollectionView<Iterable<T>> actual)
Deprecated.static <K,V> DataflowAssert.SingletonAssert<Map<K,V>>
thatMap(PCollection<KV<K,V>> actual)
Constructs aDataflowAssert.SingletonAssert
for the value of the providedPCollection
, which must have at most one value per key.static <K,V> DataflowAssert.SingletonAssert<Map<K,Iterable<V>>>
thatMultimap(PCollection<KV<K,V>> actual)
Constructs aDataflowAssert.SingletonAssert
for the value of the providedPCollection
.static <T> DataflowAssert.SingletonAssert<T>
thatSingleton(PCollection<T> actual)
Constructs aDataflowAssert.SingletonAssert
for the value of the providedPCollection PCollection<T>
, which must be a singleton.static <T> DataflowAssert.IterableAssert<T>
thatSingletonIterable(PCollection<? extends Iterable<T>> actual)
Constructs anDataflowAssert.IterableAssert
for the value of the providedPCollection
which must contain a singleIterable<T>
value.
-
-
-
Method Detail
-
that
public static <T> DataflowAssert.IterableAssert<T> that(PCollection<T> actual)
Constructs anDataflowAssert.IterableAssert
for the elements of the providedPCollection
.
-
thatSingletonIterable
public static <T> DataflowAssert.IterableAssert<T> thatSingletonIterable(PCollection<? extends Iterable<T>> actual)
Constructs anDataflowAssert.IterableAssert
for the value of the providedPCollection
which must contain a singleIterable<T>
value.
-
thatIterable
@Deprecated public static <T> DataflowAssert.IterableAssert<T> thatIterable(PCollectionView<Iterable<T>> actual)
Deprecated. usethatSingletonIterable(PCollection)
,thatSingleton(PCollection)
orthat(PCollection)
instead.Constructs anDataflowAssert.IterableAssert
for the value of the providedPCollectionView
.
-
thatSingleton
public static <T> DataflowAssert.SingletonAssert<T> thatSingleton(PCollection<T> actual)
Constructs aDataflowAssert.SingletonAssert
for the value of the providedPCollection PCollection<T>
, which must be a singleton.
-
thatMultimap
public static <K,V> DataflowAssert.SingletonAssert<Map<K,Iterable<V>>> thatMultimap(PCollection<KV<K,V>> actual)
Constructs aDataflowAssert.SingletonAssert
for the value of the providedPCollection
.Note that the actual value must be coded by a
KvCoder
, not just anyCoder<K, V>
.
-
thatMap
public static <K,V> DataflowAssert.SingletonAssert<Map<K,V>> thatMap(PCollection<KV<K,V>> actual)
Constructs aDataflowAssert.SingletonAssert
for the value of the providedPCollection
, which must have at most one value per key.Note that the actual value must be coded by a
KvCoder
, not just anyCoder<K, V>
.
-
-