Class PAssert


  • public class PAssert
    extends java.lang.Object
    An assertion on the contents of a PCollection incorporated into the pipeline. Such an assertion can be checked no matter what kind of PipelineRunner is used.

    Note that the PAssert call must precede the call to Pipeline.run().

    Examples of use:

    
     Pipeline p = TestPipeline.create();
     ...
     PCollection<String> output =
          input
          .apply(ParDo.of(new TestDoFn()));
     PAssert.that(output)
         .containsInAnyOrder("out1", "out2", "out3");
     ...
     PCollection<Integer> ints = ...
     PCollection<Integer> sum =
         ints
         .apply(Combine.globally(new SumInts()));
     PAssert.thatSingleton(sum)
         .isEqualTo(42);
     ...
     p.run();
     

    JUnit and Hamcrest must be linked in by any code that uses PAssert.