DoFnTester (Google Cloud Dataflow SDK 1.9.1 API)

Google Cloud Dataflow SDK for Java, version 1.9.1

com.google.cloud.dataflow.sdk.transforms

Class DoFnTester<InputT,OutputT>

  • java.lang.Object
    • com.google.cloud.dataflow.sdk.transforms.DoFnTester<InputT,OutputT>
  • Type Parameters:
    InputT - the type of the DoFn's (main) input elements
    OutputT - the type of the DoFn's (main) output elements


    public class DoFnTester<InputT,OutputT>
    extends Object
    A harness for unit-testing a DoFn.

    For example:

     
     DoFn<InputT, OutputT> fn = ...;
    
     DoFnTester<InputT, OutputT> fnTester = DoFnTester.of(fn);
    
     // Set arguments shared across all batches:
     fnTester.setSideInputs(...);      // If fn takes side inputs.
     fnTester.setSideOutputTags(...);  // If fn writes to side outputs.
    
     // Process a batch containing a single input element:
     Input testInput = ...;
     List<OutputT> testOutputs = fnTester.processBatch(testInput);
     Assert.assertThat(testOutputs, Matchers.hasItems(...));
    
     // Process a bigger batch:
     Assert.assertThat(fnTester.processBatch(i1, i2, ...), Matchers.hasItems(...));
      


Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Dataflow
Need help? Visit our support page.