Last active
January 22, 2018 15:58
-
-
Save fpopic/97202d96590f1a5d13bf76f06da82f12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.apache.beam.sdk.transforms.DoFn.ProcessElement | |
| import org.apache.beam.sdk.transforms.{DoFn, DoFnTester} | |
| import org.scalatest.{FlatSpec, Matchers} | |
| class MyDoFn extends DoFn[Integer, Integer] { | |
| @ProcessElement | |
| def processElement(c: ProcessContext): Unit = { | |
| c.output(c.element * 2) | |
| } | |
| } | |
| class MinimalDoFnSpec extends FlatSpec with Matchers { | |
| val tester: DoFnTester[Integer, Integer] = DoFnTester.of(new MyDoFn()) | |
| "MyDoFn" should " multiply all elements by two" in { | |
| val actualOutput = tester.processBundle(1, 2, 3) | |
| val expectedOutput = Seq(2, 4, 6) | |
| actualOutput should contain only (expectedOutput: _*) | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Testing DoFn with ScalaTest: