You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ke...@apache.org on 2016/11/18 23:09:58 UTC
[3/6] incubator-beam git commit: Separate ParDoTest cases and make
them more flexible
Separate ParDoTest cases and make them more flexible
A number of excessively rigid name tests preclude runner expansion
of ParDo. This change makes them into independent unit tests
for better signal and makes them more accurate to the intent - the
name should have the relevant information, but may have other
content.
Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/e92a157a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/e92a157a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/e92a157a
Branch: refs/heads/master
Commit: e92a157aa41746df225379b71cc88695c8e2d93f
Parents: 3548ffb
Author: Kenneth Knowles <kl...@google.com>
Authored: Thu Nov 17 10:14:07 2016 -0800
Committer: Kenneth Knowles <kl...@google.com>
Committed: Fri Nov 18 15:09:43 2016 -0800
----------------------------------------------------------------------
.../apache/beam/sdk/transforms/ParDoTest.java | 55 ++++++++++----------
1 file changed, 27 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/e92a157a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoTest.java
index 26f5570..3c3e266 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoTest.java
@@ -27,6 +27,7 @@ import static org.apache.beam.sdk.util.StringUtils.byteArrayToJsonString;
import static org.apache.beam.sdk.util.StringUtils.jsonStringToByteArray;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
@@ -826,39 +827,37 @@ public class ParDoTest implements Serializable {
}
@Test
- public void testParDoGetName() {
+ public void testParDoOutputNameBasedOnDoFnWithTrimmedSuffix() {
Pipeline p = TestPipeline.create();
+ PCollection<String> output = p.apply(Create.of(1)).apply(ParDo.of(new TestOldDoFn()));
+ assertThat(output.getName(), containsString("ParDo(Test)"));
+ }
- PCollection<Integer> input =
- p.apply(Create.of(Arrays.asList(3, -42, 666)))
- .setName("MyInput");
-
- {
- PCollection<String> output1 = input.apply(ParDo.of(new TestOldDoFn()));
- assertEquals("ParDo(Test).out", output1.getName());
- }
-
- {
- PCollection<String> output2 = input.apply("MyParDo", ParDo.of(new TestOldDoFn()));
- assertEquals("MyParDo.out", output2.getName());
- }
-
- {
- PCollection<String> output4 = input.apply("TestOldDoFn", ParDo.of(new TestOldDoFn()));
- assertEquals("TestOldDoFn.out", output4.getName());
- }
+ @Test
+ public void testParDoOutputNameBasedOnLabel() {
+ Pipeline p = TestPipeline.create();
+ PCollection<String> output =
+ p.apply(Create.of(1)).apply("MyParDo", ParDo.of(new TestOldDoFn()));
+ assertThat(output.getName(), containsString("MyParDo"));
+ }
- {
- PCollection<String> output5 = input.apply(ParDo.of(new StrangelyNamedDoer()));
- assertEquals("ParDo(StrangelyNamedDoer).out",
- output5.getName());
- }
+ @Test
+ public void testParDoOutputNameBasedDoFnWithoutMatchingSuffix() {
+ Pipeline p = TestPipeline.create();
+ PCollection<String> output = p.apply(Create.of(1)).apply(ParDo.of(new StrangelyNamedDoer()));
+ assertThat(output.getName(), containsString("ParDo(StrangelyNamedDoer)"));
+ }
- assertEquals("ParDo(Printing)", ParDo.of(new PrintingDoFn()).getName());
+ @Test
+ public void testParDoTransformNameBasedDoFnWithTrimmedSuffix() {
+ assertThat(ParDo.of(new PrintingDoFn()).getName(), containsString("ParDo(Printing)"));
+ }
- assertEquals(
- "ParMultiDo(SideOutputDummy)",
- ParDo.of(new SideOutputDummyFn(null)).withOutputTags(null, null).getName());
+ @Test
+ public void testParDoMultiNameBasedDoFnWithTrimmerSuffix() {
+ assertThat(
+ ParDo.of(new SideOutputDummyFn(null)).withOutputTags(null, null).getName(),
+ containsString("ParMultiDo(SideOutputDummy)"));
}
@Test