You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by da...@apache.org on 2016/04/08 23:02:06 UTC
[1/5] incubator-beam git commit: Rename DataflowAssert to PAssert
Repository: incubator-beam
Updated Branches:
refs/heads/master 5f24cef20 -> 529bcdf56
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/PartitionTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/PartitionTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/PartitionTest.java
index 31447fc..53642f1 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/PartitionTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/PartitionTest.java
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Partition.PartitionFn;
@@ -70,8 +70,8 @@ public class PartitionTest implements Serializable {
.apply(Create.of(591, 11789, 1257, 24578, 24799, 307))
.apply(Partition.of(2, new ModFn()));
assertTrue(outputs.size() == 2);
- DataflowAssert.that(outputs.get(0)).containsInAnyOrder(24578);
- DataflowAssert.that(outputs.get(1)).containsInAnyOrder(591, 11789, 1257,
+ PAssert.that(outputs.get(0)).containsInAnyOrder(24578);
+ PAssert.that(outputs.get(1)).containsInAnyOrder(591, 11789, 1257,
24799, 307);
pipeline.run();
}
@@ -84,9 +84,9 @@ public class PartitionTest implements Serializable {
.apply(Create.of(1, 2, 4, 5))
.apply(Partition.of(3, new ModFn()));
assertTrue(outputs.size() == 3);
- DataflowAssert.that(outputs.get(0)).empty();
- DataflowAssert.that(outputs.get(1)).containsInAnyOrder(1, 4);
- DataflowAssert.that(outputs.get(2)).containsInAnyOrder(2, 5);
+ PAssert.that(outputs.get(0)).empty();
+ PAssert.that(outputs.get(1)).containsInAnyOrder(1, 4);
+ PAssert.that(outputs.get(2)).containsInAnyOrder(2, 5);
pipeline.run();
}
@@ -130,7 +130,7 @@ public class PartitionTest implements Serializable {
assertTrue(outputs.size() == 2);
PCollection<Integer> output = outputs.apply(Flatten.<Integer>pCollections());
- DataflowAssert.that(output).containsInAnyOrder(2, 4, 5, 7, 8, 10, 11);
+ PAssert.that(output).containsInAnyOrder(2, 4, 5, 7, 8, 10, 11);
pipeline.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/RemoveDuplicatesTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/RemoveDuplicatesTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/RemoveDuplicatesTest.java
index 6508738..2ae4a1f 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/RemoveDuplicatesTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/RemoveDuplicatesTest.java
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertTrue;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -64,7 +64,7 @@ public class RemoveDuplicatesTest {
PCollection<String> output =
input.apply(RemoveDuplicates.<String>create());
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder("k1", "k5", "k2", "k3");
p.run();
}
@@ -83,7 +83,7 @@ public class RemoveDuplicatesTest {
PCollection<String> output =
input.apply(RemoveDuplicates.<String>create());
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
@@ -125,7 +125,7 @@ public class RemoveDuplicatesTest {
input.apply(RemoveDuplicates.withRepresentativeValueFn(new Keys()));
- DataflowAssert.that(output).satisfies(new Checker());
+ PAssert.that(output).satisfies(new Checker());
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/SampleTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/SampleTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/SampleTest.java
index 2342766..a2be424 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/SampleTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/SampleTest.java
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.BigEndianIntegerCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.PCollection;
@@ -110,7 +110,7 @@ public class SampleTest {
PCollection<Iterable<Integer>> output = input.apply(
Sample.<Integer>fixedSizeGlobally(3));
- DataflowAssert.thatSingletonIterable(output)
+ PAssert.thatSingletonIterable(output)
.satisfies(new VerifyCorrectSample<>(3, DATA));
p.run();
}
@@ -125,7 +125,7 @@ public class SampleTest {
PCollection<Iterable<Integer>> output = input.apply(
Sample.<Integer>fixedSizeGlobally(3));
- DataflowAssert.thatSingletonIterable(output)
+ PAssert.thatSingletonIterable(output)
.satisfies(new VerifyCorrectSample<>(0, EMPTY));
p.run();
}
@@ -140,7 +140,7 @@ public class SampleTest {
PCollection<Iterable<Integer>> output = input.apply(
Sample.<Integer>fixedSizeGlobally(0));
- DataflowAssert.thatSingletonIterable(output)
+ PAssert.thatSingletonIterable(output)
.satisfies(new VerifyCorrectSample<>(0, DATA));
p.run();
}
@@ -155,7 +155,7 @@ public class SampleTest {
PCollection<Iterable<Integer>> output = input.apply(
Sample.<Integer>fixedSizeGlobally(10));
- DataflowAssert.thatSingletonIterable(output)
+ PAssert.thatSingletonIterable(output)
.satisfies(new VerifyCorrectSample<>(5, DATA));
p.run();
}
@@ -180,7 +180,7 @@ public class SampleTest {
PCollection<Iterable<Integer>> output = input.apply(
Sample.<Integer>fixedSizeGlobally(6));
- DataflowAssert.thatSingletonIterable(output)
+ PAssert.thatSingletonIterable(output)
.satisfies(new VerifyCorrectSample<>(6, REPEATED_DATA));
p.run();
}
@@ -225,7 +225,7 @@ public class SampleTest {
input.apply(Sample.<String>any(limit));
- DataflowAssert.that(output)
+ PAssert.that(output)
.satisfies(new VerifyAnySample(lines, limit));
p.run();
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/TopTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/TopTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/TopTest.java
index 0c65357..a9eb7c2 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/TopTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/TopTest.java
@@ -23,7 +23,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.BigEndianIntegerCoder;
import com.google.cloud.dataflow.sdk.coders.KvCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.windowing.FixedWindows;
import com.google.cloud.dataflow.sdk.transforms.windowing.Window;
@@ -104,13 +104,13 @@ public class TopTest {
PCollection<KV<String, List<Integer>>> smallestPerKey = inputTable
.apply(Top.<String, Integer>smallestPerKey(2));
- DataflowAssert.thatSingletonIterable(top1).containsInAnyOrder(Arrays.asList("bb"));
- DataflowAssert.thatSingletonIterable(top2).containsInAnyOrder("z", "c");
- DataflowAssert.thatSingletonIterable(top3).containsInAnyOrder("a", "bb", "c");
- DataflowAssert.that(largestPerKey).containsInAnyOrder(
+ PAssert.thatSingletonIterable(top1).containsInAnyOrder(Arrays.asList("bb"));
+ PAssert.thatSingletonIterable(top2).containsInAnyOrder("z", "c");
+ PAssert.thatSingletonIterable(top3).containsInAnyOrder("a", "bb", "c");
+ PAssert.that(largestPerKey).containsInAnyOrder(
KV.of("a", Arrays.asList(3, 2)),
KV.of("b", Arrays.asList(100, 10)));
- DataflowAssert.that(smallestPerKey).containsInAnyOrder(
+ PAssert.that(smallestPerKey).containsInAnyOrder(
KV.of("a", Arrays.asList(1, 2)),
KV.of("b", Arrays.asList(1, 10)));
@@ -135,11 +135,11 @@ public class TopTest {
PCollection<KV<String, List<Integer>>> smallestPerKey = inputTable
.apply(Top.<String, Integer>smallestPerKey(2));
- DataflowAssert.thatSingletonIterable(top1).empty();
- DataflowAssert.thatSingletonIterable(top2).empty();
- DataflowAssert.thatSingletonIterable(top3).empty();
- DataflowAssert.that(largestPerKey).empty();
- DataflowAssert.that(smallestPerKey).empty();
+ PAssert.thatSingletonIterable(top1).empty();
+ PAssert.thatSingletonIterable(top2).empty();
+ PAssert.thatSingletonIterable(top3).empty();
+ PAssert.that(largestPerKey).empty();
+ PAssert.that(smallestPerKey).empty();
p.run();
}
@@ -180,13 +180,13 @@ public class TopTest {
PCollection<KV<String, List<Integer>>> smallestPerKey = inputTable
.apply(Top.<String, Integer>smallestPerKey(0));
- DataflowAssert.thatSingletonIterable(top1).empty();
- DataflowAssert.thatSingletonIterable(top2).empty();
- DataflowAssert.thatSingletonIterable(top3).empty();
- DataflowAssert.that(largestPerKey).containsInAnyOrder(
+ PAssert.thatSingletonIterable(top1).empty();
+ PAssert.thatSingletonIterable(top2).empty();
+ PAssert.thatSingletonIterable(top3).empty();
+ PAssert.that(largestPerKey).containsInAnyOrder(
KV.of("a", Arrays.<Integer>asList()),
KV.of("b", Arrays.<Integer>asList()));
- DataflowAssert.that(smallestPerKey).containsInAnyOrder(
+ PAssert.that(smallestPerKey).containsInAnyOrder(
KV.of("a", Arrays.<Integer>asList()),
KV.of("b", Arrays.<Integer>asList()));
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ValuesTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ValuesTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ValuesTest.java
index 790a175..69656d6 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ValuesTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ValuesTest.java
@@ -23,7 +23,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.BigEndianIntegerCoder;
import com.google.cloud.dataflow.sdk.coders.KvCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -65,7 +65,7 @@ public class ValuesTest {
PCollection<Integer> output = input.apply(Values.<Integer>create());
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder(1, 2, 3, 4, 4);
p.run();
@@ -82,7 +82,7 @@ public class ValuesTest {
PCollection<Integer> output = input.apply(Values.<Integer>create());
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ViewTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ViewTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ViewTest.java
index 69a4d2e..59919e4 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ViewTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ViewTest.java
@@ -36,7 +36,7 @@ import com.google.cloud.dataflow.sdk.coders.VoidCoder;
import com.google.cloud.dataflow.sdk.options.DirectPipelineOptions;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
import com.google.cloud.dataflow.sdk.runners.DirectPipelineRunner;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.windowing.FixedWindows;
@@ -106,7 +106,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(47, 47, 47);
+ PAssert.that(output).containsInAnyOrder(47, 47, 47);
pipeline.run();
}
@@ -136,7 +136,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(47, 47, 48);
+ PAssert.that(output).containsInAnyOrder(47, 47, 48);
pipeline.run();
}
@@ -211,7 +211,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(11, 13, 17, 23, 11, 13, 17, 23);
+ PAssert.that(output).containsInAnyOrder(11, 13, 17, 23, 11, 13, 17, 23);
pipeline.run();
}
@@ -250,7 +250,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(11, 13, 17, 23, 31, 33, 37, 43);
+ PAssert.that(output).containsInAnyOrder(11, 13, 17, 23, 31, 33, 37, 43);
pipeline.run();
}
@@ -276,7 +276,7 @@ public class ViewTest implements Serializable {
}));
// Pass at least one value through to guarantee that DoFn executes.
- DataflowAssert.that(results).containsInAnyOrder(1);
+ PAssert.that(results).containsInAnyOrder(1);
pipeline.run();
}
@@ -321,7 +321,7 @@ public class ViewTest implements Serializable {
}));
// Pass at least one value through to guarantee that DoFn executes.
- DataflowAssert.that(output).containsInAnyOrder(11);
+ PAssert.that(output).containsInAnyOrder(11);
pipeline.run();
}
@@ -346,7 +346,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(11, 13, 17, 23, 11, 13, 17, 23);
+ PAssert.that(output).containsInAnyOrder(11, 13, 17, 23, 11, 13, 17, 23);
pipeline.run();
}
@@ -383,7 +383,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(11, 13, 17, 23, 31, 33, 37, 43);
+ PAssert.that(output).containsInAnyOrder(11, 13, 17, 23, 31, 33, 37, 43);
pipeline.run();
}
@@ -408,7 +408,7 @@ public class ViewTest implements Serializable {
}));
// Pass at least one value through to guarantee that DoFn executes.
- DataflowAssert.that(results).containsInAnyOrder(1);
+ PAssert.that(results).containsInAnyOrder(1);
pipeline.run();
}
@@ -439,7 +439,7 @@ public class ViewTest implements Serializable {
}));
// Pass at least one value through to guarantee that DoFn executes.
- DataflowAssert.that(output).containsInAnyOrder(11);
+ PAssert.that(output).containsInAnyOrder(11);
pipeline.run();
}
@@ -466,7 +466,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("apple", 1), KV.of("apple", 2), KV.of("banana", 3), KV.of("blackberry", 3));
pipeline.run();
@@ -498,7 +498,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("a", 1), KV.of("a", 2), KV.of("b", 3));
pipeline.run();
@@ -548,7 +548,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("apple", 1), KV.of("apple", 2), KV.of("banana", 3), KV.of("blackberry", 3));
pipeline.run();
@@ -587,7 +587,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("apple", 1), KV.of("apple", 2), KV.of("banana", 3), KV.of("blackberry", 3));
pipeline.run();
@@ -630,7 +630,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("a", 1), KV.of("a", 2), KV.of("b", 3));
pipeline.run();
@@ -670,7 +670,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("apple", 1), KV.of("apple", 2), KV.of("banana", 3), KV.of("blackberry", 3));
pipeline.run();
@@ -699,7 +699,7 @@ public class ViewTest implements Serializable {
}));
// Pass at least one value through to guarantee that DoFn executes.
- DataflowAssert.that(results).containsInAnyOrder(1);
+ PAssert.that(results).containsInAnyOrder(1);
pipeline.run();
}
@@ -728,7 +728,7 @@ public class ViewTest implements Serializable {
}));
// Pass at least one value through to guarantee that DoFn executes.
- DataflowAssert.that(results).containsInAnyOrder(1);
+ PAssert.that(results).containsInAnyOrder(1);
pipeline.run();
}
@@ -776,7 +776,7 @@ public class ViewTest implements Serializable {
}));
// Pass at least one value through to guarantee that DoFn executes.
- DataflowAssert.that(output).containsInAnyOrder(KV.of("apple", 1));
+ PAssert.that(output).containsInAnyOrder(KV.of("apple", 1));
pipeline.run();
}
@@ -802,7 +802,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("apple", 1), KV.of("banana", 3), KV.of("blackberry", 3));
pipeline.run();
@@ -832,7 +832,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("a", 1), KV.of("b", 3));
pipeline.run();
@@ -861,7 +861,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("apple", 1), KV.of("banana", 3), KV.of("blackberry", 3));
pipeline.run();
@@ -899,7 +899,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("apple", 1), KV.of("banana", 2), KV.of("blackberry", 3));
pipeline.run();
@@ -940,7 +940,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("a", 1), KV.of("b", 2), KV.of("b", 3));
pipeline.run();
@@ -981,7 +981,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("apple", 1), KV.of("banana", 2), KV.of("blackberry", 3));
pipeline.run();
@@ -1010,7 +1010,7 @@ public class ViewTest implements Serializable {
}));
// Pass at least one value through to guarantee that DoFn executes.
- DataflowAssert.that(results).containsInAnyOrder(1);
+ PAssert.that(results).containsInAnyOrder(1);
pipeline.run();
}
@@ -1038,7 +1038,7 @@ public class ViewTest implements Serializable {
}));
// Pass at least one value through to guarantee that DoFn executes.
- DataflowAssert.that(results).containsInAnyOrder(1);
+ PAssert.that(results).containsInAnyOrder(1);
pipeline.run();
}
@@ -1068,7 +1068,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("apple", 1), KV.of("banana", 3), KV.of("blackberry", 3));
// PipelineExecutionException is thrown with cause having a message stating that a
@@ -1120,7 +1120,7 @@ public class ViewTest implements Serializable {
}));
// Pass at least one value through to guarantee that DoFn executes.
- DataflowAssert.that(output).containsInAnyOrder(KV.of("apple", 1));
+ PAssert.that(output).containsInAnyOrder(KV.of("apple", 1));
pipeline.run();
}
@@ -1144,7 +1144,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("apple", 21), KV.of("banana", 3), KV.of("blackberry", 3));
pipeline.run();
@@ -1178,7 +1178,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder("A1", "B5", "C1");
+ PAssert.that(output).containsInAnyOrder("A1", "B5", "C1");
p.run();
}
@@ -1211,7 +1211,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder("A6", "B6", "C6");
+ PAssert.that(output).containsInAnyOrder("A6", "B6", "C6");
p.run();
}
@@ -1242,7 +1242,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder("A0", "B5", "C0");
+ PAssert.that(output).containsInAnyOrder("A0", "B5", "C0");
p.run();
}
@@ -1272,7 +1272,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder("null");
+ PAssert.that(output).containsInAnyOrder("null");
p.run();
}
@@ -1317,7 +1317,7 @@ public class ViewTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(17);
+ PAssert.that(output).containsInAnyOrder(17);
pipeline.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithKeysTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithKeysTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithKeysTest.java
index 9216961..ca01a72 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithKeysTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithKeysTest.java
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
import com.google.cloud.dataflow.sdk.values.PCollection;
@@ -73,7 +73,7 @@ public class WithKeysTest {
PCollection<KV<Integer, String>> output = input.apply(WithKeys.of(
new LengthAsKey()));
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder(WITH_KEYS);
p.run();
@@ -89,7 +89,7 @@ public class WithKeysTest {
PCollection<KV<Integer, String>> output =
input.apply(WithKeys.<Integer, String>of(100));
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder(WITH_CONST_KEYS);
p.run();
@@ -110,7 +110,7 @@ public class WithKeysTest {
PCollection<KV<Integer, String>> output =
input.apply(WithKeys.of(new LengthAsKey()).withKeyType(TypeDescriptor.of(Integer.class)));
- DataflowAssert.that(output).containsInAnyOrder(WITH_KEYS);
+ PAssert.that(output).containsInAnyOrder(WITH_KEYS);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithTimestampsTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithTimestampsTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithTimestampsTest.java
index 54639af..6ccc85e 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithTimestampsTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithTimestampsTest.java
@@ -20,7 +20,7 @@ package com.google.cloud.dataflow.sdk.transforms;
import static org.hamcrest.Matchers.isA;
import com.google.cloud.dataflow.sdk.Pipeline.PipelineExecutionException;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -72,9 +72,9 @@ public class WithTimestampsTest implements Serializable {
}
}));
- DataflowAssert.that(timestamped)
+ PAssert.that(timestamped)
.containsInAnyOrder(yearTwoThousand, "0", "1234", Integer.toString(Integer.MAX_VALUE));
- DataflowAssert.that(timestampedVals)
+ PAssert.that(timestampedVals)
.containsInAnyOrder(
KV.of("0", new Instant(0)),
KV.of("1234", new Instant(1234L)),
@@ -156,9 +156,9 @@ public class WithTimestampsTest implements Serializable {
}
}));
- DataflowAssert.that(timestampedWithSkew)
+ PAssert.that(timestampedWithSkew)
.containsInAnyOrder(yearTwoThousand, "0", "1234", Integer.toString(Integer.MAX_VALUE));
- DataflowAssert.that(timestampedVals)
+ PAssert.that(timestampedVals)
.containsInAnyOrder(
KV.of("0", new Instant(0L).minus(skew)),
KV.of("1234", new Instant(1234L).minus(skew)),
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/join/CoGroupByKeyTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/join/CoGroupByKeyTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/join/CoGroupByKeyTest.java
index 251612e..e9bf3a6 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/join/CoGroupByKeyTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/join/CoGroupByKeyTest.java
@@ -25,7 +25,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.BigEndianIntegerCoder;
import com.google.cloud.dataflow.sdk.coders.KvCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -129,7 +129,7 @@ public class CoGroupByKeyTest implements Serializable {
PCollection<KV<Integer, CoGbkResult>> coGbkResults =
buildGetOnlyGbk(p, tag1, tag2);
- DataflowAssert.thatMap(coGbkResults).satisfies(
+ PAssert.thatMap(coGbkResults).satisfies(
new SerializableFunction<Map<Integer, CoGbkResult>, Void>() {
@Override
public Void apply(Map<Integer, CoGbkResult> results) {
@@ -266,7 +266,7 @@ public class CoGroupByKeyTest implements Serializable {
PCollection<KV<Integer, CoGbkResult>> coGbkResults =
buildPurchasesCoGbk(p, purchasesTag, addressesTag, namesTag);
- DataflowAssert.thatMap(coGbkResults).satisfies(
+ PAssert.thatMap(coGbkResults).satisfies(
new SerializableFunction<Map<Integer, CoGbkResult>, Void>() {
@Override
public Void apply(Map<Integer, CoGbkResult> results) {
@@ -466,7 +466,7 @@ public class CoGroupByKeyTest implements Serializable {
new CorrelatePurchaseCountForAddressesWithoutNamesFn(
purchasesTag, addressesTag, namesTag)));
- DataflowAssert.that(purchaseCountByKnownAddressesWithoutKnownNames)
+ PAssert.that(purchaseCountByKnownAddressesWithoutKnownNames)
.containsInAnyOrder(
KV.of("29 School Rd", 2),
KV.of("383 Jackson Street", 1));
@@ -491,7 +491,7 @@ public class CoGroupByKeyTest implements Serializable {
PCollection<KV<String, String>>
clickOfPurchase = coGbkResults.apply(ParDo.of(
new ClickOfPurchaseFn(clicksTag, purchasesTag)));
- DataflowAssert.that(clickOfPurchase)
+ PAssert.that(clickOfPurchase)
.containsInAnyOrder(
KV.of("Click t0:Boat t1", "0:3"),
KV.of("Click t0:Shoesi t2", "0:3"),
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/windowing/WindowingTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/windowing/WindowingTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/windowing/WindowingTest.java
index a5fb14c..1df0d96 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/windowing/WindowingTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/windowing/WindowingTest.java
@@ -20,7 +20,7 @@ package com.google.cloud.dataflow.sdk.transforms.windowing;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
import com.google.cloud.dataflow.sdk.io.TextIO;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Count;
@@ -103,7 +103,7 @@ public class WindowingTest implements Serializable {
input
.apply(new WindowedCount(FixedWindows.of(new Duration(10))));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
output("a", 1, 1, 0, 10),
output("b", 2, 2, 0, 10),
output("c", 1, 11, 10, 20),
@@ -128,7 +128,7 @@ public class WindowingTest implements Serializable {
.apply(new WindowedCount(
SlidingWindows.of(new Duration(10)).every(new Duration(5))));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
output("a", 1, 1, -5, 5),
output("a", 2, 5, 0, 10),
output("a", 1, 10, 5, 15),
@@ -153,7 +153,7 @@ public class WindowingTest implements Serializable {
input
.apply(new WindowedCount(Sessions.withGapDuration(new Duration(10))));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
output("a", 2, 1, 1, 15),
output("a", 1, 20, 20, 30));
@@ -181,7 +181,7 @@ public class WindowingTest implements Serializable {
.apply(Flatten.<String>pCollections())
.apply(new WindowedCount(FixedWindows.of(new Duration(5))));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
output("a", 2, 1, 0, 5),
output("b", 2, 2, 0, 5));
@@ -199,7 +199,7 @@ public class WindowingTest implements Serializable {
input
.apply(new WindowedCount(FixedWindows.of(new Duration(10))));
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
@@ -223,7 +223,7 @@ public class WindowingTest implements Serializable {
.apply(ParDo.of(new ExtractWordsWithTimestampsFn()))
.apply(new WindowedCount(FixedWindows.of(Duration.millis(10))));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
output("a", 1, 1, 0, 10),
output("b", 2, 2, 0, 10),
output("c", 1, 11, 10, 20),
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/util/ReshuffleTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/util/ReshuffleTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/util/ReshuffleTest.java
index dccef4f..7fafe0c 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/util/ReshuffleTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/util/ReshuffleTest.java
@@ -23,7 +23,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.KvCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
import com.google.cloud.dataflow.sdk.coders.VarIntCoder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -79,7 +79,7 @@ public class ReshuffleTest {
PCollection<KV<String, Integer>> output = input
.apply(Reshuffle.<String, Integer>of());
- DataflowAssert.that(output).containsInAnyOrder(ARBITRARY_KVS);
+ PAssert.that(output).containsInAnyOrder(ARBITRARY_KVS);
assertEquals(
input.getWindowingStrategy(),
@@ -103,7 +103,7 @@ public class ReshuffleTest {
PCollection<KV<String, Iterable<Integer>>> output = input
.apply(Reshuffle.<String, Iterable<Integer>>of());
- DataflowAssert.that(output).containsInAnyOrder(GROUPED_TESTABLE_KVS);
+ PAssert.that(output).containsInAnyOrder(GROUPED_TESTABLE_KVS);
assertEquals(
input.getWindowingStrategy(),
@@ -127,7 +127,7 @@ public class ReshuffleTest {
PCollection<KV<String, Iterable<Integer>>> output = input
.apply(Reshuffle.<String, Iterable<Integer>>of());
- DataflowAssert.that(output).containsInAnyOrder(GROUPED_TESTABLE_KVS);
+ PAssert.that(output).containsInAnyOrder(GROUPED_TESTABLE_KVS);
assertEquals(
input.getWindowingStrategy(),
@@ -151,7 +151,7 @@ public class ReshuffleTest {
PCollection<KV<String, Iterable<Integer>>> output = input
.apply(Reshuffle.<String, Iterable<Integer>>of());
- DataflowAssert.that(output).containsInAnyOrder(GROUPED_TESTABLE_KVS);
+ PAssert.that(output).containsInAnyOrder(GROUPED_TESTABLE_KVS);
assertEquals(
input.getWindowingStrategy(),
@@ -174,7 +174,7 @@ public class ReshuffleTest {
PCollection<KV<String, Integer>> output = input
.apply(Reshuffle.<String, Integer>of());
- DataflowAssert.that(output).containsInAnyOrder(ARBITRARY_KVS);
+ PAssert.that(output).containsInAnyOrder(ARBITRARY_KVS);
assertEquals(
input.getWindowingStrategy(),
@@ -198,7 +198,7 @@ public class ReshuffleTest {
PCollection<KV<String, Integer>> output = input
.apply(Reshuffle.<String, Integer>of());
- DataflowAssert.that(output).containsInAnyOrder(ARBITRARY_KVS);
+ PAssert.that(output).containsInAnyOrder(ARBITRARY_KVS);
assertEquals(
input.getWindowingStrategy(),
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/values/PCollectionTupleTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/values/PCollectionTupleTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/values/PCollectionTupleTest.java
index 9da1645..17d86b9 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/values/PCollectionTupleTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/values/PCollectionTupleTest.java
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -84,9 +84,9 @@ public final class PCollectionTupleTest implements Serializable {
assertNotNull("outputs.getPipeline()", outputs.getPipeline());
outputs = outputs.and(mainOutputTag, mainInput);
- DataflowAssert.that(outputs.get(mainOutputTag)).containsInAnyOrder(inputs);
- DataflowAssert.that(outputs.get(sideOutputTag)).containsInAnyOrder(inputs);
- DataflowAssert.that(outputs.get(emptyOutputTag)).empty();
+ PAssert.that(outputs.get(mainOutputTag)).containsInAnyOrder(inputs);
+ PAssert.that(outputs.get(sideOutputTag)).containsInAnyOrder(inputs);
+ PAssert.that(outputs.get(emptyOutputTag)).empty();
pipeline.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineJava8Test.java
----------------------------------------------------------------------
diff --git a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineJava8Test.java b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineJava8Test.java
index f04bb94..03709d9 100644
--- a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineJava8Test.java
+++ b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineJava8Test.java
@@ -18,7 +18,7 @@
package com.google.cloud.dataflow.sdk.transforms;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
import com.google.cloud.dataflow.sdk.values.PCollection;
@@ -71,7 +71,7 @@ public class CombineJava8Test implements Serializable {
return sum;
}));
- DataflowAssert.that(output).containsInAnyOrder(10);
+ PAssert.that(output).containsInAnyOrder(10);
pipeline.run();
}
@@ -86,7 +86,7 @@ public class CombineJava8Test implements Serializable {
.apply(Create.of(1, 2, 3, 4))
.apply(Combine.globally(new Summer()::sum));
- DataflowAssert.that(output).containsInAnyOrder(10);
+ PAssert.that(output).containsInAnyOrder(10);
pipeline.run();
}
@@ -107,7 +107,7 @@ public class CombineJava8Test implements Serializable {
return sum;
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("a", 4),
KV.of("b", 2),
KV.of("c", 4));
@@ -125,7 +125,7 @@ public class CombineJava8Test implements Serializable {
.apply(Create.of(KV.of("a", 1), KV.of("b", 2), KV.of("a", 3), KV.of("c", 4)))
.apply(Combine.perKey(new Summer()::sum));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("a", 4),
KV.of("b", 2),
KV.of("c", 4));
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/FilterJava8Test.java
----------------------------------------------------------------------
diff --git a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/FilterJava8Test.java b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/FilterJava8Test.java
index a38b434..7169468 100644
--- a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/FilterJava8Test.java
+++ b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/FilterJava8Test.java
@@ -19,7 +19,7 @@ package com.google.cloud.dataflow.sdk.transforms;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.CannotProvideCoderException;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.PCollection;
@@ -52,7 +52,7 @@ public class FilterJava8Test implements Serializable {
.apply(Create.of(591, 11789, 1257, 24578, 24799, 307))
.apply(Filter.byPredicate(i -> true));
- DataflowAssert.that(output).containsInAnyOrder(591, 11789, 1257, 24578, 24799, 307);
+ PAssert.that(output).containsInAnyOrder(591, 11789, 1257, 24578, 24799, 307);
pipeline.run();
}
@@ -64,7 +64,7 @@ public class FilterJava8Test implements Serializable {
.apply(Create.of(1, 2, 4, 5))
.apply(Filter.byPredicate(i -> false));
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
pipeline.run();
}
@@ -77,7 +77,7 @@ public class FilterJava8Test implements Serializable {
.apply(Create.of(1, 2, 3, 4, 5, 6, 7))
.apply(Filter.byPredicate(i -> i % 2 == 0));
- DataflowAssert.that(output).containsInAnyOrder(2, 4, 6);
+ PAssert.that(output).containsInAnyOrder(2, 4, 6);
pipeline.run();
}
@@ -107,7 +107,7 @@ public class FilterJava8Test implements Serializable {
.apply(Create.of(1, 2, 3, 4, 5, 6, 7))
.apply(Filter.byPredicate(new EvenFilter()::isEven));
- DataflowAssert.that(output).containsInAnyOrder(2, 4, 6);
+ PAssert.that(output).containsInAnyOrder(2, 4, 6);
pipeline.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlatMapElementsJava8Test.java
----------------------------------------------------------------------
diff --git a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlatMapElementsJava8Test.java b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlatMapElementsJava8Test.java
index fdf62f0..0fa8059 100644
--- a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlatMapElementsJava8Test.java
+++ b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlatMapElementsJava8Test.java
@@ -18,7 +18,7 @@
package com.google.cloud.dataflow.sdk.transforms;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.PCollection;
import com.google.cloud.dataflow.sdk.values.TypeDescriptor;
@@ -56,7 +56,7 @@ public class FlatMapElementsJava8Test implements Serializable {
.via((Integer i) -> ImmutableList.of(i, -i))
.withOutputType(new TypeDescriptor<Integer>() {}));
- DataflowAssert.that(output).containsInAnyOrder(1, 3, -1, -3, 2, -2);
+ PAssert.that(output).containsInAnyOrder(1, 3, -1, -3, 2, -2);
pipeline.run();
}
@@ -73,7 +73,7 @@ public class FlatMapElementsJava8Test implements Serializable {
.via(new Negater()::numAndNegation)
.withOutputType(new TypeDescriptor<Integer>() {}));
- DataflowAssert.that(output).containsInAnyOrder(1, 3, -1, -3, 2, -2);
+ PAssert.that(output).containsInAnyOrder(1, 3, -1, -3, 2, -2);
pipeline.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/MapElementsJava8Test.java
----------------------------------------------------------------------
diff --git a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/MapElementsJava8Test.java b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/MapElementsJava8Test.java
index 41b695e..4f0f232 100644
--- a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/MapElementsJava8Test.java
+++ b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/MapElementsJava8Test.java
@@ -18,7 +18,7 @@
package com.google.cloud.dataflow.sdk.transforms;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.PCollection;
import com.google.cloud.dataflow.sdk.values.TypeDescriptor;
@@ -49,7 +49,7 @@ public class MapElementsJava8Test implements Serializable {
.via((Integer i) -> i * 2)
.withOutputType(new TypeDescriptor<Integer>() {}));
- DataflowAssert.that(output).containsInAnyOrder(6, 2, 4);
+ PAssert.that(output).containsInAnyOrder(6, 2, 4);
pipeline.run();
}
@@ -66,7 +66,7 @@ public class MapElementsJava8Test implements Serializable {
.via(new Doubler()::doubleIt)
.withOutputType(new TypeDescriptor<Integer>() {}));
- DataflowAssert.that(output).containsInAnyOrder(6, 2, 4);
+ PAssert.that(output).containsInAnyOrder(6, 2, 4);
pipeline.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/PartitionJava8Test.java
----------------------------------------------------------------------
diff --git a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/PartitionJava8Test.java b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/PartitionJava8Test.java
index 82bd29c..938ea7f 100644
--- a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/PartitionJava8Test.java
+++ b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/PartitionJava8Test.java
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.CannotProvideCoderException;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.PCollectionList;
@@ -51,9 +51,9 @@ public class PartitionJava8Test implements Serializable {
.apply(Create.of(1, 2, 4, 5))
.apply(Partition.of(3, (element, numPartitions) -> element % numPartitions));
assertEquals(3, outputs.size());
- DataflowAssert.that(outputs.get(0)).empty();
- DataflowAssert.that(outputs.get(1)).containsInAnyOrder(1, 4);
- DataflowAssert.that(outputs.get(2)).containsInAnyOrder(2, 5);
+ PAssert.that(outputs.get(0)).empty();
+ PAssert.that(outputs.get(1)).containsInAnyOrder(1, 4);
+ PAssert.that(outputs.get(2)).containsInAnyOrder(2, 5);
pipeline.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/RemoveDuplicatesJava8Test.java
----------------------------------------------------------------------
diff --git a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/RemoveDuplicatesJava8Test.java b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/RemoveDuplicatesJava8Test.java
index d187abf..d987395 100644
--- a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/RemoveDuplicatesJava8Test.java
+++ b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/RemoveDuplicatesJava8Test.java
@@ -22,7 +22,7 @@ import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.PCollection;
import com.google.cloud.dataflow.sdk.values.TypeDescriptor;
@@ -62,7 +62,7 @@ public class RemoveDuplicatesJava8Test {
dupes.apply(RemoveDuplicates.withRepresentativeValueFn((String s) -> s.length())
.withRepresentativeType(TypeDescriptor.of(Integer.class)));
- DataflowAssert.that(deduped).satisfies((Iterable<String> strs) -> {
+ PAssert.that(deduped).satisfies((Iterable<String> strs) -> {
Set<Integer> seenLengths = new HashSet<>();
for (String s : strs) {
assertThat(predupedContents.values(), hasItem(s));
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithKeysJava8Test.java
----------------------------------------------------------------------
diff --git a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithKeysJava8Test.java b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithKeysJava8Test.java
index 9e22a91..a337935 100644
--- a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithKeysJava8Test.java
+++ b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithKeysJava8Test.java
@@ -18,7 +18,7 @@
package com.google.cloud.dataflow.sdk.transforms;
import com.google.cloud.dataflow.sdk.Pipeline.PipelineExecutionException;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -51,7 +51,7 @@ public class WithKeysJava8Test {
WithKeys.of((String s) -> Integer.valueOf(s))
.withKeyType(TypeDescriptor.of(Integer.class)));
- DataflowAssert.that(kvs).containsInAnyOrder(
+ PAssert.that(kvs).containsInAnyOrder(
KV.of(1234, "1234"), KV.of(0, "0"), KV.of(-12, "-12"), KV.of(3210, "3210"));
p.run();
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithTimestampsJava8Test.java
----------------------------------------------------------------------
diff --git a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithTimestampsJava8Test.java b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithTimestampsJava8Test.java
index 7cfa215..1a8a813 100644
--- a/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithTimestampsJava8Test.java
+++ b/sdks/java/java8tests/src/test/java/com/google/cloud/dataflow/sdk/transforms/WithTimestampsJava8Test.java
@@ -17,7 +17,7 @@
*/
package com.google.cloud.dataflow.sdk.transforms;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -55,9 +55,9 @@ public class WithTimestampsJava8Test implements Serializable {
}
}));
- DataflowAssert.that(timestamped)
+ PAssert.that(timestamped)
.containsInAnyOrder(yearTwoThousand, "0", "1234", Integer.toString(Integer.MAX_VALUE));
- DataflowAssert.that(timestampedVals)
+ PAssert.that(timestampedVals)
.containsInAnyOrder(
KV.of("0", new Instant(0)),
KV.of("1234", new Instant("1234")),
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/pom.xml b/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/pom.xml
index 5a03522..6acac43 100644
--- a/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/pom.xml
+++ b/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/pom.xml
@@ -188,7 +188,7 @@
<scope>runtime</scope>
</dependency>
- <!-- Hamcrest and JUnit are required dependencies of DataflowAssert,
+ <!-- Hamcrest and JUnit are required dependencies of PAssert,
which is used in the main code of DebuggingWordCount example. -->
<dependency>
<groupId>org.hamcrest</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/src/main/java/DebuggingWordCount.java
----------------------------------------------------------------------
diff --git a/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/src/main/java/DebuggingWordCount.java b/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/src/main/java/DebuggingWordCount.java
index 32fca4e..bd63b75 100644
--- a/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/src/main/java/DebuggingWordCount.java
+++ b/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/src/main/java/DebuggingWordCount.java
@@ -23,7 +23,7 @@ import com.google.cloud.dataflow.sdk.io.TextIO;
import com.google.cloud.dataflow.sdk.options.Default;
import com.google.cloud.dataflow.sdk.options.Description;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.Aggregator;
import com.google.cloud.dataflow.sdk.transforms.DoFn;
import com.google.cloud.dataflow.sdk.transforms.ParDo;
@@ -56,7 +56,7 @@ import java.util.regex.Pattern;
* 1. Logging to Cloud Logging
* 2. Controlling Dataflow worker log levels
* 3. Creating a custom aggregator
- * 4. Testing your Pipeline via DataflowAssert
+ * 4. Testing your Pipeline via PAssert
* </pre>
*
* <p>To execute this pipeline locally, specify general pipeline configuration:
@@ -179,13 +179,13 @@ public class DebuggingWordCount {
.apply(ParDo.of(new FilterTextFn(options.getFilterPattern())));
/**
- * Concept #4: DataflowAssert is a set of convenient PTransforms in the style of
+ * Concept #4: PAssert is a set of convenient PTransforms in the style of
* Hamcrest's collection matchers that can be used when writing Pipeline level tests
- * to validate the contents of PCollections. DataflowAssert is best used in unit tests
+ * to validate the contents of PCollections. PAssert is best used in unit tests
* with small data sets but is demonstrated here as a teaching tool.
*
* <p>Below we verify that the set of filtered words matches our expected counts. Note
- * that DataflowAssert does not provide any output and that successful completion of the
+ * that PAssert does not provide any output and that successful completion of the
* Pipeline implies that the expectations were met. Learn more at
* https://cloud.google.com/dataflow/pipelines/testing-your-pipeline on how to test
* your Pipeline and see {@link DebuggingWordCountTest} for an example unit test.
@@ -193,7 +193,7 @@ public class DebuggingWordCount {
List<KV<String, Long>> expectedResults = Arrays.asList(
KV.of("Flourish", 3L),
KV.of("stomach", 1L));
- DataflowAssert.that(filteredWords).containsInAnyOrder(expectedResults);
+ PAssert.that(filteredWords).containsInAnyOrder(expectedResults);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/src/test/java/WordCountTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/src/test/java/WordCountTest.java b/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/src/test/java/WordCountTest.java
index a28073f..b3319b6 100644
--- a/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/src/test/java/WordCountTest.java
+++ b/sdks/java/maven-archetypes/examples/src/main/resources/archetype-resources/src/test/java/WordCountTest.java
@@ -22,7 +22,7 @@ import ${package}.WordCount.ExtractWordsFn;
import ${package}.WordCount.FormatAsTextFn;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -80,7 +80,7 @@ public class WordCountTest {
PCollection<String> output = input.apply(new CountWords())
.apply(ParDo.of(new FormatAsTextFn()));
- DataflowAssert.that(output).containsInAnyOrder(COUNTS_ARRAY);
+ PAssert.that(output).containsInAnyOrder(COUNTS_ARRAY);
p.run();
}
}
[5/5] incubator-beam git commit: This closes #146
Posted by da...@apache.org.
This closes #146
Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/529bcdf5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/529bcdf5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/529bcdf5
Branch: refs/heads/master
Commit: 529bcdf5688139ae76bcbcaa1c0dbbf44c3008bc
Parents: 5f24cef d73ceab
Author: Davor Bonaci <da...@google.com>
Authored: Fri Apr 8 13:55:07 2016 -0700
Committer: Davor Bonaci <da...@google.com>
Committed: Fri Apr 8 13:55:07 2016 -0700
----------------------------------------------------------------------
.../contrib/joinlibrary/InnerJoinTest.java | 10 +-
.../contrib/joinlibrary/OuterLeftJoinTest.java | 10 +-
.../contrib/joinlibrary/OuterRightJoinTest.java | 10 +-
examples/java/pom.xml | 2 +-
.../dataflow/examples/DebuggingWordCount.java | 12 +-
.../cloud/dataflow/examples/WordCountTest.java | 4 +-
.../examples/complete/AutoCompleteTest.java | 8 +-
.../dataflow/examples/complete/TfIdfTest.java | 4 +-
.../complete/TopWikipediaSessionsTest.java | 4 +-
.../examples/cookbook/DeDupExampleTest.java | 6 +-
.../examples/cookbook/JoinExamplesTest.java | 4 +-
.../examples/cookbook/TriggerExampleTest.java | 4 +-
.../examples/complete/game/GameStatsTest.java | 4 +-
.../complete/game/HourlyTeamScoreTest.java | 4 +-
.../examples/complete/game/UserScoreTest.java | 8 +-
.../beam/runners/flink/FlinkTestPipeline.java | 6 +-
.../streaming/StreamingTransformTranslator.java | 4 +-
.../apache/beam/runners/spark/DeDupTest.java | 4 +-
.../beam/runners/spark/SimpleWordCountTest.java | 4 +-
.../apache/beam/runners/spark/TfIdfTest.java | 4 +-
.../spark/translation/DoFnOutputTest.java | 4 +-
.../translation/MultiOutputWordCountTest.java | 4 +-
.../spark/translation/SerializationTest.java | 4 +-
.../translation/WindowedWordCountTest.java | 8 +-
.../streaming/FlattenStreamingTest.java | 8 +-
.../streaming/KafkaStreamingTest.java | 8 +-
.../streaming/SimpleStreamingWordCountTest.java | 8 +-
.../utils/DataflowAssertStreaming.java | 42 -
.../streaming/utils/PAssertStreaming.java | 42 +
.../dataflow/sdk/testing/DataflowAssert.java | 826 -------------------
.../cloud/dataflow/sdk/testing/PAssert.java | 825 ++++++++++++++++++
.../sdk/testing/SerializableMatcher.java | 2 +-
.../dataflow/sdk/testing/SourceTestUtils.java | 2 +-
.../sdk/testing/TestDataflowPipelineRunner.java | 8 +-
.../dataflow/sdk/testing/TestPipeline.java | 6 +-
.../google/cloud/dataflow/sdk/PipelineTest.java | 10 +-
.../dataflow/sdk/coders/AvroCoderTest.java | 4 +-
.../sdk/coders/SerializableCoderTest.java | 4 +-
.../cloud/dataflow/sdk/io/AvroIOTest.java | 6 +-
.../io/BoundedReadFromUnboundedSourceTest.java | 4 +-
.../dataflow/sdk/io/CompressedSourceTest.java | 10 +-
.../dataflow/sdk/io/CountingInputTest.java | 12 +-
.../dataflow/sdk/io/CountingSourceTest.java | 14 +-
.../dataflow/sdk/io/FileBasedSourceTest.java | 6 +-
.../cloud/dataflow/sdk/io/TextIOTest.java | 8 +-
.../cloud/dataflow/sdk/io/XmlSourceTest.java | 8 +-
.../sdk/io/bigtable/BigtableIOTest.java | 8 +-
.../sdk/runners/dataflow/CustomSourcesTest.java | 6 +-
.../runners/inprocess/InProcessCreateTest.java | 8 +-
.../inprocess/InProcessPipelineRunnerTest.java | 4 +-
.../sdk/testing/DataflowAssertTest.java | 327 --------
.../cloud/dataflow/sdk/testing/PAssertTest.java | 331 ++++++++
.../testing/TestDataflowPipelineRunnerTest.java | 24 +-
.../transforms/ApproximateQuantilesTest.java | 10 +-
.../sdk/transforms/ApproximateUniqueTest.java | 12 +-
.../dataflow/sdk/transforms/CombineFnsTest.java | 12 +-
.../dataflow/sdk/transforms/CombineTest.java | 66 +-
.../dataflow/sdk/transforms/CountTest.java | 10 +-
.../dataflow/sdk/transforms/CreateTest.java | 18 +-
.../dataflow/sdk/transforms/FilterTest.java | 18 +-
.../sdk/transforms/FlatMapElementsTest.java | 4 +-
.../dataflow/sdk/transforms/FlattenTest.java | 22 +-
.../dataflow/sdk/transforms/GroupByKeyTest.java | 8 +-
.../cloud/dataflow/sdk/transforms/KeysTest.java | 6 +-
.../dataflow/sdk/transforms/KvSwapTest.java | 6 +-
.../sdk/transforms/MapElementsTest.java | 6 +-
.../dataflow/sdk/transforms/ParDoTest.java | 66 +-
.../dataflow/sdk/transforms/PartitionTest.java | 14 +-
.../sdk/transforms/RemoveDuplicatesTest.java | 8 +-
.../dataflow/sdk/transforms/SampleTest.java | 14 +-
.../cloud/dataflow/sdk/transforms/TopTest.java | 32 +-
.../dataflow/sdk/transforms/ValuesTest.java | 6 +-
.../cloud/dataflow/sdk/transforms/ViewTest.java | 72 +-
.../dataflow/sdk/transforms/WithKeysTest.java | 8 +-
.../sdk/transforms/WithTimestampsTest.java | 10 +-
.../sdk/transforms/join/CoGroupByKeyTest.java | 10 +-
.../sdk/transforms/windowing/WindowingTest.java | 14 +-
.../cloud/dataflow/sdk/util/ReshuffleTest.java | 14 +-
.../sdk/values/PCollectionTupleTest.java | 8 +-
.../sdk/transforms/CombineJava8Test.java | 10 +-
.../sdk/transforms/FilterJava8Test.java | 10 +-
.../transforms/FlatMapElementsJava8Test.java | 6 +-
.../sdk/transforms/MapElementsJava8Test.java | 6 +-
.../sdk/transforms/PartitionJava8Test.java | 8 +-
.../transforms/RemoveDuplicatesJava8Test.java | 4 +-
.../sdk/transforms/WithKeysJava8Test.java | 4 +-
.../sdk/transforms/WithTimestampsJava8Test.java | 6 +-
.../main/resources/archetype-resources/pom.xml | 2 +-
.../src/main/java/DebuggingWordCount.java | 12 +-
.../src/test/java/WordCountTest.java | 4 +-
90 files changed, 1628 insertions(+), 1625 deletions(-)
----------------------------------------------------------------------
[4/5] incubator-beam git commit: Rename DataflowAssert to PAssert
Posted by da...@apache.org.
Rename DataflowAssert to PAssert
Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/d73ceab8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/d73ceab8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/d73ceab8
Branch: refs/heads/master
Commit: d73ceab8bc0a3f8479882bd689015fd7f869758b
Parents: 5f24cef
Author: Thomas Groh <tg...@google.com>
Authored: Thu Apr 7 15:53:15 2016 -0700
Committer: Davor Bonaci <da...@google.com>
Committed: Fri Apr 8 13:55:01 2016 -0700
----------------------------------------------------------------------
.../contrib/joinlibrary/InnerJoinTest.java | 10 +-
.../contrib/joinlibrary/OuterLeftJoinTest.java | 10 +-
.../contrib/joinlibrary/OuterRightJoinTest.java | 10 +-
examples/java/pom.xml | 2 +-
.../dataflow/examples/DebuggingWordCount.java | 12 +-
.../cloud/dataflow/examples/WordCountTest.java | 4 +-
.../examples/complete/AutoCompleteTest.java | 8 +-
.../dataflow/examples/complete/TfIdfTest.java | 4 +-
.../complete/TopWikipediaSessionsTest.java | 4 +-
.../examples/cookbook/DeDupExampleTest.java | 6 +-
.../examples/cookbook/JoinExamplesTest.java | 4 +-
.../examples/cookbook/TriggerExampleTest.java | 4 +-
.../examples/complete/game/GameStatsTest.java | 4 +-
.../complete/game/HourlyTeamScoreTest.java | 4 +-
.../examples/complete/game/UserScoreTest.java | 8 +-
.../beam/runners/flink/FlinkTestPipeline.java | 6 +-
.../streaming/StreamingTransformTranslator.java | 4 +-
.../apache/beam/runners/spark/DeDupTest.java | 4 +-
.../beam/runners/spark/SimpleWordCountTest.java | 4 +-
.../apache/beam/runners/spark/TfIdfTest.java | 4 +-
.../spark/translation/DoFnOutputTest.java | 4 +-
.../translation/MultiOutputWordCountTest.java | 4 +-
.../spark/translation/SerializationTest.java | 4 +-
.../translation/WindowedWordCountTest.java | 8 +-
.../streaming/FlattenStreamingTest.java | 8 +-
.../streaming/KafkaStreamingTest.java | 8 +-
.../streaming/SimpleStreamingWordCountTest.java | 8 +-
.../utils/DataflowAssertStreaming.java | 42 -
.../streaming/utils/PAssertStreaming.java | 42 +
.../dataflow/sdk/testing/DataflowAssert.java | 826 -------------------
.../cloud/dataflow/sdk/testing/PAssert.java | 825 ++++++++++++++++++
.../sdk/testing/SerializableMatcher.java | 2 +-
.../dataflow/sdk/testing/SourceTestUtils.java | 2 +-
.../sdk/testing/TestDataflowPipelineRunner.java | 8 +-
.../dataflow/sdk/testing/TestPipeline.java | 6 +-
.../google/cloud/dataflow/sdk/PipelineTest.java | 10 +-
.../dataflow/sdk/coders/AvroCoderTest.java | 4 +-
.../sdk/coders/SerializableCoderTest.java | 4 +-
.../cloud/dataflow/sdk/io/AvroIOTest.java | 6 +-
.../io/BoundedReadFromUnboundedSourceTest.java | 4 +-
.../dataflow/sdk/io/CompressedSourceTest.java | 10 +-
.../dataflow/sdk/io/CountingInputTest.java | 12 +-
.../dataflow/sdk/io/CountingSourceTest.java | 14 +-
.../dataflow/sdk/io/FileBasedSourceTest.java | 6 +-
.../cloud/dataflow/sdk/io/TextIOTest.java | 8 +-
.../cloud/dataflow/sdk/io/XmlSourceTest.java | 8 +-
.../sdk/io/bigtable/BigtableIOTest.java | 8 +-
.../sdk/runners/dataflow/CustomSourcesTest.java | 6 +-
.../runners/inprocess/InProcessCreateTest.java | 8 +-
.../inprocess/InProcessPipelineRunnerTest.java | 4 +-
.../sdk/testing/DataflowAssertTest.java | 327 --------
.../cloud/dataflow/sdk/testing/PAssertTest.java | 331 ++++++++
.../testing/TestDataflowPipelineRunnerTest.java | 24 +-
.../transforms/ApproximateQuantilesTest.java | 10 +-
.../sdk/transforms/ApproximateUniqueTest.java | 12 +-
.../dataflow/sdk/transforms/CombineFnsTest.java | 12 +-
.../dataflow/sdk/transforms/CombineTest.java | 66 +-
.../dataflow/sdk/transforms/CountTest.java | 10 +-
.../dataflow/sdk/transforms/CreateTest.java | 18 +-
.../dataflow/sdk/transforms/FilterTest.java | 18 +-
.../sdk/transforms/FlatMapElementsTest.java | 4 +-
.../dataflow/sdk/transforms/FlattenTest.java | 22 +-
.../dataflow/sdk/transforms/GroupByKeyTest.java | 8 +-
.../cloud/dataflow/sdk/transforms/KeysTest.java | 6 +-
.../dataflow/sdk/transforms/KvSwapTest.java | 6 +-
.../sdk/transforms/MapElementsTest.java | 6 +-
.../dataflow/sdk/transforms/ParDoTest.java | 66 +-
.../dataflow/sdk/transforms/PartitionTest.java | 14 +-
.../sdk/transforms/RemoveDuplicatesTest.java | 8 +-
.../dataflow/sdk/transforms/SampleTest.java | 14 +-
.../cloud/dataflow/sdk/transforms/TopTest.java | 32 +-
.../dataflow/sdk/transforms/ValuesTest.java | 6 +-
.../cloud/dataflow/sdk/transforms/ViewTest.java | 72 +-
.../dataflow/sdk/transforms/WithKeysTest.java | 8 +-
.../sdk/transforms/WithTimestampsTest.java | 10 +-
.../sdk/transforms/join/CoGroupByKeyTest.java | 10 +-
.../sdk/transforms/windowing/WindowingTest.java | 14 +-
.../cloud/dataflow/sdk/util/ReshuffleTest.java | 14 +-
.../sdk/values/PCollectionTupleTest.java | 8 +-
.../sdk/transforms/CombineJava8Test.java | 10 +-
.../sdk/transforms/FilterJava8Test.java | 10 +-
.../transforms/FlatMapElementsJava8Test.java | 6 +-
.../sdk/transforms/MapElementsJava8Test.java | 6 +-
.../sdk/transforms/PartitionJava8Test.java | 8 +-
.../transforms/RemoveDuplicatesJava8Test.java | 4 +-
.../sdk/transforms/WithKeysJava8Test.java | 4 +-
.../sdk/transforms/WithTimestampsJava8Test.java | 6 +-
.../main/resources/archetype-resources/pom.xml | 2 +-
.../src/main/java/DebuggingWordCount.java | 12 +-
.../src/test/java/WordCountTest.java | 4 +-
90 files changed, 1628 insertions(+), 1625 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/InnerJoinTest.java
----------------------------------------------------------------------
diff --git a/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/InnerJoinTest.java b/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/InnerJoinTest.java
index 067ffb6..c479a65 100644
--- a/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/InnerJoinTest.java
+++ b/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/InnerJoinTest.java
@@ -18,7 +18,7 @@
package com.google.cloud.dataflow.contrib.joinlibrary;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -67,7 +67,7 @@ public class InnerJoinTest {
expectedResult.add(KV.of("Key1", KV.of(5L, "foo")));
expectedResult.add(KV.of("Key2", KV.of(4L, "bar")));
- DataflowAssert.that(output).containsInAnyOrder(expectedResult);
+ PAssert.that(output).containsInAnyOrder(expectedResult);
p.run();
}
@@ -88,7 +88,7 @@ public class InnerJoinTest {
expectedResult.add(KV.of("Key2", KV.of(4L, "bar")));
expectedResult.add(KV.of("Key2", KV.of(4L, "gazonk")));
- DataflowAssert.that(output).containsInAnyOrder(expectedResult);
+ PAssert.that(output).containsInAnyOrder(expectedResult);
p.run();
}
@@ -109,7 +109,7 @@ public class InnerJoinTest {
expectedResult.add(KV.of("Key2", KV.of(4L, "bar")));
expectedResult.add(KV.of("Key2", KV.of(6L, "bar")));
- DataflowAssert.that(output).containsInAnyOrder(expectedResult);
+ PAssert.that(output).containsInAnyOrder(expectedResult);
p.run();
}
@@ -127,7 +127,7 @@ public class InnerJoinTest {
PCollection<KV<String, KV<Long, String>>> output = Join.innerJoin(
leftCollection, rightCollection);
- DataflowAssert.that(output).containsInAnyOrder(expectedResult);
+ PAssert.that(output).containsInAnyOrder(expectedResult);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/OuterLeftJoinTest.java
----------------------------------------------------------------------
diff --git a/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/OuterLeftJoinTest.java b/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/OuterLeftJoinTest.java
index 90e4606..35c8655 100644
--- a/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/OuterLeftJoinTest.java
+++ b/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/OuterLeftJoinTest.java
@@ -18,7 +18,7 @@
package com.google.cloud.dataflow.contrib.joinlibrary;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -68,7 +68,7 @@ public class OuterLeftJoinTest {
expectedResult.add(KV.of("Key1", KV.of(5L, "foo")));
expectedResult.add(KV.of("Key2", KV.of(4L, "bar")));
- DataflowAssert.that(output).containsInAnyOrder(expectedResult);
+ PAssert.that(output).containsInAnyOrder(expectedResult);
p.run();
}
@@ -89,7 +89,7 @@ public class OuterLeftJoinTest {
expectedResult.add(KV.of("Key2", KV.of(4L, "bar")));
expectedResult.add(KV.of("Key2", KV.of(4L, "gazonk")));
- DataflowAssert.that(output).containsInAnyOrder(expectedResult);
+ PAssert.that(output).containsInAnyOrder(expectedResult);
p.run();
}
@@ -110,7 +110,7 @@ public class OuterLeftJoinTest {
expectedResult.add(KV.of("Key2", KV.of(4L, "bar")));
expectedResult.add(KV.of("Key2", KV.of(6L, "bar")));
- DataflowAssert.that(output).containsInAnyOrder(expectedResult);
+ PAssert.that(output).containsInAnyOrder(expectedResult);
p.run();
}
@@ -129,7 +129,7 @@ public class OuterLeftJoinTest {
leftCollection, rightCollection, "");
expectedResult.add(KV.of("Key2", KV.of(4L, "")));
- DataflowAssert.that(output).containsInAnyOrder(expectedResult);
+ PAssert.that(output).containsInAnyOrder(expectedResult);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/OuterRightJoinTest.java
----------------------------------------------------------------------
diff --git a/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/OuterRightJoinTest.java b/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/OuterRightJoinTest.java
index fe785d7..9cc6785 100644
--- a/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/OuterRightJoinTest.java
+++ b/contrib/join-library/src/test/java/com/google/cloud/dataflow/contrib/joinlibrary/OuterRightJoinTest.java
@@ -18,7 +18,7 @@
package com.google.cloud.dataflow.contrib.joinlibrary;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -68,7 +68,7 @@ public class OuterRightJoinTest {
expectedResult.add(KV.of("Key1", KV.of(5L, "foo")));
expectedResult.add(KV.of("Key2", KV.of(4L, "bar")));
- DataflowAssert.that(output).containsInAnyOrder(expectedResult);
+ PAssert.that(output).containsInAnyOrder(expectedResult);
p.run();
}
@@ -89,7 +89,7 @@ public class OuterRightJoinTest {
expectedResult.add(KV.of("Key2", KV.of(4L, "bar")));
expectedResult.add(KV.of("Key2", KV.of(4L, "gazonk")));
- DataflowAssert.that(output).containsInAnyOrder(expectedResult);
+ PAssert.that(output).containsInAnyOrder(expectedResult);
p.run();
}
@@ -110,7 +110,7 @@ public class OuterRightJoinTest {
expectedResult.add(KV.of("Key2", KV.of(4L, "bar")));
expectedResult.add(KV.of("Key2", KV.of(6L, "bar")));
- DataflowAssert.that(output).containsInAnyOrder(expectedResult);
+ PAssert.that(output).containsInAnyOrder(expectedResult);
p.run();
}
@@ -129,7 +129,7 @@ public class OuterRightJoinTest {
leftCollection, rightCollection, -1L);
expectedResult.add(KV.of("Key3", KV.of(-1L, "bar")));
- DataflowAssert.that(output).containsInAnyOrder(expectedResult);
+ PAssert.that(output).containsInAnyOrder(expectedResult);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/examples/java/pom.xml
----------------------------------------------------------------------
diff --git a/examples/java/pom.xml b/examples/java/pom.xml
index 2e158cb..d63ac23 100644
--- a/examples/java/pom.xml
+++ b/examples/java/pom.xml
@@ -369,7 +369,7 @@
<version>3.1.0</version>
</dependency>
- <!-- Hamcrest and JUnit are required dependencies of DataflowAssert,
+ <!-- Hamcrest and JUnit are required dependencies of PAssert,
which is used in the main code of DebuggingWordCount example. -->
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/examples/java/src/main/java/com/google/cloud/dataflow/examples/DebuggingWordCount.java
----------------------------------------------------------------------
diff --git a/examples/java/src/main/java/com/google/cloud/dataflow/examples/DebuggingWordCount.java b/examples/java/src/main/java/com/google/cloud/dataflow/examples/DebuggingWordCount.java
index 331d7c6..7134bca 100644
--- a/examples/java/src/main/java/com/google/cloud/dataflow/examples/DebuggingWordCount.java
+++ b/examples/java/src/main/java/com/google/cloud/dataflow/examples/DebuggingWordCount.java
@@ -22,7 +22,7 @@ import com.google.cloud.dataflow.sdk.io.TextIO;
import com.google.cloud.dataflow.sdk.options.Default;
import com.google.cloud.dataflow.sdk.options.Description;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.Aggregator;
import com.google.cloud.dataflow.sdk.transforms.DoFn;
import com.google.cloud.dataflow.sdk.transforms.ParDo;
@@ -55,7 +55,7 @@ import java.util.regex.Pattern;
* 1. Logging to Cloud Logging
* 2. Controlling Dataflow worker log levels
* 3. Creating a custom aggregator
- * 4. Testing your Pipeline via DataflowAssert
+ * 4. Testing your Pipeline via PAssert
* </pre>
*
* <p>To execute this pipeline locally, specify general pipeline configuration:
@@ -178,13 +178,13 @@ public class DebuggingWordCount {
.apply(ParDo.of(new FilterTextFn(options.getFilterPattern())));
/**
- * Concept #4: DataflowAssert is a set of convenient PTransforms in the style of
+ * Concept #4: PAssert is a set of convenient PTransforms in the style of
* Hamcrest's collection matchers that can be used when writing Pipeline level tests
- * to validate the contents of PCollections. DataflowAssert is best used in unit tests
+ * to validate the contents of PCollections. PAssert is best used in unit tests
* with small data sets but is demonstrated here as a teaching tool.
*
* <p>Below we verify that the set of filtered words matches our expected counts. Note
- * that DataflowAssert does not provide any output and that successful completion of the
+ * that PAssert does not provide any output and that successful completion of the
* Pipeline implies that the expectations were met. Learn more at
* https://cloud.google.com/dataflow/pipelines/testing-your-pipeline on how to test
* your Pipeline and see {@link DebuggingWordCountTest} for an example unit test.
@@ -192,7 +192,7 @@ public class DebuggingWordCount {
List<KV<String, Long>> expectedResults = Arrays.asList(
KV.of("Flourish", 3L),
KV.of("stomach", 1L));
- DataflowAssert.that(filteredWords).containsInAnyOrder(expectedResults);
+ PAssert.that(filteredWords).containsInAnyOrder(expectedResults);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/examples/java/src/test/java/com/google/cloud/dataflow/examples/WordCountTest.java
----------------------------------------------------------------------
diff --git a/examples/java/src/test/java/com/google/cloud/dataflow/examples/WordCountTest.java b/examples/java/src/test/java/com/google/cloud/dataflow/examples/WordCountTest.java
index 8121d70..b1f4f27 100644
--- a/examples/java/src/test/java/com/google/cloud/dataflow/examples/WordCountTest.java
+++ b/examples/java/src/test/java/com/google/cloud/dataflow/examples/WordCountTest.java
@@ -22,7 +22,7 @@ import com.google.cloud.dataflow.examples.WordCount.ExtractWordsFn;
import com.google.cloud.dataflow.examples.WordCount.FormatAsTextFn;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -80,7 +80,7 @@ public class WordCountTest {
PCollection<String> output = input.apply(new CountWords())
.apply(MapElements.via(new FormatAsTextFn()));
- DataflowAssert.that(output).containsInAnyOrder(COUNTS_ARRAY);
+ PAssert.that(output).containsInAnyOrder(COUNTS_ARRAY);
p.run();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/AutoCompleteTest.java
----------------------------------------------------------------------
diff --git a/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/AutoCompleteTest.java b/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/AutoCompleteTest.java
index d29a039..a70aee1 100644
--- a/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/AutoCompleteTest.java
+++ b/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/AutoCompleteTest.java
@@ -20,7 +20,7 @@ package com.google.cloud.dataflow.examples.complete;
import com.google.cloud.dataflow.examples.complete.AutoComplete.CompletionCandidate;
import com.google.cloud.dataflow.examples.complete.AutoComplete.ComputeTopCompletions;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.transforms.DoFn;
@@ -93,7 +93,7 @@ public class AutoCompleteTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("a", parseList("apple:2", "apricot:1")),
KV.of("ap", parseList("apple:2", "apricot:1")),
KV.of("b", parseList("blackberry:3", "blueberry:2")),
@@ -115,7 +115,7 @@ public class AutoCompleteTest implements Serializable {
PCollection<KV<String, List<CompletionCandidate>>> output =
input.apply(new ComputeTopCompletions(2, recursive));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of("x", parseList("x:3", "xy:2")),
KV.of("xy", parseList("xy:2", "xyz:1")),
KV.of("xyz", parseList("xyz:1")));
@@ -141,7 +141,7 @@ public class AutoCompleteTest implements Serializable {
input.apply(Window.<String>into(SlidingWindows.of(new Duration(2))))
.apply(new ComputeTopCompletions(2, recursive));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
// Window [0, 2)
KV.of("x", parseList("xA:2", "xB:1")),
KV.of("xA", parseList("xA:2")),
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/TfIdfTest.java
----------------------------------------------------------------------
diff --git a/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/TfIdfTest.java b/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/TfIdfTest.java
index 5f991ad..5989ce8 100644
--- a/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/TfIdfTest.java
+++ b/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/TfIdfTest.java
@@ -19,7 +19,7 @@ package com.google.cloud.dataflow.examples.complete;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringDelegateCoder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -61,7 +61,7 @@ public class TfIdfTest {
.apply(Keys.<String>create())
.apply(RemoveDuplicates.<String>create());
- DataflowAssert.that(words).containsInAnyOrder(Arrays.asList("a", "m", "n", "b", "c", "d"));
+ PAssert.that(words).containsInAnyOrder(Arrays.asList("a", "m", "n", "b", "c", "d"));
pipeline.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/TopWikipediaSessionsTest.java
----------------------------------------------------------------------
diff --git a/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/TopWikipediaSessionsTest.java b/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/TopWikipediaSessionsTest.java
index 872b8e3..52f69b0 100644
--- a/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/TopWikipediaSessionsTest.java
+++ b/examples/java/src/test/java/com/google/cloud/dataflow/examples/complete/TopWikipediaSessionsTest.java
@@ -19,7 +19,7 @@ package com.google.cloud.dataflow.examples.complete;
import com.google.api.services.bigquery.model.TableRow;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -52,7 +52,7 @@ public class TopWikipediaSessionsTest {
new TableRow().set("timestamp", 35 * 24 * 3600).set("contributor_username", "user3"))))
.apply(new TopWikipediaSessions.ComputeTopSessions(1.0));
- DataflowAssert.that(output).containsInAnyOrder(Arrays.asList(
+ PAssert.that(output).containsInAnyOrder(Arrays.asList(
"user1 : [1970-01-01T00:00:00.000Z..1970-01-01T01:00:02.000Z)"
+ " : 3 : 1970-01-01T00:00:00.000Z",
"user3 : [1970-02-05T00:00:00.000Z..1970-02-05T01:00:00.000Z)"
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/DeDupExampleTest.java
----------------------------------------------------------------------
diff --git a/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/DeDupExampleTest.java b/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/DeDupExampleTest.java
index ee1859f..6e9e3ed 100644
--- a/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/DeDupExampleTest.java
+++ b/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/DeDupExampleTest.java
@@ -19,7 +19,7 @@ package com.google.cloud.dataflow.examples.cookbook;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -59,7 +59,7 @@ public class DeDupExampleTest {
PCollection<String> output =
input.apply(RemoveDuplicates.<String>create());
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder("k1", "k5", "k2", "k3");
p.run();
}
@@ -78,7 +78,7 @@ public class DeDupExampleTest {
PCollection<String> output =
input.apply(RemoveDuplicates.<String>create());
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/JoinExamplesTest.java
----------------------------------------------------------------------
diff --git a/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/JoinExamplesTest.java b/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/JoinExamplesTest.java
index a7a0eda..259ce08 100644
--- a/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/JoinExamplesTest.java
+++ b/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/JoinExamplesTest.java
@@ -21,7 +21,7 @@ import com.google.api.services.bigquery.model.TableRow;
import com.google.cloud.dataflow.examples.cookbook.JoinExamples.ExtractCountryInfoFn;
import com.google.cloud.dataflow.examples.cookbook.JoinExamples.ExtractEventDataFn;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -109,7 +109,7 @@ public class JoinExamplesTest {
PCollection<TableRow> input2 = p.apply("CreateCC", Create.of(CC_ARRAY));
PCollection<String> output = JoinExamples.joinEvents(input1, input2);
- DataflowAssert.that(output).containsInAnyOrder(JOINED_EVENTS);
+ PAssert.that(output).containsInAnyOrder(JOINED_EVENTS);
p.run();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/TriggerExampleTest.java
----------------------------------------------------------------------
diff --git a/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/TriggerExampleTest.java b/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/TriggerExampleTest.java
index e3f26ff..3664561 100644
--- a/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/TriggerExampleTest.java
+++ b/examples/java/src/test/java/com/google/cloud/dataflow/examples/cookbook/TriggerExampleTest.java
@@ -21,7 +21,7 @@ import com.google.api.services.bigquery.model.TableRow;
import com.google.cloud.dataflow.examples.cookbook.TriggerExample.ExtractFlowInfo;
import com.google.cloud.dataflow.examples.cookbook.TriggerExample.TotalFlow;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -114,7 +114,7 @@ public class TriggerExampleTest {
PCollection<TableRow> results = totalFlow.apply(ParDo.of(new FormatResults()));
- DataflowAssert.that(results).containsInAnyOrder(OUT_ROW_1, OUT_ROW_2);
+ PAssert.that(results).containsInAnyOrder(OUT_ROW_1, OUT_ROW_2);
pipeline.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/GameStatsTest.java
----------------------------------------------------------------------
diff --git a/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/GameStatsTest.java b/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/GameStatsTest.java
index e1a5edb..5832c89 100644
--- a/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/GameStatsTest.java
+++ b/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/GameStatsTest.java
@@ -19,7 +19,7 @@ package com.google.cloud.dataflow.examples.complete.game;
import com.google.cloud.dataflow.examples.complete.game.GameStats.CalculateSpammyUsers;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -69,7 +69,7 @@ public class GameStatsTest implements Serializable {
PCollection<KV<String, Integer>> output = input.apply(new CalculateSpammyUsers());
// Check the set of spammers.
- DataflowAssert.that(output).containsInAnyOrder(SPAMMERS);
+ PAssert.that(output).containsInAnyOrder(SPAMMERS);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/HourlyTeamScoreTest.java
----------------------------------------------------------------------
diff --git a/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/HourlyTeamScoreTest.java b/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/HourlyTeamScoreTest.java
index df9768a..3fd2c57 100644
--- a/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/HourlyTeamScoreTest.java
+++ b/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/HourlyTeamScoreTest.java
@@ -21,7 +21,7 @@ import com.google.cloud.dataflow.examples.complete.game.UserScore.GameActionInfo
import com.google.cloud.dataflow.examples.complete.game.UserScore.ParseEventFn;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -104,7 +104,7 @@ public class HourlyTeamScoreTest implements Serializable {
.via((GameActionInfo gInfo) -> KV.of(gInfo.getUser(), gInfo.getScore()))
.withOutputType(new TypeDescriptor<KV<String, Integer>>() {}));
- DataflowAssert.that(output).containsInAnyOrder(FILTERED_EVENTS);
+ PAssert.that(output).containsInAnyOrder(FILTERED_EVENTS);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/UserScoreTest.java
----------------------------------------------------------------------
diff --git a/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/UserScoreTest.java b/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/UserScoreTest.java
index 7f25dae..b907ae7 100644
--- a/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/UserScoreTest.java
+++ b/examples/java8/src/test/java/com/google/cloud/dataflow/examples/complete/game/UserScoreTest.java
@@ -22,7 +22,7 @@ import com.google.cloud.dataflow.examples.complete.game.UserScore.GameActionInfo
import com.google.cloud.dataflow.examples.complete.game.UserScore.ParseEventFn;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -110,7 +110,7 @@ public class UserScoreTest implements Serializable {
.apply("ExtractUserScore", new ExtractAndSumScore("user"));
// Check the user score sums.
- DataflowAssert.that(output).containsInAnyOrder(USER_SUMS);
+ PAssert.that(output).containsInAnyOrder(USER_SUMS);
p.run();
}
@@ -129,7 +129,7 @@ public class UserScoreTest implements Serializable {
.apply("ExtractTeamScore", new ExtractAndSumScore("team"));
// Check the team score sums.
- DataflowAssert.that(output).containsInAnyOrder(TEAM_SUMS);
+ PAssert.that(output).containsInAnyOrder(TEAM_SUMS);
p.run();
}
@@ -148,7 +148,7 @@ public class UserScoreTest implements Serializable {
MapElements.via((GameActionInfo gInfo) -> KV.of(gInfo.getUser(), gInfo.getScore()))
.withOutputType(new TypeDescriptor<KV<String, Integer>>() {}));
- DataflowAssert.that(extract).empty();
+ PAssert.that(extract).empty();
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/flink/runner/src/test/java/org/apache/beam/runners/flink/FlinkTestPipeline.java
----------------------------------------------------------------------
diff --git a/runners/flink/runner/src/test/java/org/apache/beam/runners/flink/FlinkTestPipeline.java b/runners/flink/runner/src/test/java/org/apache/beam/runners/flink/FlinkTestPipeline.java
index aadda24..86a0cd0 100644
--- a/runners/flink/runner/src/test/java/org/apache/beam/runners/flink/FlinkTestPipeline.java
+++ b/runners/flink/runner/src/test/java/org/apache/beam/runners/flink/FlinkTestPipeline.java
@@ -31,7 +31,7 @@ public class FlinkTestPipeline extends Pipeline {
/**
* Creates and returns a new test pipeline for batch execution.
*
- * <p> Use {@link com.google.cloud.dataflow.sdk.testing.DataflowAssert} to add tests, then call
+ * <p> Use {@link com.google.cloud.dataflow.sdk.testing.PAssert} to add tests, then call
* {@link Pipeline#run} to execute the pipeline and check the tests.
*/
public static FlinkTestPipeline createForBatch() {
@@ -41,7 +41,7 @@ public class FlinkTestPipeline extends Pipeline {
/**
* Creates and returns a new test pipeline for streaming execution.
*
- * <p> Use {@link com.google.cloud.dataflow.sdk.testing.DataflowAssert} to add tests, then call
+ * <p> Use {@link com.google.cloud.dataflow.sdk.testing.PAssert} to add tests, then call
* {@link Pipeline#run} to execute the pipeline and check the tests.
*
* @return The Test Pipeline
@@ -53,7 +53,7 @@ public class FlinkTestPipeline extends Pipeline {
/**
* Creates and returns a new test pipeline for streaming or batch execution.
*
- * <p> Use {@link com.google.cloud.dataflow.sdk.testing.DataflowAssert} to add tests, then call
+ * <p> Use {@link com.google.cloud.dataflow.sdk.testing.PAssert} to add tests, then call
* {@link Pipeline#run} to execute the pipeline and check the tests.
*
* @param streaming <code>True</code> for streaming mode, <code>False</code> for batch.
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/main/java/org/apache/beam/runners/spark/translation/streaming/StreamingTransformTranslator.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/main/java/org/apache/beam/runners/spark/translation/streaming/StreamingTransformTranslator.java b/runners/spark/src/main/java/org/apache/beam/runners/spark/translation/streaming/StreamingTransformTranslator.java
index 349bb7c..fdab667 100644
--- a/runners/spark/src/main/java/org/apache/beam/runners/spark/translation/streaming/StreamingTransformTranslator.java
+++ b/runners/spark/src/main/java/org/apache/beam/runners/spark/translation/streaming/StreamingTransformTranslator.java
@@ -136,7 +136,7 @@ public final class StreamingTransformTranslator {
// fake create as an input
// creates a stream with a single batch containing a single null element
// to invoke following transformations once
- // to support DataflowAssert
+ // to support PAssert
sec.setDStreamFromQueue(transform,
Collections.<Iterable<Void>>singletonList(Collections.singletonList((Void) null)),
(Coder<Void>) coder);
@@ -195,7 +195,7 @@ public final class StreamingTransformTranslator {
.transform(new RDDTransform<>(sec, rddEvaluator, transform)));
} else {
// if the transformation requires direct access to RDD (not in stream)
- // this is used for "fake" transformations like with DataflowAssert
+ // this is used for "fake" transformations like with PAssert
rddEvaluator.evaluate(transform, context);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/test/java/org/apache/beam/runners/spark/DeDupTest.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/DeDupTest.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/DeDupTest.java
index 4a080e8..87f6d4c 100644
--- a/runners/spark/src/test/java/org/apache/beam/runners/spark/DeDupTest.java
+++ b/runners/spark/src/test/java/org/apache/beam/runners/spark/DeDupTest.java
@@ -20,7 +20,7 @@ package org.apache.beam.runners.spark;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.transforms.RemoveDuplicates;
import com.google.cloud.dataflow.sdk.values.PCollection;
@@ -52,7 +52,7 @@ public class DeDupTest {
PCollection<String> input = p.apply(Create.of(LINES)).setCoder(StringUtf8Coder.of());
PCollection<String> output = input.apply(RemoveDuplicates.<String>create());
- DataflowAssert.that(output).containsInAnyOrder(EXPECTED_SET);
+ PAssert.that(output).containsInAnyOrder(EXPECTED_SET);
EvaluationResult res = SparkPipelineRunner.create().run(p);
res.close();
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/test/java/org/apache/beam/runners/spark/SimpleWordCountTest.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/SimpleWordCountTest.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/SimpleWordCountTest.java
index e32b39a..3946e12 100644
--- a/runners/spark/src/test/java/org/apache/beam/runners/spark/SimpleWordCountTest.java
+++ b/runners/spark/src/test/java/org/apache/beam/runners/spark/SimpleWordCountTest.java
@@ -20,7 +20,7 @@ package org.apache.beam.runners.spark;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.*;
import com.google.cloud.dataflow.sdk.values.KV;
import com.google.cloud.dataflow.sdk.values.PCollection;
@@ -50,7 +50,7 @@ public class SimpleWordCountTest {
.of());
PCollection<String> output = inputWords.apply(new CountWords());
- DataflowAssert.that(output).containsInAnyOrder(EXPECTED_COUNT_SET);
+ PAssert.that(output).containsInAnyOrder(EXPECTED_COUNT_SET);
EvaluationResult res = SparkPipelineRunner.create().run(p);
res.close();
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/test/java/org/apache/beam/runners/spark/TfIdfTest.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/TfIdfTest.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/TfIdfTest.java
index 51ce3a3..24183fb 100644
--- a/runners/spark/src/test/java/org/apache/beam/runners/spark/TfIdfTest.java
+++ b/runners/spark/src/test/java/org/apache/beam/runners/spark/TfIdfTest.java
@@ -22,7 +22,7 @@ import com.google.cloud.dataflow.examples.complete.TfIdf;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringDelegateCoder;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.transforms.Keys;
import com.google.cloud.dataflow.sdk.transforms.RemoveDuplicates;
@@ -55,7 +55,7 @@ public class TfIdfTest {
.apply(Keys.<String>create())
.apply(RemoveDuplicates.<String>create());
- DataflowAssert.that(words).containsInAnyOrder(Arrays.asList("a", "m", "n", "b", "c", "d"));
+ PAssert.that(words).containsInAnyOrder(Arrays.asList("a", "m", "n", "b", "c", "d"));
EvaluationResult res = SparkPipelineRunner.create().run(pipeline);
res.close();
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/DoFnOutputTest.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/DoFnOutputTest.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/DoFnOutputTest.java
index a9779e6..5f15a35 100644
--- a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/DoFnOutputTest.java
+++ b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/DoFnOutputTest.java
@@ -19,7 +19,7 @@
package org.apache.beam.runners.spark.translation;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.transforms.DoFn;
import com.google.cloud.dataflow.sdk.transforms.ParDo;
@@ -56,7 +56,7 @@ public class DoFnOutputTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder("start", "a", "finish");
+ PAssert.that(output).containsInAnyOrder("start", "a", "finish");
EvaluationResult res = SparkPipelineRunner.create().run(pipeline);
res.close();
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/MultiOutputWordCountTest.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/MultiOutputWordCountTest.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/MultiOutputWordCountTest.java
index 974467f..52dcf30 100644
--- a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/MultiOutputWordCountTest.java
+++ b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/MultiOutputWordCountTest.java
@@ -22,7 +22,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
import com.google.cloud.dataflow.sdk.runners.AggregatorValues;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.*;
import com.google.cloud.dataflow.sdk.values.*;
import com.google.common.collect.ImmutableSet;
@@ -61,7 +61,7 @@ public class MultiOutputWordCountTest {
ApproximateUnique.<KV<String, Long>>globally(16));
EvaluationResult res = SparkPipelineRunner.create().run(p);
- DataflowAssert.that(luc.get(lowerCnts).apply(ParDo.of(new FormatCountsFn())))
+ PAssert.that(luc.get(lowerCnts).apply(ParDo.of(new FormatCountsFn())))
.containsInAnyOrder(EXPECTED_LOWER_COUNTS);
Iterable<KV<String, Long>> actualUpper = res.get(luc.get(upperCnts));
Assert.assertEquals("Here", actualUpper.iterator().next().getKey());
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/SerializationTest.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/SerializationTest.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/SerializationTest.java
index b378795..0978766 100644
--- a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/SerializationTest.java
+++ b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/SerializationTest.java
@@ -22,7 +22,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.AtomicCoder;
import com.google.cloud.dataflow.sdk.coders.Coder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.*;
import com.google.cloud.dataflow.sdk.values.KV;
import com.google.cloud.dataflow.sdk.values.PCollection;
@@ -118,7 +118,7 @@ public class SerializationTest {
p.apply(Create.of(WORDS).withCoder(StringHolderUtf8Coder.of()));
PCollection<StringHolder> output = inputWords.apply(new CountWords());
- DataflowAssert.that(output).containsInAnyOrder(EXPECTED_COUNT_SET);
+ PAssert.that(output).containsInAnyOrder(EXPECTED_COUNT_SET);
EvaluationResult res = SparkPipelineRunner.create().run(p);
res.close();
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/WindowedWordCountTest.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/WindowedWordCountTest.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/WindowedWordCountTest.java
index 9fac9c6..9a29171 100644
--- a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/WindowedWordCountTest.java
+++ b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/WindowedWordCountTest.java
@@ -21,7 +21,7 @@ package org.apache.beam.runners.spark.translation;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.transforms.windowing.FixedWindows;
import com.google.cloud.dataflow.sdk.transforms.windowing.SlidingWindows;
@@ -59,7 +59,7 @@ public class WindowedWordCountTest {
PCollection<String> output = windowedWords.apply(new SimpleWordCountTest.CountWords());
- DataflowAssert.that(output).containsInAnyOrder(EXPECTED_FIXED_SEPARATE_COUNT_SET);
+ PAssert.that(output).containsInAnyOrder(EXPECTED_FIXED_SEPARATE_COUNT_SET);
EvaluationResult res = SparkPipelineRunner.create().run(p);
res.close();
@@ -78,7 +78,7 @@ public class WindowedWordCountTest {
PCollection<String> output = windowedWords.apply(new SimpleWordCountTest.CountWords());
- DataflowAssert.that(output).containsInAnyOrder(EXPECTED_FIXED_SAME_COUNT_SET);
+ PAssert.that(output).containsInAnyOrder(EXPECTED_FIXED_SAME_COUNT_SET);
EvaluationResult res = SparkPipelineRunner.create().run(p);
res.close();
@@ -99,7 +99,7 @@ public class WindowedWordCountTest {
PCollection<String> output = windowedWords.apply(new SimpleWordCountTest.CountWords());
- DataflowAssert.that(output).containsInAnyOrder(EXPECTED_SLIDING_COUNT_SET);
+ PAssert.that(output).containsInAnyOrder(EXPECTED_SLIDING_COUNT_SET);
EvaluationResult res = SparkPipelineRunner.create().run(p);
res.close();
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/FlattenStreamingTest.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/FlattenStreamingTest.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/FlattenStreamingTest.java
index a3eb301..ed51edf 100644
--- a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/FlattenStreamingTest.java
+++ b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/FlattenStreamingTest.java
@@ -19,7 +19,7 @@ package org.apache.beam.runners.spark.translation.streaming;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.Flatten;
import com.google.cloud.dataflow.sdk.transforms.View;
import com.google.cloud.dataflow.sdk.transforms.windowing.FixedWindows;
@@ -31,7 +31,7 @@ import org.apache.beam.runners.spark.SparkStreamingPipelineOptions;
import org.apache.beam.runners.spark.io.CreateStream;
import org.apache.beam.runners.spark.EvaluationResult;
import org.apache.beam.runners.spark.SparkPipelineRunner;
-import org.apache.beam.runners.spark.translation.streaming.utils.DataflowAssertStreaming;
+import org.apache.beam.runners.spark.translation.streaming.utils.PAssertStreaming;
import org.joda.time.Duration;
import org.junit.Test;
@@ -76,13 +76,13 @@ public class FlattenStreamingTest {
PCollectionList<String> list = PCollectionList.of(windowedW1).and(windowedW2);
PCollection<String> union = list.apply(Flatten.<String>pCollections());
- DataflowAssert.thatIterable(union.apply(View.<String>asIterable()))
+ PAssert.thatIterable(union.apply(View.<String>asIterable()))
.containsInAnyOrder(EXPECTED_UNION);
EvaluationResult res = SparkPipelineRunner.create(options).run(p);
res.close();
- DataflowAssertStreaming.assertNoFailures(res);
+ PAssertStreaming.assertNoFailures(res);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/KafkaStreamingTest.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/KafkaStreamingTest.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/KafkaStreamingTest.java
index 628fe86..4499b56 100644
--- a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/KafkaStreamingTest.java
+++ b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/KafkaStreamingTest.java
@@ -20,7 +20,7 @@ package org.apache.beam.runners.spark.translation.streaming;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.KvCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.DoFn;
import com.google.cloud.dataflow.sdk.transforms.ParDo;
import com.google.cloud.dataflow.sdk.transforms.View;
@@ -35,7 +35,7 @@ import org.apache.beam.runners.spark.SparkStreamingPipelineOptions;
import org.apache.beam.runners.spark.io.KafkaIO;
import org.apache.beam.runners.spark.EvaluationResult;
import org.apache.beam.runners.spark.SparkPipelineRunner;
-import org.apache.beam.runners.spark.translation.streaming.utils.DataflowAssertStreaming;
+import org.apache.beam.runners.spark.translation.streaming.utils.PAssertStreaming;
import org.apache.beam.runners.spark.translation.streaming.utils.EmbeddedKafkaCluster;
import org.apache.kafka.clients.producer.KafkaProducer;
@@ -115,13 +115,13 @@ public class KafkaStreamingTest {
PCollection<String> formattedKV = windowedWords.apply(ParDo.of(new FormatKVFn()));
- DataflowAssert.thatIterable(formattedKV.apply(View.<String>asIterable()))
+ PAssert.thatIterable(formattedKV.apply(View.<String>asIterable()))
.containsInAnyOrder(EXPECTED);
EvaluationResult res = SparkPipelineRunner.create(options).run(p);
res.close();
- DataflowAssertStreaming.assertNoFailures(res);
+ PAssertStreaming.assertNoFailures(res);
}
@AfterClass
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/SimpleStreamingWordCountTest.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/SimpleStreamingWordCountTest.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/SimpleStreamingWordCountTest.java
index b591510..ed02286 100644
--- a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/SimpleStreamingWordCountTest.java
+++ b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/SimpleStreamingWordCountTest.java
@@ -19,7 +19,7 @@ package org.apache.beam.runners.spark.translation.streaming;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.View;
import com.google.cloud.dataflow.sdk.transforms.windowing.FixedWindows;
import com.google.cloud.dataflow.sdk.transforms.windowing.Window;
@@ -31,7 +31,7 @@ import org.apache.beam.runners.spark.io.CreateStream;
import org.apache.beam.runners.spark.EvaluationResult;
import org.apache.beam.runners.spark.SimpleWordCountTest;
import org.apache.beam.runners.spark.SparkPipelineRunner;
-import org.apache.beam.runners.spark.translation.streaming.utils.DataflowAssertStreaming;
+import org.apache.beam.runners.spark.translation.streaming.utils.PAssertStreaming;
import org.joda.time.Duration;
import org.junit.Test;
@@ -66,12 +66,12 @@ public class SimpleStreamingWordCountTest {
PCollection<String> output = windowedWords.apply(new SimpleWordCountTest.CountWords());
- DataflowAssert.thatIterable(output.apply(View.<String>asIterable()))
+ PAssert.thatIterable(output.apply(View.<String>asIterable()))
.containsInAnyOrder(EXPECTED_COUNT_SET);
EvaluationResult res = SparkPipelineRunner.create(options).run(p);
res.close();
- DataflowAssertStreaming.assertNoFailures(res);
+ PAssertStreaming.assertNoFailures(res);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/utils/DataflowAssertStreaming.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/utils/DataflowAssertStreaming.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/utils/DataflowAssertStreaming.java
deleted file mode 100644
index 30673dd..0000000
--- a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/utils/DataflowAssertStreaming.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.beam.runners.spark.translation.streaming.utils;
-
-import org.apache.beam.runners.spark.EvaluationResult;
-
-import org.junit.Assert;
-
-/**
- * Since DataflowAssert doesn't propagate assert exceptions, use Aggregators to assert streaming
- * success/failure counters.
- */
-public final class DataflowAssertStreaming {
- /**
- * Copied aggregator names from {@link com.google.cloud.dataflow.sdk.testing.DataflowAssert}
- */
- static final String SUCCESS_COUNTER = "DataflowAssertSuccess";
- static final String FAILURE_COUNTER = "DataflowAssertFailure";
-
- private DataflowAssertStreaming() {
- }
-
- public static void assertNoFailures(EvaluationResult res) {
- int failures = res.getAggregatorValue(FAILURE_COUNTER, Integer.class);
- Assert.assertEquals("Found " + failures + " failures, see the log for details", 0, failures);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/utils/PAssertStreaming.java
----------------------------------------------------------------------
diff --git a/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/utils/PAssertStreaming.java b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/utils/PAssertStreaming.java
new file mode 100644
index 0000000..fe0f2a8
--- /dev/null
+++ b/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/utils/PAssertStreaming.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.spark.translation.streaming.utils;
+
+import org.apache.beam.runners.spark.EvaluationResult;
+
+import org.junit.Assert;
+
+/**
+ * Since PAssert doesn't propagate assert exceptions, use Aggregators to assert streaming
+ * success/failure counters.
+ */
+public final class PAssertStreaming {
+ /**
+ * Copied aggregator names from {@link com.google.cloud.dataflow.sdk.testing.PAssert}
+ */
+ static final String SUCCESS_COUNTER = "PAssertSuccess";
+ static final String FAILURE_COUNTER = "PAssertFailure";
+
+ private PAssertStreaming() {
+ }
+
+ public static void assertNoFailures(EvaluationResult res) {
+ int failures = res.getAggregatorValue(FAILURE_COUNTER, Integer.class);
+ Assert.assertEquals("Found " + failures + " failures, see the log for details", 0, failures);
+ }
+}
[3/5] incubator-beam git commit: Rename DataflowAssert to PAssert
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/DataflowAssert.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/DataflowAssert.java b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/DataflowAssert.java
deleted file mode 100644
index 8f4c066..0000000
--- a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/DataflowAssert.java
+++ /dev/null
@@ -1,826 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.cloud.dataflow.sdk.testing;
-
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertThat;
-
-import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.coders.Coder;
-import com.google.cloud.dataflow.sdk.coders.CoderException;
-import com.google.cloud.dataflow.sdk.coders.IterableCoder;
-import com.google.cloud.dataflow.sdk.coders.KvCoder;
-import com.google.cloud.dataflow.sdk.coders.MapCoder;
-import com.google.cloud.dataflow.sdk.coders.VoidCoder;
-import com.google.cloud.dataflow.sdk.options.StreamingOptions;
-import com.google.cloud.dataflow.sdk.runners.PipelineRunner;
-import com.google.cloud.dataflow.sdk.transforms.Aggregator;
-import com.google.cloud.dataflow.sdk.transforms.Create;
-import com.google.cloud.dataflow.sdk.transforms.DoFn;
-import com.google.cloud.dataflow.sdk.transforms.PTransform;
-import com.google.cloud.dataflow.sdk.transforms.ParDo;
-import com.google.cloud.dataflow.sdk.transforms.SerializableFunction;
-import com.google.cloud.dataflow.sdk.transforms.Sum;
-import com.google.cloud.dataflow.sdk.transforms.View;
-import com.google.cloud.dataflow.sdk.transforms.windowing.GlobalWindows;
-import com.google.cloud.dataflow.sdk.transforms.windowing.Window;
-import com.google.cloud.dataflow.sdk.util.CoderUtils;
-import com.google.cloud.dataflow.sdk.values.KV;
-import com.google.cloud.dataflow.sdk.values.PBegin;
-import com.google.cloud.dataflow.sdk.values.PCollection;
-import com.google.cloud.dataflow.sdk.values.PCollectionView;
-import com.google.cloud.dataflow.sdk.values.PDone;
-import com.google.common.base.Optional;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-/**
- * An assertion on the contents of a {@link PCollection}
- * incorporated into the pipeline. Such an assertion
- * can be checked no matter what kind of {@link PipelineRunner} is
- * used.
- *
- * <p>Note that the {@code DataflowAssert} call must precede the call
- * to {@link Pipeline#run}.
- *
- * <p>Examples of use:
- * <pre>{@code
- * 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();
- * }</pre>
- *
- * <p>JUnit and Hamcrest must be linked in by any code that uses DataflowAssert.
- */
-public class DataflowAssert {
-
- private static final Logger LOG = LoggerFactory.getLogger(DataflowAssert.class);
-
- static final String SUCCESS_COUNTER = "DataflowAssertSuccess";
- static final String FAILURE_COUNTER = "DataflowAssertFailure";
-
- private static int assertCount = 0;
-
- // Do not instantiate.
- private DataflowAssert() {}
-
- /**
- * Constructs an {@link IterableAssert} for the elements of the provided
- * {@link PCollection}.
- */
- public static <T> IterableAssert<T> that(PCollection<T> actual) {
- return new IterableAssert<>(
- new CreateActual<T, Iterable<T>>(actual, View.<T>asIterable()),
- actual.getPipeline())
- .setCoder(actual.getCoder());
- }
-
- /**
- * Constructs an {@link IterableAssert} for the value of the provided
- * {@link PCollection} which must contain a single {@code Iterable<T>}
- * value.
- */
- public static <T> IterableAssert<T>
- thatSingletonIterable(PCollection<? extends Iterable<T>> actual) {
-
- List<? extends Coder<?>> maybeElementCoder = actual.getCoder().getCoderArguments();
- Coder<T> tCoder;
- try {
- @SuppressWarnings("unchecked")
- Coder<T> tCoderTmp = (Coder<T>) Iterables.getOnlyElement(maybeElementCoder);
- tCoder = tCoderTmp;
- } catch (NoSuchElementException | IllegalArgumentException exc) {
- throw new IllegalArgumentException(
- "DataflowAssert.<T>thatSingletonIterable requires a PCollection<Iterable<T>>"
- + " with a Coder<Iterable<T>> where getCoderArguments() yields a"
- + " single Coder<T> to apply to the elements.");
- }
-
- @SuppressWarnings("unchecked") // Safe covariant cast
- PCollection<Iterable<T>> actualIterables = (PCollection<Iterable<T>>) actual;
-
- return new IterableAssert<>(
- new CreateActual<Iterable<T>, Iterable<T>>(
- actualIterables, View.<Iterable<T>>asSingleton()),
- actual.getPipeline())
- .setCoder(tCoder);
- }
-
- /**
- * Constructs an {@link IterableAssert} for the value of the provided
- * {@code PCollectionView PCollectionView<Iterable<T>>}.
- */
- public static <T> IterableAssert<T> thatIterable(PCollectionView<Iterable<T>> actual) {
- return new IterableAssert<>(new PreExisting<Iterable<T>>(actual), actual.getPipeline());
- }
-
- /**
- * Constructs a {@link SingletonAssert} for the value of the provided
- * {@code PCollection PCollection<T>}, which must be a singleton.
- */
- public static <T> SingletonAssert<T> thatSingleton(PCollection<T> actual) {
- return new SingletonAssert<>(
- new CreateActual<T, T>(actual, View.<T>asSingleton()), actual.getPipeline())
- .setCoder(actual.getCoder());
- }
-
- /**
- * Constructs a {@link SingletonAssert} for the value of the provided {@link PCollection}.
- *
- * <p>Note that the actual value must be coded by a {@link KvCoder},
- * not just any {@code Coder<K, V>}.
- */
- public static <K, V> SingletonAssert<Map<K, Iterable<V>>>
- thatMultimap(PCollection<KV<K, V>> actual) {
- @SuppressWarnings("unchecked")
- KvCoder<K, V> kvCoder = (KvCoder<K, V>) actual.getCoder();
-
- return new SingletonAssert<>(
- new CreateActual<>(actual, View.<K, V>asMultimap()), actual.getPipeline())
- .setCoder(MapCoder.of(kvCoder.getKeyCoder(), IterableCoder.of(kvCoder.getValueCoder())));
- }
-
- /**
- * Constructs a {@link SingletonAssert} for the value of the provided {@link PCollection},
- * which must have at most one value per key.
- *
- * <p>Note that the actual value must be coded by a {@link KvCoder},
- * not just any {@code Coder<K, V>}.
- */
- public static <K, V> SingletonAssert<Map<K, V>> thatMap(PCollection<KV<K, V>> actual) {
- @SuppressWarnings("unchecked")
- KvCoder<K, V> kvCoder = (KvCoder<K, V>) actual.getCoder();
-
- return new SingletonAssert<>(
- new CreateActual<>(actual, View.<K, V>asMap()), actual.getPipeline())
- .setCoder(MapCoder.of(kvCoder.getKeyCoder(), kvCoder.getValueCoder()));
- }
-
- ////////////////////////////////////////////////////////////
-
- /**
- * An assertion about the contents of a {@link PCollectionView} yielding an {@code Iterable<T>}.
- */
- public static class IterableAssert<T> implements Serializable {
- private final Pipeline pipeline;
- private final PTransform<PBegin, PCollectionView<Iterable<T>>> createActual;
- private Optional<Coder<T>> coder;
-
- protected IterableAssert(
- PTransform<PBegin, PCollectionView<Iterable<T>>> createActual, Pipeline pipeline) {
- this.createActual = createActual;
- this.pipeline = pipeline;
- this.coder = Optional.absent();
- }
-
- /**
- * Sets the coder to use for elements of type {@code T}, as needed for internal purposes.
- *
- * <p>Returns this {@code IterableAssert}.
- */
- public IterableAssert<T> setCoder(Coder<T> coderOrNull) {
- this.coder = Optional.fromNullable(coderOrNull);
- return this;
- }
-
- /**
- * Gets the coder, which may yet be absent.
- */
- public Coder<T> getCoder() {
- if (coder.isPresent()) {
- return coder.get();
- } else {
- throw new IllegalStateException(
- "Attempting to access the coder of an IterableAssert"
- + " that has not been set yet.");
- }
- }
-
- /**
- * Applies a {@link SerializableFunction} to check the elements of the {@code Iterable}.
- *
- * <p>Returns this {@code IterableAssert}.
- */
- public IterableAssert<T> satisfies(SerializableFunction<Iterable<T>, Void> checkerFn) {
- pipeline.apply(
- "DataflowAssert$" + (assertCount++),
- new OneSideInputAssert<Iterable<T>>(createActual, checkerFn));
- return this;
- }
-
- /**
- * Applies a {@link SerializableFunction} to check the elements of the {@code Iterable}.
- *
- * <p>Returns this {@code IterableAssert}.
- */
- public IterableAssert<T> satisfies(
- AssertRelation<Iterable<T>, Iterable<T>> relation,
- final Iterable<T> expectedElements) {
- pipeline.apply(
- "DataflowAssert$" + (assertCount++),
- new TwoSideInputAssert<Iterable<T>, Iterable<T>>(createActual,
- new CreateExpected<T, Iterable<T>>(expectedElements, coder, View.<T>asIterable()),
- relation));
-
- return this;
- }
-
- /**
- * Applies a {@link SerializableMatcher} to check the elements of the {@code Iterable}.
- *
- * <p>Returns this {@code IterableAssert}.
- */
- IterableAssert<T> satisfies(final SerializableMatcher<Iterable<? extends T>> matcher) {
- // Safe covariant cast. Could be elided by changing a lot of this file to use
- // more flexible bounds.
- @SuppressWarnings({"rawtypes", "unchecked"})
- SerializableFunction<Iterable<T>, Void> checkerFn =
- (SerializableFunction) new MatcherCheckerFn<>(matcher);
- pipeline.apply(
- "DataflowAssert$" + (assertCount++),
- new OneSideInputAssert<Iterable<T>>(
- createActual,
- checkerFn));
- return this;
- }
-
- private static class MatcherCheckerFn<T> implements SerializableFunction<T, Void> {
- private SerializableMatcher<T> matcher;
-
- public MatcherCheckerFn(SerializableMatcher<T> matcher) {
- this.matcher = matcher;
- }
-
- @Override
- public Void apply(T actual) {
- assertThat(actual, matcher);
- return null;
- }
- }
-
- /**
- * Checks that the {@code Iterable} is empty.
- *
- * <p>Returns this {@code IterableAssert}.
- */
- public IterableAssert<T> empty() {
- return satisfies(new AssertContainsInAnyOrderRelation<T>(), Collections.<T>emptyList());
- }
-
- /**
- * @throws UnsupportedOperationException always
- * @deprecated {@link Object#equals(Object)} is not supported on DataflowAssert objects.
- * If you meant to test object equality, use a variant of {@link #containsInAnyOrder}
- * instead.
- */
- @Deprecated
- @Override
- public boolean equals(Object o) {
- throw new UnsupportedOperationException(
- "If you meant to test object equality, use .containsInAnyOrder instead.");
- }
-
- /**
- * @throws UnsupportedOperationException always.
- * @deprecated {@link Object#hashCode()} is not supported on DataflowAssert objects.
- */
- @Deprecated
- @Override
- public int hashCode() {
- throw new UnsupportedOperationException(
- String.format("%s.hashCode() is not supported.", IterableAssert.class.getSimpleName()));
- }
-
- /**
- * Checks that the {@code Iterable} contains the expected elements, in any
- * order.
- *
- * <p>Returns this {@code IterableAssert}.
- */
- public IterableAssert<T> containsInAnyOrder(Iterable<T> expectedElements) {
- return satisfies(new AssertContainsInAnyOrderRelation<T>(), expectedElements);
- }
-
- /**
- * Checks that the {@code Iterable} contains the expected elements, in any
- * order.
- *
- * <p>Returns this {@code IterableAssert}.
- */
- @SafeVarargs
- public final IterableAssert<T> containsInAnyOrder(T... expectedElements) {
- return satisfies(
- new AssertContainsInAnyOrderRelation<T>(),
- Arrays.asList(expectedElements));
- }
-
- /**
- * Checks that the {@code Iterable} contains elements that match the provided matchers,
- * in any order.
- *
- * <p>Returns this {@code IterableAssert}.
- */
- @SafeVarargs
- final IterableAssert<T> containsInAnyOrder(
- SerializableMatcher<? super T>... elementMatchers) {
- return satisfies(SerializableMatchers.<T>containsInAnyOrder(elementMatchers));
- }
- }
-
- /**
- * An assertion about the single value of type {@code T}
- * associated with a {@link PCollectionView}.
- */
- public static class SingletonAssert<T> implements Serializable {
- private final Pipeline pipeline;
- private final CreateActual<?, T> createActual;
- private Optional<Coder<T>> coder;
-
- protected SingletonAssert(
- CreateActual<?, T> createActual, Pipeline pipeline) {
- this.pipeline = pipeline;
- this.createActual = createActual;
- this.coder = Optional.absent();
- }
-
- /**
- * Always throws an {@link UnsupportedOperationException}: users are probably looking for
- * {@link #isEqualTo}.
- */
- @Deprecated
- @Override
- public boolean equals(Object o) {
- throw new UnsupportedOperationException(
- String.format(
- "tests for Java equality of the %s object, not the PCollection in question. "
- + "Call a test method, such as isEqualTo.",
- getClass().getSimpleName()));
- }
-
- /**
- * @throws UnsupportedOperationException always.
- * @deprecated {@link Object#hashCode()} is not supported on DataflowAssert objects.
- */
- @Deprecated
- @Override
- public int hashCode() {
- throw new UnsupportedOperationException(
- String.format("%s.hashCode() is not supported.", SingletonAssert.class.getSimpleName()));
- }
-
- /**
- * Sets the coder to use for elements of type {@code T}, as needed
- * for internal purposes.
- *
- * <p>Returns this {@code IterableAssert}.
- */
- public SingletonAssert<T> setCoder(Coder<T> coderOrNull) {
- this.coder = Optional.fromNullable(coderOrNull);
- return this;
- }
-
- /**
- * Gets the coder, which may yet be absent.
- */
- public Coder<T> getCoder() {
- if (coder.isPresent()) {
- return coder.get();
- } else {
- throw new IllegalStateException(
- "Attempting to access the coder of an IterableAssert that has not been set yet.");
- }
- }
-
- /**
- * Applies a {@link SerializableFunction} to check the value of this
- * {@code SingletonAssert}'s view.
- *
- * <p>Returns this {@code SingletonAssert}.
- */
- public SingletonAssert<T> satisfies(SerializableFunction<T, Void> checkerFn) {
- pipeline.apply(
- "DataflowAssert$" + (assertCount++),
- new OneSideInputAssert<T>(createActual, checkerFn));
- return this;
- }
-
- /**
- * Applies an {@link AssertRelation} to check the provided relation against the
- * value of this assert and the provided expected value.
- *
- * <p>Returns this {@code SingletonAssert}.
- */
- public SingletonAssert<T> satisfies(
- AssertRelation<T, T> relation,
- final T expectedValue) {
- pipeline.apply(
- "DataflowAssert$" + (assertCount++),
- new TwoSideInputAssert<T, T>(createActual,
- new CreateExpected<T, T>(Arrays.asList(expectedValue), coder, View.<T>asSingleton()),
- relation));
-
- return this;
- }
-
- /**
- * Checks that the value of this {@code SingletonAssert}'s view is equal
- * to the expected value.
- *
- * <p>Returns this {@code SingletonAssert}.
- */
- public SingletonAssert<T> isEqualTo(T expectedValue) {
- return satisfies(new AssertIsEqualToRelation<T>(), expectedValue);
- }
-
- /**
- * Checks that the value of this {@code SingletonAssert}'s view is not equal
- * to the expected value.
- *
- * <p>Returns this {@code SingletonAssert}.
- */
- public SingletonAssert<T> notEqualTo(T expectedValue) {
- return satisfies(new AssertNotEqualToRelation<T>(), expectedValue);
- }
-
- /**
- * Checks that the value of this {@code SingletonAssert}'s view is equal to
- * the expected value.
- *
- * @deprecated replaced by {@link #isEqualTo}
- */
- @Deprecated
- public SingletonAssert<T> is(T expectedValue) {
- return isEqualTo(expectedValue);
- }
-
- }
-
- ////////////////////////////////////////////////////////////////////////
-
- private static class CreateActual<T, ActualT>
- extends PTransform<PBegin, PCollectionView<ActualT>> {
-
- private final transient PCollection<T> actual;
- private final transient PTransform<PCollection<T>, PCollectionView<ActualT>> actualView;
-
- private CreateActual(PCollection<T> actual,
- PTransform<PCollection<T>, PCollectionView<ActualT>> actualView) {
- this.actual = actual;
- this.actualView = actualView;
- }
-
- @Override
- public PCollectionView<ActualT> apply(PBegin input) {
- final Coder<T> coder = actual.getCoder();
- return actual
- .apply(Window.<T>into(new GlobalWindows()))
- .apply(ParDo.of(new DoFn<T, T>() {
- @Override
- public void processElement(ProcessContext context) throws CoderException {
- context.output(CoderUtils.clone(coder, context.element()));
- }
- }))
- .apply(actualView);
- }
- }
-
- private static class CreateExpected<T, ExpectedT>
- extends PTransform<PBegin, PCollectionView<ExpectedT>> {
-
- private final Iterable<T> elements;
- private final Optional<Coder<T>> coder;
- private final transient PTransform<PCollection<T>, PCollectionView<ExpectedT>> view;
-
- private CreateExpected(Iterable<T> elements, Optional<Coder<T>> coder,
- PTransform<PCollection<T>, PCollectionView<ExpectedT>> view) {
- this.elements = elements;
- this.coder = coder;
- this.view = view;
- }
-
- @Override
- public PCollectionView<ExpectedT> apply(PBegin input) {
- Create.Values<T> createTransform = Create.<T>of(elements);
- if (coder.isPresent()) {
- createTransform = createTransform.withCoder(coder.get());
- }
- return input.apply(createTransform).apply(view);
- }
- }
-
- private static class PreExisting<T> extends PTransform<PBegin, PCollectionView<T>> {
-
- private final PCollectionView<T> view;
-
- private PreExisting(PCollectionView<T> view) {
- this.view = view;
- }
-
- @Override
- public PCollectionView<T> apply(PBegin input) {
- return view;
- }
- }
-
- /**
- * An assertion checker that takes a single
- * {@link PCollectionView PCollectionView<ActualT>}
- * and an assertion over {@code ActualT}, and checks it within a dataflow
- * pipeline.
- *
- * <p>Note that the entire assertion must be serializable. If
- * you need to make assertions involving multiple inputs
- * that are each not serializable, use TwoSideInputAssert.
- *
- * <p>This is generally useful for assertion functions that
- * are serializable but whose underlying data may not have a coder.
- */
- static class OneSideInputAssert<ActualT>
- extends PTransform<PBegin, PDone> implements Serializable {
- private final transient PTransform<PBegin, PCollectionView<ActualT>> createActual;
- private final SerializableFunction<ActualT, Void> checkerFn;
-
- public OneSideInputAssert(
- PTransform<PBegin, PCollectionView<ActualT>> createActual,
- SerializableFunction<ActualT, Void> checkerFn) {
- this.createActual = createActual;
- this.checkerFn = checkerFn;
- }
-
- @Override
- public PDone apply(PBegin input) {
- final PCollectionView<ActualT> actual = input.apply("CreateActual", createActual);
-
- input
- .apply(Create.<Void>of((Void) null).withCoder(VoidCoder.of()))
- .apply(ParDo.named("RunChecks").withSideInputs(actual)
- .of(new CheckerDoFn<>(checkerFn, actual)));
-
- return PDone.in(input.getPipeline());
- }
- }
-
- /**
- * A {@link DoFn} that runs a checking {@link SerializableFunction} on the contents of
- * a {@link PCollectionView}, and adjusts counters and thrown exceptions for use in testing.
- */
- private static class CheckerDoFn<ActualT> extends DoFn<Void, Void> {
- private final SerializableFunction<ActualT, Void> checkerFn;
- private final Aggregator<Integer, Integer> success =
- createAggregator(SUCCESS_COUNTER, new Sum.SumIntegerFn());
- private final Aggregator<Integer, Integer> failure =
- createAggregator(FAILURE_COUNTER, new Sum.SumIntegerFn());
- private final PCollectionView<ActualT> actual;
-
- private CheckerDoFn(
- SerializableFunction<ActualT, Void> checkerFn,
- PCollectionView<ActualT> actual) {
- this.checkerFn = checkerFn;
- this.actual = actual;
- }
-
- @Override
- public void processElement(ProcessContext c) {
- try {
- ActualT actualContents = c.sideInput(actual);
- checkerFn.apply(actualContents);
- success.addValue(1);
- } catch (Throwable t) {
- LOG.error("DataflowAssert failed expectations.", t);
- failure.addValue(1);
- // TODO: allow for metrics to propagate on failure when running a streaming pipeline
- if (!c.getPipelineOptions().as(StreamingOptions.class).isStreaming()) {
- throw t;
- }
- }
- }
- }
-
- /**
- * An assertion checker that takes a {@link PCollectionView PCollectionView<ActualT>},
- * a {@link PCollectionView PCollectionView<ExpectedT>}, a relation
- * over {@code A} and {@code B}, and checks that the relation holds
- * within a dataflow pipeline.
- *
- * <p>This is useful when either/both of {@code A} and {@code B}
- * are not serializable, but have coders (provided
- * by the underlying {@link PCollection}s).
- */
- static class TwoSideInputAssert<ActualT, ExpectedT>
- extends PTransform<PBegin, PDone> implements Serializable {
-
- private final transient PTransform<PBegin, PCollectionView<ActualT>> createActual;
- private final transient PTransform<PBegin, PCollectionView<ExpectedT>> createExpected;
- private final AssertRelation<ActualT, ExpectedT> relation;
-
- protected TwoSideInputAssert(
- PTransform<PBegin, PCollectionView<ActualT>> createActual,
- PTransform<PBegin, PCollectionView<ExpectedT>> createExpected,
- AssertRelation<ActualT, ExpectedT> relation) {
- this.createActual = createActual;
- this.createExpected = createExpected;
- this.relation = relation;
- }
-
- @Override
- public PDone apply(PBegin input) {
- final PCollectionView<ActualT> actual = input.apply("CreateActual", createActual);
- final PCollectionView<ExpectedT> expected = input.apply("CreateExpected", createExpected);
-
- input
- .apply(Create.<Void>of((Void) null).withCoder(VoidCoder.of()))
- .apply(ParDo.named("RunChecks").withSideInputs(actual, expected)
- .of(new CheckerDoFn<>(relation, actual, expected)));
-
- return PDone.in(input.getPipeline());
- }
-
- private static class CheckerDoFn<ActualT, ExpectedT> extends DoFn<Void, Void> {
- private final Aggregator<Integer, Integer> success =
- createAggregator(SUCCESS_COUNTER, new Sum.SumIntegerFn());
- private final Aggregator<Integer, Integer> failure =
- createAggregator(FAILURE_COUNTER, new Sum.SumIntegerFn());
- private final AssertRelation<ActualT, ExpectedT> relation;
- private final PCollectionView<ActualT> actual;
- private final PCollectionView<ExpectedT> expected;
-
- private CheckerDoFn(AssertRelation<ActualT, ExpectedT> relation,
- PCollectionView<ActualT> actual, PCollectionView<ExpectedT> expected) {
- this.relation = relation;
- this.actual = actual;
- this.expected = expected;
- }
-
- @Override
- public void processElement(ProcessContext c) {
- try {
- ActualT actualContents = c.sideInput(actual);
- ExpectedT expectedContents = c.sideInput(expected);
- relation.assertFor(expectedContents).apply(actualContents);
- success.addValue(1);
- } catch (Throwable t) {
- LOG.error("DataflowAssert failed expectations.", t);
- failure.addValue(1);
- // TODO: allow for metrics to propagate on failure when running a streaming pipeline
- if (!c.getPipelineOptions().as(StreamingOptions.class).isStreaming()) {
- throw t;
- }
- }
- }
- }
- }
-
- /////////////////////////////////////////////////////////////////////////////
-
- /**
- * A {@link SerializableFunction} that verifies that an actual value is equal to an
- * expected value.
- */
- private static class AssertIsEqualTo<T> implements SerializableFunction<T, Void> {
- private T expected;
-
- public AssertIsEqualTo(T expected) {
- this.expected = expected;
- }
-
- @Override
- public Void apply(T actual) {
- assertThat(actual, equalTo(expected));
- return null;
- }
- }
-
- /**
- * A {@link SerializableFunction} that verifies that an actual value is not equal to an
- * expected value.
- */
- private static class AssertNotEqualTo<T> implements SerializableFunction<T, Void> {
- private T expected;
-
- public AssertNotEqualTo(T expected) {
- this.expected = expected;
- }
-
- @Override
- public Void apply(T actual) {
- assertThat(actual, not(equalTo(expected)));
- return null;
- }
- }
-
- /**
- * A {@link SerializableFunction} that verifies that an {@code Iterable} contains
- * expected items in any order.
- */
- private static class AssertContainsInAnyOrder<T>
- implements SerializableFunction<Iterable<T>, Void> {
- private T[] expected;
-
- @SafeVarargs
- public AssertContainsInAnyOrder(T... expected) {
- this.expected = expected;
- }
-
- @SuppressWarnings("unchecked")
- public AssertContainsInAnyOrder(Collection<T> expected) {
- this((T[]) expected.toArray());
- }
-
- public AssertContainsInAnyOrder(Iterable<T> expected) {
- this(Lists.<T>newArrayList(expected));
- }
-
- @Override
- public Void apply(Iterable<T> actual) {
- assertThat(actual, containsInAnyOrder(expected));
- return null;
- }
- }
-
- ////////////////////////////////////////////////////////////
-
- /**
- * A binary predicate between types {@code Actual} and {@code Expected}.
- * Implemented as a method {@code assertFor(Expected)} which returns
- * a {@code SerializableFunction<Actual, Void>}
- * that should verify the assertion..
- */
- private static interface AssertRelation<ActualT, ExpectedT> extends Serializable {
- public SerializableFunction<ActualT, Void> assertFor(ExpectedT input);
- }
-
- /**
- * An {@link AssertRelation} implementing the binary predicate that two objects are equal.
- */
- private static class AssertIsEqualToRelation<T>
- implements AssertRelation<T, T> {
- @Override
- public SerializableFunction<T, Void> assertFor(T expected) {
- return new AssertIsEqualTo<T>(expected);
- }
- }
-
- /**
- * An {@link AssertRelation} implementing the binary predicate that two objects are not equal.
- */
- private static class AssertNotEqualToRelation<T>
- implements AssertRelation<T, T> {
- @Override
- public SerializableFunction<T, Void> assertFor(T expected) {
- return new AssertNotEqualTo<T>(expected);
- }
- }
-
- /**
- * An {@code AssertRelation} implementing the binary predicate that two collections are equal
- * modulo reordering.
- */
- private static class AssertContainsInAnyOrderRelation<T>
- implements AssertRelation<Iterable<T>, Iterable<T>> {
- @Override
- public SerializableFunction<Iterable<T>, Void> assertFor(Iterable<T> expectedElements) {
- return new AssertContainsInAnyOrder<T>(expectedElements);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/PAssert.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/PAssert.java b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/PAssert.java
new file mode 100644
index 0000000..aebce42
--- /dev/null
+++ b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/PAssert.java
@@ -0,0 +1,825 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.dataflow.sdk.testing;
+
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertThat;
+
+import com.google.cloud.dataflow.sdk.Pipeline;
+import com.google.cloud.dataflow.sdk.coders.Coder;
+import com.google.cloud.dataflow.sdk.coders.CoderException;
+import com.google.cloud.dataflow.sdk.coders.IterableCoder;
+import com.google.cloud.dataflow.sdk.coders.KvCoder;
+import com.google.cloud.dataflow.sdk.coders.MapCoder;
+import com.google.cloud.dataflow.sdk.coders.VoidCoder;
+import com.google.cloud.dataflow.sdk.options.StreamingOptions;
+import com.google.cloud.dataflow.sdk.runners.PipelineRunner;
+import com.google.cloud.dataflow.sdk.transforms.Aggregator;
+import com.google.cloud.dataflow.sdk.transforms.Create;
+import com.google.cloud.dataflow.sdk.transforms.DoFn;
+import com.google.cloud.dataflow.sdk.transforms.PTransform;
+import com.google.cloud.dataflow.sdk.transforms.ParDo;
+import com.google.cloud.dataflow.sdk.transforms.SerializableFunction;
+import com.google.cloud.dataflow.sdk.transforms.Sum;
+import com.google.cloud.dataflow.sdk.transforms.View;
+import com.google.cloud.dataflow.sdk.transforms.windowing.GlobalWindows;
+import com.google.cloud.dataflow.sdk.transforms.windowing.Window;
+import com.google.cloud.dataflow.sdk.util.CoderUtils;
+import com.google.cloud.dataflow.sdk.values.KV;
+import com.google.cloud.dataflow.sdk.values.PBegin;
+import com.google.cloud.dataflow.sdk.values.PCollection;
+import com.google.cloud.dataflow.sdk.values.PCollectionView;
+import com.google.cloud.dataflow.sdk.values.PDone;
+import com.google.common.base.Optional;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+/**
+ * An assertion on the contents of a {@link PCollection}
+ * incorporated into the pipeline. Such an assertion
+ * can be checked no matter what kind of {@link PipelineRunner} is
+ * used.
+ *
+ * <p>Note that the {@code PAssert} call must precede the call
+ * to {@link Pipeline#run}.
+ *
+ * <p>Examples of use:
+ * <pre>{@code
+ * 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.that(sum)
+ * .is(42);
+ * ...
+ * p.run();
+ * }</pre>
+ *
+ * <p>JUnit and Hamcrest must be linked in by any code that uses PAssert.
+ */
+public class PAssert {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PAssert.class);
+
+ static final String SUCCESS_COUNTER = "PAssertSuccess";
+ static final String FAILURE_COUNTER = "PAssertFailure";
+
+ private static int assertCount = 0;
+
+ // Do not instantiate.
+ private PAssert() {}
+
+ /**
+ * Constructs an {@link IterableAssert} for the elements of the provided
+ * {@link PCollection}.
+ */
+ public static <T> IterableAssert<T> that(PCollection<T> actual) {
+ return new IterableAssert<>(
+ new CreateActual<T, Iterable<T>>(actual, View.<T>asIterable()),
+ actual.getPipeline())
+ .setCoder(actual.getCoder());
+ }
+
+ /**
+ * Constructs an {@link IterableAssert} for the value of the provided
+ * {@link PCollection} which must contain a single {@code Iterable<T>}
+ * value.
+ */
+ public static <T> IterableAssert<T>
+ thatSingletonIterable(PCollection<? extends Iterable<T>> actual) {
+
+ List<? extends Coder<?>> maybeElementCoder = actual.getCoder().getCoderArguments();
+ Coder<T> tCoder;
+ try {
+ @SuppressWarnings("unchecked")
+ Coder<T> tCoderTmp = (Coder<T>) Iterables.getOnlyElement(maybeElementCoder);
+ tCoder = tCoderTmp;
+ } catch (NoSuchElementException | IllegalArgumentException exc) {
+ throw new IllegalArgumentException(
+ "PAssert.<T>thatSingletonIterable requires a PCollection<Iterable<T>>"
+ + " with a Coder<Iterable<T>> where getCoderArguments() yields a"
+ + " single Coder<T> to apply to the elements.");
+ }
+
+ @SuppressWarnings("unchecked") // Safe covariant cast
+ PCollection<Iterable<T>> actualIterables = (PCollection<Iterable<T>>) actual;
+
+ return new IterableAssert<>(
+ new CreateActual<Iterable<T>, Iterable<T>>(
+ actualIterables, View.<Iterable<T>>asSingleton()),
+ actual.getPipeline())
+ .setCoder(tCoder);
+ }
+
+ /**
+ * Constructs an {@link IterableAssert} for the value of the provided
+ * {@code PCollectionView PCollectionView<Iterable<T>>}.
+ */
+ public static <T> IterableAssert<T> thatIterable(PCollectionView<Iterable<T>> actual) {
+ return new IterableAssert<>(new PreExisting<Iterable<T>>(actual), actual.getPipeline());
+ }
+
+ /**
+ * Constructs a {@link SingletonAssert} for the value of the provided
+ * {@code PCollection PCollection<T>}, which must be a singleton.
+ */
+ public static <T> SingletonAssert<T> thatSingleton(PCollection<T> actual) {
+ return new SingletonAssert<>(
+ new CreateActual<T, T>(actual, View.<T>asSingleton()), actual.getPipeline())
+ .setCoder(actual.getCoder());
+ }
+
+ /**
+ * Constructs a {@link SingletonAssert} for the value of the provided {@link PCollection}.
+ *
+ * <p>Note that the actual value must be coded by a {@link KvCoder},
+ * not just any {@code Coder<K, V>}.
+ */
+ public static <K, V> SingletonAssert<Map<K, Iterable<V>>>
+ thatMultimap(PCollection<KV<K, V>> actual) {
+ @SuppressWarnings("unchecked")
+ KvCoder<K, V> kvCoder = (KvCoder<K, V>) actual.getCoder();
+
+ return new SingletonAssert<>(
+ new CreateActual<>(actual, View.<K, V>asMultimap()), actual.getPipeline())
+ .setCoder(MapCoder.of(kvCoder.getKeyCoder(), IterableCoder.of(kvCoder.getValueCoder())));
+ }
+
+ /**
+ * Constructs a {@link SingletonAssert} for the value of the provided {@link PCollection},
+ * which must have at most one value per key.
+ *
+ * <p>Note that the actual value must be coded by a {@link KvCoder},
+ * not just any {@code Coder<K, V>}.
+ */
+ public static <K, V> SingletonAssert<Map<K, V>> thatMap(PCollection<KV<K, V>> actual) {
+ @SuppressWarnings("unchecked")
+ KvCoder<K, V> kvCoder = (KvCoder<K, V>) actual.getCoder();
+
+ return new SingletonAssert<>(
+ new CreateActual<>(actual, View.<K, V>asMap()), actual.getPipeline())
+ .setCoder(MapCoder.of(kvCoder.getKeyCoder(), kvCoder.getValueCoder()));
+ }
+
+ ////////////////////////////////////////////////////////////
+
+ /**
+ * An assertion about the contents of a {@link PCollectionView} yielding an {@code Iterable<T>}.
+ */
+ public static class IterableAssert<T> implements Serializable {
+ private final Pipeline pipeline;
+ private final PTransform<PBegin, PCollectionView<Iterable<T>>> createActual;
+ private Optional<Coder<T>> coder;
+
+ protected IterableAssert(
+ PTransform<PBegin, PCollectionView<Iterable<T>>> createActual, Pipeline pipeline) {
+ this.createActual = createActual;
+ this.pipeline = pipeline;
+ this.coder = Optional.absent();
+ }
+
+ /**
+ * Sets the coder to use for elements of type {@code T}, as needed for internal purposes.
+ *
+ * <p>Returns this {@code IterableAssert}.
+ */
+ public IterableAssert<T> setCoder(Coder<T> coderOrNull) {
+ this.coder = Optional.fromNullable(coderOrNull);
+ return this;
+ }
+
+ /**
+ * Gets the coder, which may yet be absent.
+ */
+ public Coder<T> getCoder() {
+ if (coder.isPresent()) {
+ return coder.get();
+ } else {
+ throw new IllegalStateException(
+ "Attempting to access the coder of an IterableAssert"
+ + " that has not been set yet.");
+ }
+ }
+
+ /**
+ * Applies a {@link SerializableFunction} to check the elements of the {@code Iterable}.
+ *
+ * <p>Returns this {@code IterableAssert}.
+ */
+ public IterableAssert<T> satisfies(SerializableFunction<Iterable<T>, Void> checkerFn) {
+ pipeline.apply(
+ "PAssert$" + (assertCount++),
+ new OneSideInputAssert<Iterable<T>>(createActual, checkerFn));
+ return this;
+ }
+
+ /**
+ * Applies a {@link SerializableFunction} to check the elements of the {@code Iterable}.
+ *
+ * <p>Returns this {@code IterableAssert}.
+ */
+ public IterableAssert<T> satisfies(
+ AssertRelation<Iterable<T>, Iterable<T>> relation,
+ final Iterable<T> expectedElements) {
+ pipeline.apply(
+ "PAssert$" + (assertCount++),
+ new TwoSideInputAssert<Iterable<T>, Iterable<T>>(
+ createActual,
+ new CreateExpected<T, Iterable<T>>(expectedElements, coder, View.<T>asIterable()),
+ relation));
+
+ return this;
+ }
+
+ /**
+ * Applies a {@link SerializableMatcher} to check the elements of the {@code Iterable}.
+ *
+ * <p>Returns this {@code IterableAssert}.
+ */
+ IterableAssert<T> satisfies(final SerializableMatcher<Iterable<? extends T>> matcher) {
+ // Safe covariant cast. Could be elided by changing a lot of this file to use
+ // more flexible bounds.
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ SerializableFunction<Iterable<T>, Void> checkerFn =
+ (SerializableFunction) new MatcherCheckerFn<>(matcher);
+ pipeline.apply(
+ "PAssert$" + (assertCount++),
+ new OneSideInputAssert<Iterable<T>>(createActual, checkerFn));
+ return this;
+ }
+
+ private static class MatcherCheckerFn<T> implements SerializableFunction<T, Void> {
+ private SerializableMatcher<T> matcher;
+
+ public MatcherCheckerFn(SerializableMatcher<T> matcher) {
+ this.matcher = matcher;
+ }
+
+ @Override
+ public Void apply(T actual) {
+ assertThat(actual, matcher);
+ return null;
+ }
+ }
+
+ /**
+ * Checks that the {@code Iterable} is empty.
+ *
+ * <p>Returns this {@code IterableAssert}.
+ */
+ public IterableAssert<T> empty() {
+ return satisfies(new AssertContainsInAnyOrderRelation<T>(), Collections.<T>emptyList());
+ }
+
+ /**
+ * @throws UnsupportedOperationException always
+ * @deprecated {@link Object#equals(Object)} is not supported on PAssert objects.
+ * If you meant to test object equality, use a variant of {@link #containsInAnyOrder}
+ * instead.
+ */
+ @Deprecated
+ @Override
+ public boolean equals(Object o) {
+ throw new UnsupportedOperationException(
+ "If you meant to test object equality, use .containsInAnyOrder instead.");
+ }
+
+ /**
+ * @throws UnsupportedOperationException always.
+ * @deprecated {@link Object#hashCode()} is not supported on PAssert objects.
+ */
+ @Deprecated
+ @Override
+ public int hashCode() {
+ throw new UnsupportedOperationException(
+ String.format("%s.hashCode() is not supported.", IterableAssert.class.getSimpleName()));
+ }
+
+ /**
+ * Checks that the {@code Iterable} contains the expected elements, in any
+ * order.
+ *
+ * <p>Returns this {@code IterableAssert}.
+ */
+ public IterableAssert<T> containsInAnyOrder(Iterable<T> expectedElements) {
+ return satisfies(new AssertContainsInAnyOrderRelation<T>(), expectedElements);
+ }
+
+ /**
+ * Checks that the {@code Iterable} contains the expected elements, in any
+ * order.
+ *
+ * <p>Returns this {@code IterableAssert}.
+ */
+ @SafeVarargs
+ public final IterableAssert<T> containsInAnyOrder(T... expectedElements) {
+ return satisfies(
+ new AssertContainsInAnyOrderRelation<T>(),
+ Arrays.asList(expectedElements));
+ }
+
+ /**
+ * Checks that the {@code Iterable} contains elements that match the provided matchers,
+ * in any order.
+ *
+ * <p>Returns this {@code IterableAssert}.
+ */
+ @SafeVarargs
+ final IterableAssert<T> containsInAnyOrder(
+ SerializableMatcher<? super T>... elementMatchers) {
+ return satisfies(SerializableMatchers.<T>containsInAnyOrder(elementMatchers));
+ }
+ }
+
+ /**
+ * An assertion about the single value of type {@code T}
+ * associated with a {@link PCollectionView}.
+ */
+ public static class SingletonAssert<T> implements Serializable {
+ private final Pipeline pipeline;
+ private final CreateActual<?, T> createActual;
+ private Optional<Coder<T>> coder;
+
+ protected SingletonAssert(
+ CreateActual<?, T> createActual, Pipeline pipeline) {
+ this.pipeline = pipeline;
+ this.createActual = createActual;
+ this.coder = Optional.absent();
+ }
+
+ /**
+ * Always throws an {@link UnsupportedOperationException}: users are probably looking for
+ * {@link #isEqualTo}.
+ */
+ @Deprecated
+ @Override
+ public boolean equals(Object o) {
+ throw new UnsupportedOperationException(
+ String.format(
+ "tests for Java equality of the %s object, not the PCollection in question. "
+ + "Call a test method, such as isEqualTo.",
+ getClass().getSimpleName()));
+ }
+
+ /**
+ * @throws UnsupportedOperationException always.
+ * @deprecated {@link Object#hashCode()} is not supported on PAssert objects.
+ */
+ @Deprecated
+ @Override
+ public int hashCode() {
+ throw new UnsupportedOperationException(
+ String.format("%s.hashCode() is not supported.", SingletonAssert.class.getSimpleName()));
+ }
+
+ /**
+ * Sets the coder to use for elements of type {@code T}, as needed
+ * for internal purposes.
+ *
+ * <p>Returns this {@code IterableAssert}.
+ */
+ public SingletonAssert<T> setCoder(Coder<T> coderOrNull) {
+ this.coder = Optional.fromNullable(coderOrNull);
+ return this;
+ }
+
+ /**
+ * Gets the coder, which may yet be absent.
+ */
+ public Coder<T> getCoder() {
+ if (coder.isPresent()) {
+ return coder.get();
+ } else {
+ throw new IllegalStateException(
+ "Attempting to access the coder of an IterableAssert that has not been set yet.");
+ }
+ }
+
+ /**
+ * Applies a {@link SerializableFunction} to check the value of this
+ * {@code SingletonAssert}'s view.
+ *
+ * <p>Returns this {@code SingletonAssert}.
+ */
+ public SingletonAssert<T> satisfies(SerializableFunction<T, Void> checkerFn) {
+ pipeline.apply(
+ "PAssert$" + (assertCount++), new OneSideInputAssert<T>(createActual, checkerFn));
+ return this;
+ }
+
+ /**
+ * Applies an {@link AssertRelation} to check the provided relation against the
+ * value of this assert and the provided expected value.
+ *
+ * <p>Returns this {@code SingletonAssert}.
+ */
+ public SingletonAssert<T> satisfies(
+ AssertRelation<T, T> relation,
+ final T expectedValue) {
+ pipeline.apply(
+ "PAssert$" + (assertCount++),
+ new TwoSideInputAssert<T, T>(
+ createActual,
+ new CreateExpected<T, T>(Arrays.asList(expectedValue), coder, View.<T>asSingleton()),
+ relation));
+
+ return this;
+ }
+
+ /**
+ * Checks that the value of this {@code SingletonAssert}'s view is equal
+ * to the expected value.
+ *
+ * <p>Returns this {@code SingletonAssert}.
+ */
+ public SingletonAssert<T> isEqualTo(T expectedValue) {
+ return satisfies(new AssertIsEqualToRelation<T>(), expectedValue);
+ }
+
+ /**
+ * Checks that the value of this {@code SingletonAssert}'s view is not equal
+ * to the expected value.
+ *
+ * <p>Returns this {@code SingletonAssert}.
+ */
+ public SingletonAssert<T> notEqualTo(T expectedValue) {
+ return satisfies(new AssertNotEqualToRelation<T>(), expectedValue);
+ }
+
+ /**
+ * Checks that the value of this {@code SingletonAssert}'s view is equal to
+ * the expected value.
+ *
+ * @deprecated replaced by {@link #isEqualTo}
+ */
+ @Deprecated
+ public SingletonAssert<T> is(T expectedValue) {
+ return isEqualTo(expectedValue);
+ }
+
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+
+ private static class CreateActual<T, ActualT>
+ extends PTransform<PBegin, PCollectionView<ActualT>> {
+
+ private final transient PCollection<T> actual;
+ private final transient PTransform<PCollection<T>, PCollectionView<ActualT>> actualView;
+
+ private CreateActual(PCollection<T> actual,
+ PTransform<PCollection<T>, PCollectionView<ActualT>> actualView) {
+ this.actual = actual;
+ this.actualView = actualView;
+ }
+
+ @Override
+ public PCollectionView<ActualT> apply(PBegin input) {
+ final Coder<T> coder = actual.getCoder();
+ return actual
+ .apply(Window.<T>into(new GlobalWindows()))
+ .apply(ParDo.of(new DoFn<T, T>() {
+ @Override
+ public void processElement(ProcessContext context) throws CoderException {
+ context.output(CoderUtils.clone(coder, context.element()));
+ }
+ }))
+ .apply(actualView);
+ }
+ }
+
+ private static class CreateExpected<T, ExpectedT>
+ extends PTransform<PBegin, PCollectionView<ExpectedT>> {
+
+ private final Iterable<T> elements;
+ private final Optional<Coder<T>> coder;
+ private final transient PTransform<PCollection<T>, PCollectionView<ExpectedT>> view;
+
+ private CreateExpected(Iterable<T> elements, Optional<Coder<T>> coder,
+ PTransform<PCollection<T>, PCollectionView<ExpectedT>> view) {
+ this.elements = elements;
+ this.coder = coder;
+ this.view = view;
+ }
+
+ @Override
+ public PCollectionView<ExpectedT> apply(PBegin input) {
+ Create.Values<T> createTransform = Create.<T>of(elements);
+ if (coder.isPresent()) {
+ createTransform = createTransform.withCoder(coder.get());
+ }
+ return input.apply(createTransform).apply(view);
+ }
+ }
+
+ private static class PreExisting<T> extends PTransform<PBegin, PCollectionView<T>> {
+
+ private final PCollectionView<T> view;
+
+ private PreExisting(PCollectionView<T> view) {
+ this.view = view;
+ }
+
+ @Override
+ public PCollectionView<T> apply(PBegin input) {
+ return view;
+ }
+ }
+
+ /**
+ * An assertion checker that takes a single
+ * {@link PCollectionView PCollectionView<ActualT>}
+ * and an assertion over {@code ActualT}, and checks it within a dataflow
+ * pipeline.
+ *
+ * <p>Note that the entire assertion must be serializable. If
+ * you need to make assertions involving multiple inputs
+ * that are each not serializable, use TwoSideInputAssert.
+ *
+ * <p>This is generally useful for assertion functions that
+ * are serializable but whose underlying data may not have a coder.
+ */
+ static class OneSideInputAssert<ActualT>
+ extends PTransform<PBegin, PDone> implements Serializable {
+ private final transient PTransform<PBegin, PCollectionView<ActualT>> createActual;
+ private final SerializableFunction<ActualT, Void> checkerFn;
+
+ public OneSideInputAssert(
+ PTransform<PBegin, PCollectionView<ActualT>> createActual,
+ SerializableFunction<ActualT, Void> checkerFn) {
+ this.createActual = createActual;
+ this.checkerFn = checkerFn;
+ }
+
+ @Override
+ public PDone apply(PBegin input) {
+ final PCollectionView<ActualT> actual = input.apply("CreateActual", createActual);
+
+ input
+ .apply(Create.<Void>of((Void) null).withCoder(VoidCoder.of()))
+ .apply(ParDo.named("RunChecks").withSideInputs(actual)
+ .of(new CheckerDoFn<>(checkerFn, actual)));
+
+ return PDone.in(input.getPipeline());
+ }
+ }
+
+ /**
+ * A {@link DoFn} that runs a checking {@link SerializableFunction} on the contents of
+ * a {@link PCollectionView}, and adjusts counters and thrown exceptions for use in testing.
+ */
+ private static class CheckerDoFn<ActualT> extends DoFn<Void, Void> {
+ private final SerializableFunction<ActualT, Void> checkerFn;
+ private final Aggregator<Integer, Integer> success =
+ createAggregator(SUCCESS_COUNTER, new Sum.SumIntegerFn());
+ private final Aggregator<Integer, Integer> failure =
+ createAggregator(FAILURE_COUNTER, new Sum.SumIntegerFn());
+ private final PCollectionView<ActualT> actual;
+
+ private CheckerDoFn(
+ SerializableFunction<ActualT, Void> checkerFn,
+ PCollectionView<ActualT> actual) {
+ this.checkerFn = checkerFn;
+ this.actual = actual;
+ }
+
+ @Override
+ public void processElement(ProcessContext c) {
+ try {
+ ActualT actualContents = c.sideInput(actual);
+ checkerFn.apply(actualContents);
+ success.addValue(1);
+ } catch (Throwable t) {
+ LOG.error("PAssert failed expectations.", t);
+ failure.addValue(1);
+ // TODO: allow for metrics to propagate on failure when running a streaming pipeline
+ if (!c.getPipelineOptions().as(StreamingOptions.class).isStreaming()) {
+ throw t;
+ }
+ }
+ }
+ }
+
+ /**
+ * An assertion checker that takes a {@link PCollectionView PCollectionView<ActualT>},
+ * a {@link PCollectionView PCollectionView<ExpectedT>}, a relation
+ * over {@code A} and {@code B}, and checks that the relation holds
+ * within a dataflow pipeline.
+ *
+ * <p>This is useful when either/both of {@code A} and {@code B}
+ * are not serializable, but have coders (provided
+ * by the underlying {@link PCollection}s).
+ */
+ static class TwoSideInputAssert<ActualT, ExpectedT>
+ extends PTransform<PBegin, PDone> implements Serializable {
+
+ private final transient PTransform<PBegin, PCollectionView<ActualT>> createActual;
+ private final transient PTransform<PBegin, PCollectionView<ExpectedT>> createExpected;
+ private final AssertRelation<ActualT, ExpectedT> relation;
+
+ protected TwoSideInputAssert(
+ PTransform<PBegin, PCollectionView<ActualT>> createActual,
+ PTransform<PBegin, PCollectionView<ExpectedT>> createExpected,
+ AssertRelation<ActualT, ExpectedT> relation) {
+ this.createActual = createActual;
+ this.createExpected = createExpected;
+ this.relation = relation;
+ }
+
+ @Override
+ public PDone apply(PBegin input) {
+ final PCollectionView<ActualT> actual = input.apply("CreateActual", createActual);
+ final PCollectionView<ExpectedT> expected = input.apply("CreateExpected", createExpected);
+
+ input
+ .apply(Create.<Void>of((Void) null).withCoder(VoidCoder.of()))
+ .apply(ParDo.named("RunChecks").withSideInputs(actual, expected)
+ .of(new CheckerDoFn<>(relation, actual, expected)));
+
+ return PDone.in(input.getPipeline());
+ }
+
+ private static class CheckerDoFn<ActualT, ExpectedT> extends DoFn<Void, Void> {
+ private final Aggregator<Integer, Integer> success =
+ createAggregator(SUCCESS_COUNTER, new Sum.SumIntegerFn());
+ private final Aggregator<Integer, Integer> failure =
+ createAggregator(FAILURE_COUNTER, new Sum.SumIntegerFn());
+ private final AssertRelation<ActualT, ExpectedT> relation;
+ private final PCollectionView<ActualT> actual;
+ private final PCollectionView<ExpectedT> expected;
+
+ private CheckerDoFn(AssertRelation<ActualT, ExpectedT> relation,
+ PCollectionView<ActualT> actual, PCollectionView<ExpectedT> expected) {
+ this.relation = relation;
+ this.actual = actual;
+ this.expected = expected;
+ }
+
+ @Override
+ public void processElement(ProcessContext c) {
+ try {
+ ActualT actualContents = c.sideInput(actual);
+ ExpectedT expectedContents = c.sideInput(expected);
+ relation.assertFor(expectedContents).apply(actualContents);
+ success.addValue(1);
+ } catch (Throwable t) {
+ LOG.error("PAssert failed expectations.", t);
+ failure.addValue(1);
+ // TODO: allow for metrics to propagate on failure when running a streaming pipeline
+ if (!c.getPipelineOptions().as(StreamingOptions.class).isStreaming()) {
+ throw t;
+ }
+ }
+ }
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * A {@link SerializableFunction} that verifies that an actual value is equal to an
+ * expected value.
+ */
+ private static class AssertIsEqualTo<T> implements SerializableFunction<T, Void> {
+ private T expected;
+
+ public AssertIsEqualTo(T expected) {
+ this.expected = expected;
+ }
+
+ @Override
+ public Void apply(T actual) {
+ assertThat(actual, equalTo(expected));
+ return null;
+ }
+ }
+
+ /**
+ * A {@link SerializableFunction} that verifies that an actual value is not equal to an
+ * expected value.
+ */
+ private static class AssertNotEqualTo<T> implements SerializableFunction<T, Void> {
+ private T expected;
+
+ public AssertNotEqualTo(T expected) {
+ this.expected = expected;
+ }
+
+ @Override
+ public Void apply(T actual) {
+ assertThat(actual, not(equalTo(expected)));
+ return null;
+ }
+ }
+
+ /**
+ * A {@link SerializableFunction} that verifies that an {@code Iterable} contains
+ * expected items in any order.
+ */
+ private static class AssertContainsInAnyOrder<T>
+ implements SerializableFunction<Iterable<T>, Void> {
+ private T[] expected;
+
+ @SafeVarargs
+ public AssertContainsInAnyOrder(T... expected) {
+ this.expected = expected;
+ }
+
+ @SuppressWarnings("unchecked")
+ public AssertContainsInAnyOrder(Collection<T> expected) {
+ this((T[]) expected.toArray());
+ }
+
+ public AssertContainsInAnyOrder(Iterable<T> expected) {
+ this(Lists.<T>newArrayList(expected));
+ }
+
+ @Override
+ public Void apply(Iterable<T> actual) {
+ assertThat(actual, containsInAnyOrder(expected));
+ return null;
+ }
+ }
+
+ ////////////////////////////////////////////////////////////
+
+ /**
+ * A binary predicate between types {@code Actual} and {@code Expected}.
+ * Implemented as a method {@code assertFor(Expected)} which returns
+ * a {@code SerializableFunction<Actual, Void>}
+ * that should verify the assertion..
+ */
+ private static interface AssertRelation<ActualT, ExpectedT> extends Serializable {
+ public SerializableFunction<ActualT, Void> assertFor(ExpectedT input);
+ }
+
+ /**
+ * An {@link AssertRelation} implementing the binary predicate that two objects are equal.
+ */
+ private static class AssertIsEqualToRelation<T>
+ implements AssertRelation<T, T> {
+ @Override
+ public SerializableFunction<T, Void> assertFor(T expected) {
+ return new AssertIsEqualTo<T>(expected);
+ }
+ }
+
+ /**
+ * An {@link AssertRelation} implementing the binary predicate that two objects are not equal.
+ */
+ private static class AssertNotEqualToRelation<T>
+ implements AssertRelation<T, T> {
+ @Override
+ public SerializableFunction<T, Void> assertFor(T expected) {
+ return new AssertNotEqualTo<T>(expected);
+ }
+ }
+
+ /**
+ * An {@code AssertRelation} implementing the binary predicate that two collections are equal
+ * modulo reordering.
+ */
+ private static class AssertContainsInAnyOrderRelation<T>
+ implements AssertRelation<Iterable<T>, Iterable<T>> {
+ @Override
+ public SerializableFunction<Iterable<T>, Void> assertFor(Iterable<T> expectedElements) {
+ return new AssertContainsInAnyOrder<T>(expectedElements);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/SerializableMatcher.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/SerializableMatcher.java b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/SerializableMatcher.java
index 879d7e2..238e0d1 100644
--- a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/SerializableMatcher.java
+++ b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/SerializableMatcher.java
@@ -24,7 +24,7 @@ import java.io.Serializable;
/**
* A {@link Matcher} that is also {@link Serializable}.
*
- * <p>Such matchers can be used with {@link DataflowAssert}, which builds Dataflow pipelines
+ * <p>Such matchers can be used with {@link PAssert}, which builds Dataflow pipelines
* such that these matchers may be serialized and executed remotely.
*
* <p>To create a {@code SerializableMatcher}, extend {@link org.hamcrest.BaseMatcher}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/SourceTestUtils.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/SourceTestUtils.java b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/SourceTestUtils.java
index a0b4ffd..feff16a 100644
--- a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/SourceTestUtils.java
+++ b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/SourceTestUtils.java
@@ -71,7 +71,7 @@ import java.util.concurrent.Future;
* {@link com.google.cloud.dataflow.sdk.io.AvroSource} or
* {@link com.google.cloud.dataflow.sdk.io.XmlSource}.
*
- * <p>Like {@link DataflowAssert}, requires JUnit and Hamcrest to be present in the classpath.
+ * <p>Like {@link PAssert}, requires JUnit and Hamcrest to be present in the classpath.
*/
public class SourceTestUtils {
private static final Logger LOG = LoggerFactory.getLogger(SourceTestUtils.class);
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/TestDataflowPipelineRunner.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/TestDataflowPipelineRunner.java b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/TestDataflowPipelineRunner.java
index 065d808..8f7374f 100644
--- a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/TestDataflowPipelineRunner.java
+++ b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/TestDataflowPipelineRunner.java
@@ -158,8 +158,8 @@ public class TestDataflowPipelineRunner extends PipelineRunner<DataflowPipelineJ
@Override
public <OutputT extends POutput, InputT extends PInput> OutputT apply(
PTransform<InputT, OutputT> transform, InputT input) {
- if (transform instanceof DataflowAssert.OneSideInputAssert
- || transform instanceof DataflowAssert.TwoSideInputAssert) {
+ if (transform instanceof PAssert.OneSideInputAssert
+ || transform instanceof PAssert.TwoSideInputAssert) {
expectedNumberOfAssertions += 1;
}
@@ -188,9 +188,9 @@ public class TestDataflowPipelineRunner extends PipelineRunner<DataflowPipelineJ
// Don't double count using the non-tentative version of the metric.
continue;
}
- if (DataflowAssert.SUCCESS_COUNTER.equals(metric.getName().getName())) {
+ if (PAssert.SUCCESS_COUNTER.equals(metric.getName().getName())) {
successes += ((BigDecimal) metric.getScalar()).intValue();
- } else if (DataflowAssert.FAILURE_COUNTER.equals(metric.getName().getName())) {
+ } else if (PAssert.FAILURE_COUNTER.equals(metric.getName().getName())) {
failures += ((BigDecimal) metric.getScalar()).intValue();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/TestPipeline.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/TestPipeline.java b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/TestPipeline.java
index e97e90f..98d4823 100644
--- a/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/TestPipeline.java
+++ b/sdks/java/core/src/main/java/com/google/cloud/dataflow/sdk/testing/TestPipeline.java
@@ -55,14 +55,14 @@ import javax.annotation.Nullable;
* <li> Jars containing the SDK and test classes must be added to the test classpath.
* </ul>
*
- * <p>Use {@link DataflowAssert} for tests, as it integrates with this test
+ * <p>Use {@link PAssert} for tests, as it integrates with this test
* harness in both direct and remote execution modes. For example:
*
* <pre>{@code
* Pipeline p = TestPipeline.create();
* PCollection<Integer> output = ...
*
- * DataflowAssert.that(output)
+ * PAssert.that(output)
* .containsInAnyOrder(1, 2, 3, 4);
* p.run();
* }</pre>
@@ -75,7 +75,7 @@ public class TestPipeline extends Pipeline {
/**
* Creates and returns a new test pipeline.
*
- * <p>Use {@link DataflowAssert} to add tests, then call
+ * <p>Use {@link PAssert} to add tests, then call
* {@link Pipeline#run} to execute the pipeline and check the tests.
*/
public static TestPipeline create() {
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/PipelineTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/PipelineTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/PipelineTest.java
index 8463f8c..e6a6426 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/PipelineTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/PipelineTest.java
@@ -30,8 +30,8 @@ import com.google.cloud.dataflow.sdk.options.PipelineOptions.CheckEnabled;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
import com.google.cloud.dataflow.sdk.runners.DirectPipelineRunner;
import com.google.cloud.dataflow.sdk.runners.PipelineRunner;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
import com.google.cloud.dataflow.sdk.testing.ExpectedLogs;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -137,7 +137,7 @@ public class PipelineTest {
PCollection<String> both = PCollectionList.of(left).and(right)
.apply(Flatten.<String>pCollections());
- DataflowAssert.that(both).containsInAnyOrder("a++", "b++", "a+", "b+");
+ PAssert.that(both).containsInAnyOrder("a++", "b++", "a+", "b+");
p.run();
}
@@ -205,7 +205,7 @@ public class PipelineTest {
.apply(Create.<Integer>of(1, 2, 3, 4))
.apply("IdentityTransform", new IdentityTransform<PCollection<Integer>>());
- DataflowAssert.that(output).containsInAnyOrder(1, 2, 3, 4);
+ PAssert.that(output).containsInAnyOrder(1, 2, 3, 4);
pipeline.run();
}
@@ -234,7 +234,7 @@ public class PipelineTest {
PCollection<Integer> output = tuple
.apply("ProjectTag", new TupleProjectionTransform<Integer>(tag));
- DataflowAssert.that(output).containsInAnyOrder(1, 2, 3, 4);
+ PAssert.that(output).containsInAnyOrder(1, 2, 3, 4);
pipeline.run();
}
@@ -268,7 +268,7 @@ public class PipelineTest {
PCollectionTuple output = input
.apply("ProjectTag", new TupleInjectionTransform<Integer>(tag));
- DataflowAssert.that(output.get(tag)).containsInAnyOrder(1, 2, 3, 4);
+ PAssert.that(output.get(tag)).containsInAnyOrder(1, 2, 3, 4);
pipeline.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/coders/AvroCoderTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/coders/AvroCoderTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/coders/AvroCoderTest.java
index 021b4a5..d938a1c 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/coders/AvroCoderTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/coders/AvroCoderTest.java
@@ -27,7 +27,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.Coder.Context;
import com.google.cloud.dataflow.sdk.coders.Coder.NonDeterministicException;
import com.google.cloud.dataflow.sdk.testing.CoderProperties;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.transforms.DoFn;
@@ -220,7 +220,7 @@ public class AvroCoderTest {
p.apply(Create.of(new Pojo("hello", 1), new Pojo("world", 2)))
.apply(ParDo.of(new GetTextFn()));
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder("hello", "world");
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/coders/SerializableCoderTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/coders/SerializableCoderTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/coders/SerializableCoderTest.java
index ac2136a..799da7c 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/coders/SerializableCoderTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/coders/SerializableCoderTest.java
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertNull;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.testing.CoderProperties;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.transforms.DoFn;
@@ -139,7 +139,7 @@ public class SerializableCoderTest implements Serializable {
.apply(ParDo.of(new StringToRecord()))
.apply(ParDo.of(new RecordToString()));
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder("Hello", "World");
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/AvroIOTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/AvroIOTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/AvroIOTest.java
index ccc24d5..7949b9f 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/AvroIOTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/AvroIOTest.java
@@ -27,7 +27,7 @@ import com.google.cloud.dataflow.sdk.coders.AvroCoder;
import com.google.cloud.dataflow.sdk.coders.DefaultCoder;
import com.google.cloud.dataflow.sdk.io.AvroIO.Write.Bound;
import com.google.cloud.dataflow.sdk.runners.DirectPipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.util.IOChannelUtils;
@@ -130,7 +130,7 @@ public class AvroIOTest {
PCollection<GenericClass> input = p
.apply(AvroIO.Read.from(outputFile.getAbsolutePath()).withSchema(GenericClass.class));
- DataflowAssert.that(input).containsInAnyOrder(values);
+ PAssert.that(input).containsInAnyOrder(values);
p.run();
}
@@ -195,7 +195,7 @@ public class AvroIOTest {
PCollection<GenericClassV2> input = p
.apply(AvroIO.Read.from(outputFile.getAbsolutePath()).withSchema(GenericClassV2.class));
- DataflowAssert.that(input).containsInAnyOrder(expected);
+ PAssert.that(input).containsInAnyOrder(expected);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/BoundedReadFromUnboundedSourceTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/BoundedReadFromUnboundedSourceTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/BoundedReadFromUnboundedSourceTest.java
index a98402d..24b0fca 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/BoundedReadFromUnboundedSourceTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/BoundedReadFromUnboundedSourceTest.java
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.runners.DirectPipelineRunner;
import com.google.cloud.dataflow.sdk.runners.dataflow.TestCountingSource;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.SerializableFunction;
@@ -126,7 +126,7 @@ public class BoundedReadFromUnboundedSourceTest {
// Because some of the NUM_RECORDS elements read are dupes, the final output
// will only have output from 0 to n where n < NUM_RECORDS.
- DataflowAssert.that(output).satisfies(new Checker(dedup, timeBound));
+ PAssert.that(output).satisfies(new Checker(dedup, timeBound));
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CompressedSourceTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CompressedSourceTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CompressedSourceTest.java
index 3de0513..331c896 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CompressedSourceTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CompressedSourceTest.java
@@ -29,7 +29,7 @@ import com.google.cloud.dataflow.sdk.io.CompressedSource.CompressionMode;
import com.google.cloud.dataflow.sdk.io.CompressedSource.DecompressingChannelFactory;
import com.google.cloud.dataflow.sdk.options.PipelineOptions;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.SourceTestUtils;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.PCollection;
@@ -140,7 +140,7 @@ public class CompressedSourceTest {
.withDecompression(CompressionMode.GZIP);
PCollection<Byte> output = p.apply(Read.from(source));
- DataflowAssert.that(output).containsInAnyOrder(Bytes.asList(expected));
+ PAssert.that(output).containsInAnyOrder(Bytes.asList(expected));
p.run();
}
@@ -210,7 +210,7 @@ public class CompressedSourceTest {
CompressedSource.from(new ByteSource(filePattern, 1));
PCollection<Byte> output = p.apply(Read.from(source));
- DataflowAssert.that(output).containsInAnyOrder(expected);
+ PAssert.that(output).containsInAnyOrder(expected);
p.run();
}
@@ -327,7 +327,7 @@ public class CompressedSourceTest {
.withDecompression(CompressionMode.GZIP);
PCollection<Byte> output = p.apply(Read.from(source));
- DataflowAssert.that(output).containsInAnyOrder(expected);
+ PAssert.that(output).containsInAnyOrder(expected);
p.run();
}
@@ -389,7 +389,7 @@ public class CompressedSourceTest {
source = source.withDecompression(decompressionFactory);
}
PCollection<Byte> output = p.apply(Read.from(source));
- DataflowAssert.that(output).containsInAnyOrder(Bytes.asList(expected));
+ PAssert.that(output).containsInAnyOrder(Bytes.asList(expected));
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CountingInputTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CountingInputTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CountingInputTest.java
index 5a7c2fb..2b369ed 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CountingInputTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CountingInputTest.java
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertThat;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.io.CountingInput.UnboundedCountingInput;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Count;
@@ -49,18 +49,18 @@ import org.junit.runners.JUnit4;
public class CountingInputTest {
public static void addCountingAsserts(PCollection<Long> input, long numElements) {
// Count == numElements
- DataflowAssert.thatSingleton(input.apply("Count", Count.<Long>globally()))
+ PAssert.thatSingleton(input.apply("Count", Count.<Long>globally()))
.isEqualTo(numElements);
// Unique count == numElements
- DataflowAssert.thatSingleton(
+ PAssert.thatSingleton(
input
.apply(RemoveDuplicates.<Long>create())
.apply("UniqueCount", Count.<Long>globally()))
.isEqualTo(numElements);
// Min == 0
- DataflowAssert.thatSingleton(input.apply("Min", Min.<Long>globally())).isEqualTo(0L);
+ PAssert.thatSingleton(input.apply("Min", Min.<Long>globally())).isEqualTo(0L);
// Max == numElements-1
- DataflowAssert.thatSingleton(input.apply("Max", Max.<Long>globally()))
+ PAssert.thatSingleton(input.apply("Max", Max.<Long>globally()))
.isEqualTo(numElements - 1);
}
@@ -133,7 +133,7 @@ public class CountingInputTest {
.apply("TimestampDiff", ParDo.of(new ElementValueDiff()))
.apply("RemoveDuplicateTimestamps", RemoveDuplicates.<Long>create());
// This assert also confirms that diffs only has one unique value.
- DataflowAssert.thatSingleton(diffs).isEqualTo(0L);
+ PAssert.thatSingleton(diffs).isEqualTo(0L);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CountingSourceTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CountingSourceTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CountingSourceTest.java
index 09c1f2a..5abd081 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CountingSourceTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/CountingSourceTest.java
@@ -27,7 +27,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.io.CountingSource.CounterMark;
import com.google.cloud.dataflow.sdk.io.CountingSource.UnboundedCountingSource;
import com.google.cloud.dataflow.sdk.io.UnboundedSource.UnboundedReader;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Count;
@@ -59,20 +59,20 @@ public class CountingSourceTest {
public static void addCountingAsserts(PCollection<Long> input, long numElements) {
// Count == numElements
- DataflowAssert
+ PAssert
.thatSingleton(input.apply("Count", Count.<Long>globally()))
.isEqualTo(numElements);
// Unique count == numElements
- DataflowAssert
+ PAssert
.thatSingleton(input.apply(RemoveDuplicates.<Long>create())
.apply("UniqueCount", Count.<Long>globally()))
.isEqualTo(numElements);
// Min == 0
- DataflowAssert
+ PAssert
.thatSingleton(input.apply("Min", Min.<Long>globally()))
.isEqualTo(0L);
// Max == numElements-1
- DataflowAssert
+ PAssert
.thatSingleton(input.apply("Max", Max.<Long>globally()))
.isEqualTo(numElements - 1);
}
@@ -150,7 +150,7 @@ public class CountingSourceTest {
.apply("TimestampDiff", ParDo.of(new ElementValueDiff()))
.apply("RemoveDuplicateTimestamps", RemoveDuplicates.<Long>create());
// This assert also confirms that diffs only has one unique value.
- DataflowAssert.thatSingleton(diffs).isEqualTo(0L);
+ PAssert.thatSingleton(diffs).isEqualTo(0L);
p.run();
}
@@ -176,7 +176,7 @@ public class CountingSourceTest {
.apply("TimestampDiff", ParDo.of(new ElementValueDiff()))
.apply("RemoveDuplicateTimestamps", RemoveDuplicates.<Long>create());
// This assert also confirms that diffs only has one unique value.
- DataflowAssert.thatSingleton(diffs).isEqualTo(0L);
+ PAssert.thatSingleton(diffs).isEqualTo(0L);
Instant started = Instant.now();
p.run();
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/FileBasedSourceTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/FileBasedSourceTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/FileBasedSourceTest.java
index d7a2e09..1071a67 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/FileBasedSourceTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/FileBasedSourceTest.java
@@ -35,7 +35,7 @@ import com.google.cloud.dataflow.sdk.io.FileBasedSource.FileBasedReader;
import com.google.cloud.dataflow.sdk.io.Source.Reader;
import com.google.cloud.dataflow.sdk.options.PipelineOptions;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.util.CoderUtils;
import com.google.cloud.dataflow.sdk.util.IOChannelFactory;
@@ -715,7 +715,7 @@ public class FileBasedSourceTest {
TestFileBasedSource source = new TestFileBasedSource(file.getPath(), 64, null);
PCollection<String> output = p.apply(Read.from(source).named("ReadFileData"));
- DataflowAssert.that(output).containsInAnyOrder(data);
+ PAssert.that(output).containsInAnyOrder(data);
p.run();
}
@@ -745,7 +745,7 @@ public class FileBasedSourceTest {
expectedResults.addAll(data2);
expectedResults.addAll(data3);
- DataflowAssert.that(output).containsInAnyOrder(expectedResults);
+ PAssert.that(output).containsInAnyOrder(expectedResults);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/TextIOTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/TextIOTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/TextIOTest.java
index 5a9a8c6..bc3a6fe 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/TextIOTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/TextIOTest.java
@@ -35,7 +35,7 @@ import com.google.cloud.dataflow.sdk.coders.VoidCoder;
import com.google.cloud.dataflow.sdk.io.TextIO.CompressionType;
import com.google.cloud.dataflow.sdk.io.TextIO.TextSource;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.SourceTestUtils;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
@@ -100,7 +100,7 @@ public class TextIOTest {
PCollection<T> output = p.apply(read);
- DataflowAssert.that(output).containsInAnyOrder(expected);
+ PAssert.that(output).containsInAnyOrder(expected);
p.run();
}
@@ -340,7 +340,7 @@ public class TextIOTest {
TextIO.Read.from(filename).withCompressionType(CompressionType.GZIP);
PCollection<String> output = p.apply(read);
- DataflowAssert.that(output).containsInAnyOrder(expected);
+ PAssert.that(output).containsInAnyOrder(expected);
p.run();
}
@@ -363,7 +363,7 @@ public class TextIOTest {
TextIO.Read.from(filename).withCompressionType(CompressionType.GZIP);
PCollection<String> output = p.apply(read);
- DataflowAssert.that(output).containsInAnyOrder(expected);
+ PAssert.that(output).containsInAnyOrder(expected);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/XmlSourceTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/XmlSourceTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/XmlSourceTest.java
index 41e2887..9865615 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/XmlSourceTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/XmlSourceTest.java
@@ -31,7 +31,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.io.Source.Reader;
import com.google.cloud.dataflow.sdk.options.PipelineOptions;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.PCollection;
import com.google.common.collect.ImmutableList;
@@ -583,7 +583,7 @@ public class XmlSourceTest {
new Train("Toby", 7, "brown", null), new Train("Gordon", 4, "blue", null),
new Train("Emily", -1, "red", null), new Train("Percy", 6, "green", null));
- DataflowAssert.that(output).containsInAnyOrder(expectedResults);
+ PAssert.that(output).containsInAnyOrder(expectedResults);
p.run();
}
@@ -667,7 +667,7 @@ public class XmlSourceTest {
.withMinBundleSize(1024);
PCollection<Train> output = p.apply(Read.from(source).named("ReadFileData"));
- DataflowAssert.that(output).containsInAnyOrder(trains);
+ PAssert.that(output).containsInAnyOrder(trains);
p.run();
}
@@ -819,7 +819,7 @@ public class XmlSourceTest {
expectedResults.addAll(trains2);
expectedResults.addAll(trains3);
- DataflowAssert.that(output).containsInAnyOrder(expectedResults);
+ PAssert.that(output).containsInAnyOrder(expectedResults);
p.run();
}
}
[2/5] incubator-beam git commit: Rename DataflowAssert to PAssert
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/bigtable/BigtableIOTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/bigtable/BigtableIOTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/bigtable/BigtableIOTest.java
index b8ac243..7cb77c7 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/bigtable/BigtableIOTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/io/bigtable/BigtableIOTest.java
@@ -42,8 +42,8 @@ import com.google.cloud.dataflow.sdk.coders.Coder;
import com.google.cloud.dataflow.sdk.io.bigtable.BigtableIO.BigtableSource;
import com.google.cloud.dataflow.sdk.io.range.ByteKey;
import com.google.cloud.dataflow.sdk.io.range.ByteKeyRange;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
import com.google.cloud.dataflow.sdk.testing.ExpectedLogs;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -218,7 +218,7 @@ public class BigtableIOTest {
TestPipeline p = TestPipeline.create();
PCollection<Row> rows = p.apply(defaultRead.withTableId(table));
- DataflowAssert.that(rows).empty();
+ PAssert.that(rows).empty();
p.run();
logged.verifyInfo(String.format("Closing reader after reading 0 records."));
@@ -233,7 +233,7 @@ public class BigtableIOTest {
TestPipeline p = TestPipeline.create();
PCollection<Row> rows = p.apply(defaultRead.withTableId(table));
- DataflowAssert.that(rows).containsInAnyOrder(testRows);
+ PAssert.that(rows).containsInAnyOrder(testRows);
p.run();
logged.verifyInfo(String.format("Closing reader after reading %d records.", numRows));
@@ -278,7 +278,7 @@ public class BigtableIOTest {
TestPipeline p = TestPipeline.create();
PCollection<Row> rows = p.apply(defaultRead.withTableId(table).withRowFilter(filter));
- DataflowAssert.that(rows).containsInAnyOrder(filteredRows);
+ PAssert.that(rows).containsInAnyOrder(filteredRows);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/dataflow/CustomSourcesTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/dataflow/CustomSourcesTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/dataflow/CustomSourcesTest.java
index fb045cd..20d2bc8 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/dataflow/CustomSourcesTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/dataflow/CustomSourcesTest.java
@@ -33,8 +33,8 @@ import com.google.cloud.dataflow.sdk.io.Read;
import com.google.cloud.dataflow.sdk.options.DataflowPipelineOptions;
import com.google.cloud.dataflow.sdk.options.PipelineOptions;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
import com.google.cloud.dataflow.sdk.testing.ExpectedLogs;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Sample;
import com.google.cloud.dataflow.sdk.transforms.Sum;
@@ -213,7 +213,7 @@ public class CustomSourcesTest {
.apply(Sum.integersGlobally())
.apply(Sample.<Integer>any(1));
- DataflowAssert.thatSingleton(sum).isEqualTo(145);
+ PAssert.thatSingleton(sum).isEqualTo(145);
p.run();
}
@@ -225,7 +225,7 @@ public class CustomSourcesTest {
.apply(Window.<Integer>into(FixedWindows.of(Duration.millis(3))))
.apply(Sum.integersGlobally().withoutDefaults());
// Should group into [10 11] [12 13 14] [15 16 17] [18 19].
- DataflowAssert.that(sums).containsInAnyOrder(21, 37, 39, 48);
+ PAssert.that(sums).containsInAnyOrder(21, 37, 39, 48);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessCreateTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessCreateTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessCreateTest.java
index 1956b20..8bb7e51 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessCreateTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessCreateTest.java
@@ -35,7 +35,7 @@ import com.google.cloud.dataflow.sdk.io.BoundedSource;
import com.google.cloud.dataflow.sdk.options.PipelineOptions;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
import com.google.cloud.dataflow.sdk.runners.inprocess.InProcessCreate.InMemorySource;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.SourceTestUtils;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
@@ -76,7 +76,7 @@ public class InProcessCreateTest {
InProcessCreate<Integer> converted = InProcessCreate.from(og);
- DataflowAssert.that(p.apply(converted)).containsInAnyOrder(2, 1, 3);
+ PAssert.that(p.apply(converted)).containsInAnyOrder(2, 1, 3);
p.run();
}
@@ -91,7 +91,7 @@ public class InProcessCreateTest {
InProcessCreate<String> converted = InProcessCreate.from(og);
TestPipeline p = TestPipeline.create();
- DataflowAssert.that(p.apply(converted))
+ PAssert.that(p.apply(converted))
.containsInAnyOrder(null, "foo", null, "spam", "ham", "eggs");
p.run();
@@ -172,7 +172,7 @@ public class InProcessCreateTest {
Create.of(elements).withCoder(new UnserializableRecord.UnserializableRecordCoder()));
TestPipeline p = TestPipeline.create();
- DataflowAssert.that(p.apply(create))
+ PAssert.that(p.apply(create))
.containsInAnyOrder(
new UnserializableRecord("foo"),
new UnserializableRecord("bar"),
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessPipelineRunnerTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessPipelineRunnerTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessPipelineRunnerTest.java
index 4efa5dd..61c942d 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessPipelineRunnerTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/runners/inprocess/InProcessPipelineRunnerTest.java
@@ -21,7 +21,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.options.PipelineOptions;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
import com.google.cloud.dataflow.sdk.runners.inprocess.InProcessPipelineRunner.InProcessPipelineResult;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.transforms.Count;
import com.google.cloud.dataflow.sdk.transforms.Create;
import com.google.cloud.dataflow.sdk.transforms.MapElements;
@@ -62,7 +62,7 @@ public class InProcessPipelineRunnerTest implements Serializable {
}
}));
- DataflowAssert.that(countStrs).containsInAnyOrder("baz: 1", "bar: 2", "foo: 3");
+ PAssert.that(countStrs).containsInAnyOrder("baz: 1", "bar: 2", "foo: 3");
InProcessPipelineResult result = ((InProcessPipelineResult) p.run());
result.awaitCompletion();
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/DataflowAssertTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/DataflowAssertTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/DataflowAssertTest.java
deleted file mode 100644
index cf88617..0000000
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/DataflowAssertTest.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.cloud.dataflow.sdk.testing;
-
-import static com.google.cloud.dataflow.sdk.testing.SerializableMatchers.anything;
-import static com.google.cloud.dataflow.sdk.testing.SerializableMatchers.not;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.coders.AtomicCoder;
-import com.google.cloud.dataflow.sdk.coders.CoderException;
-import com.google.cloud.dataflow.sdk.runners.DirectPipelineRunner;
-import com.google.cloud.dataflow.sdk.transforms.Create;
-import com.google.cloud.dataflow.sdk.transforms.SerializableFunction;
-import com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver;
-import com.google.cloud.dataflow.sdk.values.PCollection;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.regex.Pattern;
-
-import javax.annotation.Nullable;
-
-/**
- * Test case for {@link DataflowAssert}.
- */
-@RunWith(JUnit4.class)
-public class DataflowAssertTest implements Serializable {
- @Rule
- public transient ExpectedException thrown = ExpectedException.none();
-
- private static class NotSerializableObject {
-
- @Override
- public boolean equals(Object other) {
- return (other instanceof NotSerializableObject);
- }
-
- @Override
- public int hashCode() {
- return 73;
- }
- }
-
- private static class NotSerializableObjectCoder extends AtomicCoder<NotSerializableObject> {
- private NotSerializableObjectCoder() { }
- private static final NotSerializableObjectCoder INSTANCE = new NotSerializableObjectCoder();
-
- @JsonCreator
- public static NotSerializableObjectCoder of() {
- return INSTANCE;
- }
-
- @Override
- public void encode(NotSerializableObject value, OutputStream outStream, Context context)
- throws CoderException, IOException {
- }
-
- @Override
- public NotSerializableObject decode(InputStream inStream, Context context)
- throws CoderException, IOException {
- return new NotSerializableObject();
- }
-
- @Override
- public boolean isRegisterByteSizeObserverCheap(NotSerializableObject value, Context context) {
- return true;
- }
-
- @Override
- public void registerByteSizeObserver(
- NotSerializableObject value, ElementByteSizeObserver observer, Context context)
- throws Exception {
- observer.update(0L);
- }
- }
-
- /**
- * A {@link DataflowAssert} about the contents of a {@link PCollection}
- * must not require the contents of the {@link PCollection} to be
- * serializable.
- */
- @Test
- @Category(RunnableOnService.class)
- public void testContainsInAnyOrderNotSerializable() throws Exception {
- Pipeline pipeline = TestPipeline.create();
-
- PCollection<NotSerializableObject> pcollection = pipeline
- .apply(Create.of(
- new NotSerializableObject(),
- new NotSerializableObject())
- .withCoder(NotSerializableObjectCoder.of()));
-
- DataflowAssert.that(pcollection).containsInAnyOrder(
- new NotSerializableObject(),
- new NotSerializableObject());
-
- pipeline.run();
- }
-
- /**
- * A {@link DataflowAssert} about the contents of a {@link PCollection}
- * is allows to be verified by an arbitrary {@link SerializableFunction},
- * though.
- */
- @Test
- @Category(RunnableOnService.class)
- public void testSerializablePredicate() throws Exception {
- Pipeline pipeline = TestPipeline.create();
-
- PCollection<NotSerializableObject> pcollection = pipeline
- .apply(Create.of(
- new NotSerializableObject(),
- new NotSerializableObject())
- .withCoder(NotSerializableObjectCoder.of()));
-
- DataflowAssert.that(pcollection).satisfies(
- new SerializableFunction<Iterable<NotSerializableObject>, Void>() {
- @Override
- public Void apply(Iterable<NotSerializableObject> contents) {
- return null; // no problem!
- }
- });
-
- pipeline.run();
- }
-
- /**
- * Basic test of succeeding {@link DataflowAssert} using a {@link SerializableMatcher}.
- */
- @Test
- @Category(RunnableOnService.class)
- public void testBasicMatcherSuccess() throws Exception {
- Pipeline pipeline = TestPipeline.create();
- PCollection<Integer> pcollection = pipeline.apply(Create.of(42));
- DataflowAssert.that(pcollection).containsInAnyOrder(anything());
- pipeline.run();
- }
-
- /**
- * Basic test of failing {@link DataflowAssert} using a {@link SerializableMatcher}.
- */
- @Test
- @Category(RunnableOnService.class)
- public void testBasicMatcherFailure() throws Exception {
- Pipeline pipeline = TestPipeline.create();
- PCollection<Integer> pcollection = pipeline.apply(Create.of(42));
- DataflowAssert.that(pcollection).containsInAnyOrder(not(anything()));
- runExpectingAssertionFailure(pipeline);
- }
-
- /**
- * Test that we throw an error at pipeline construction time when the user mistakenly uses
- * {@code DataflowAssert.thatSingleton().equals()} instead of the test method {@code .isEqualTo}.
- */
- @SuppressWarnings("deprecation") // test of deprecated function
- @Test
- public void testDataflowAssertEqualsSingletonUnsupported() throws Exception {
- thrown.expect(UnsupportedOperationException.class);
- thrown.expectMessage("isEqualTo");
-
- Pipeline pipeline = TestPipeline.create();
- PCollection<Integer> pcollection = pipeline.apply(Create.of(42));
- DataflowAssert.thatSingleton(pcollection).equals(42);
- }
-
- /**
- * Test that we throw an error at pipeline construction time when the user mistakenly uses
- * {@code DataflowAssert.that().equals()} instead of the test method {@code .containsInAnyOrder}.
- */
- @SuppressWarnings("deprecation") // test of deprecated function
- @Test
- public void testDataflowAssertEqualsIterableUnsupported() throws Exception {
- thrown.expect(UnsupportedOperationException.class);
- thrown.expectMessage("containsInAnyOrder");
-
- Pipeline pipeline = TestPipeline.create();
- PCollection<Integer> pcollection = pipeline.apply(Create.of(42));
- DataflowAssert.that(pcollection).equals(42);
- }
-
- /**
- * Test that {@code DataflowAssert.thatSingleton().hashCode()} is unsupported.
- * See {@link #testDataflowAssertEqualsSingletonUnsupported}.
- */
- @SuppressWarnings("deprecation") // test of deprecated function
- @Test
- public void testDataflowAssertHashCodeSingletonUnsupported() throws Exception {
- thrown.expect(UnsupportedOperationException.class);
- thrown.expectMessage(".hashCode() is not supported.");
-
- Pipeline pipeline = TestPipeline.create();
- PCollection<Integer> pcollection = pipeline.apply(Create.of(42));
- DataflowAssert.thatSingleton(pcollection).hashCode();
- }
-
- /**
- * Test that {@code DataflowAssert.thatIterable().hashCode()} is unsupported.
- * See {@link #testDataflowAssertEqualsIterableUnsupported}.
- */
- @SuppressWarnings("deprecation") // test of deprecated function
- @Test
- public void testDataflowAssertHashCodeIterableUnsupported() throws Exception {
- thrown.expect(UnsupportedOperationException.class);
- thrown.expectMessage(".hashCode() is not supported.");
-
- Pipeline pipeline = TestPipeline.create();
- PCollection<Integer> pcollection = pipeline.apply(Create.of(42));
- DataflowAssert.that(pcollection).hashCode();
- }
-
- /**
- * Basic test for {@code isEqualTo}.
- */
- @Test
- @Category(RunnableOnService.class)
- public void testIsEqualTo() throws Exception {
- Pipeline pipeline = TestPipeline.create();
- PCollection<Integer> pcollection = pipeline.apply(Create.of(43));
- DataflowAssert.thatSingleton(pcollection).isEqualTo(43);
- pipeline.run();
- }
-
- /**
- * Basic test for {@code notEqualTo}.
- */
- @Test
- @Category(RunnableOnService.class)
- public void testNotEqualTo() throws Exception {
- Pipeline pipeline = TestPipeline.create();
- PCollection<Integer> pcollection = pipeline.apply(Create.of(43));
- DataflowAssert.thatSingleton(pcollection).notEqualTo(42);
- pipeline.run();
- }
-
- /**
- * Tests that {@code containsInAnyOrder} is actually order-independent.
- */
- @Test
- @Category(RunnableOnService.class)
- public void testContainsInAnyOrder() throws Exception {
- Pipeline pipeline = TestPipeline.create();
- PCollection<Integer> pcollection = pipeline.apply(Create.of(1, 2, 3, 4));
- DataflowAssert.that(pcollection).containsInAnyOrder(2, 1, 4, 3);
- pipeline.run();
- }
-
- /**
- * Tests that {@code containsInAnyOrder} fails when and how it should.
- */
- @Test
- @Category(RunnableOnService.class)
- public void testContainsInAnyOrderFalse() throws Exception {
- Pipeline pipeline = TestPipeline.create();
-
- PCollection<Integer> pcollection = pipeline
- .apply(Create.of(1, 2, 3, 4));
-
- DataflowAssert.that(pcollection).containsInAnyOrder(2, 1, 4, 3, 7);
-
- // The service runner does not give an exception we can usefully inspect.
- @Nullable
- Throwable exc = runExpectingAssertionFailure(pipeline);
- Pattern expectedPattern = Pattern.compile(
- "Expected: iterable over \\[((<4>|<7>|<3>|<2>|<1>)(, )?){5}\\] in any order");
- if (exc != null) {
- // A loose pattern, but should get the job done.
- assertTrue("Expected error message from DataflowAssert with substring matching "
- + expectedPattern + " but the message was \"" + exc.getMessage() + "\"",
- expectedPattern.matcher(exc.getMessage()).find());
- }
- }
-
- private static Throwable runExpectingAssertionFailure(Pipeline pipeline) {
- // Even though this test will succeed or fail adequately whether local or on the service,
- // it results in a different exception depending on the runner.
- if (pipeline.getRunner() instanceof DirectPipelineRunner) {
- // We cannot use thrown.expect(AssertionError.class) because the AssertionError
- // is first caught by JUnit and causes a test failure.
- try {
- pipeline.run();
- } catch (AssertionError exc) {
- return exc;
- }
- } else if (pipeline.getRunner() instanceof TestDataflowPipelineRunner) {
- // Separately, if this is run on the service, then the TestDataflowPipelineRunner throws
- // an IllegalStateException with a basic message.
- try {
- pipeline.run();
- } catch (IllegalStateException exc) {
- assertThat(exc.getMessage(), containsString("The dataflow failed."));
- return null;
- }
- }
- fail("assertion should have failed");
- throw new RuntimeException("unreachable");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/PAssertTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/PAssertTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/PAssertTest.java
new file mode 100644
index 0000000..2848eaa
--- /dev/null
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/PAssertTest.java
@@ -0,0 +1,331 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.google.cloud.dataflow.sdk.testing;
+
+import static com.google.cloud.dataflow.sdk.testing.SerializableMatchers.anything;
+import static com.google.cloud.dataflow.sdk.testing.SerializableMatchers.not;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.google.cloud.dataflow.sdk.Pipeline;
+import com.google.cloud.dataflow.sdk.coders.AtomicCoder;
+import com.google.cloud.dataflow.sdk.coders.CoderException;
+import com.google.cloud.dataflow.sdk.runners.DirectPipelineRunner;
+import com.google.cloud.dataflow.sdk.transforms.Create;
+import com.google.cloud.dataflow.sdk.transforms.SerializableFunction;
+import com.google.cloud.dataflow.sdk.util.common.ElementByteSizeObserver;
+import com.google.cloud.dataflow.sdk.values.PCollection;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.regex.Pattern;
+
+import javax.annotation.Nullable;
+
+/**
+ * Test case for {@link PAssert}.
+ */
+@RunWith(JUnit4.class)
+public class PAssertTest implements Serializable {
+ @Rule
+ public transient ExpectedException thrown = ExpectedException.none();
+
+ private static class NotSerializableObject {
+
+ @Override
+ public boolean equals(Object other) {
+ return (other instanceof NotSerializableObject);
+ }
+
+ @Override
+ public int hashCode() {
+ return 73;
+ }
+ }
+
+ private static class NotSerializableObjectCoder extends AtomicCoder<NotSerializableObject> {
+ private NotSerializableObjectCoder() { }
+ private static final NotSerializableObjectCoder INSTANCE = new NotSerializableObjectCoder();
+
+ @JsonCreator
+ public static NotSerializableObjectCoder of() {
+ return INSTANCE;
+ }
+
+ @Override
+ public void encode(NotSerializableObject value, OutputStream outStream, Context context)
+ throws CoderException, IOException {
+ }
+
+ @Override
+ public NotSerializableObject decode(InputStream inStream, Context context)
+ throws CoderException, IOException {
+ return new NotSerializableObject();
+ }
+
+ @Override
+ public boolean isRegisterByteSizeObserverCheap(NotSerializableObject value, Context context) {
+ return true;
+ }
+
+ @Override
+ public void registerByteSizeObserver(
+ NotSerializableObject value, ElementByteSizeObserver observer, Context context)
+ throws Exception {
+ observer.update(0L);
+ }
+ }
+
+ /**
+ * A {@link PAssert} about the contents of a {@link PCollection}
+ * must not require the contents of the {@link PCollection} to be
+ * serializable.
+ */
+ @Test
+ @Category(RunnableOnService.class)
+ public void testContainsInAnyOrderNotSerializable() throws Exception {
+ Pipeline pipeline = TestPipeline.create();
+
+ PCollection<NotSerializableObject> pcollection = pipeline
+ .apply(Create.of(
+ new NotSerializableObject(),
+ new NotSerializableObject())
+ .withCoder(NotSerializableObjectCoder.of()));
+
+ PAssert.that(pcollection).containsInAnyOrder(
+ new NotSerializableObject(),
+ new NotSerializableObject());
+
+ pipeline.run();
+ }
+
+ /**
+ * A {@link PAssert} about the contents of a {@link PCollection}
+ * is allows to be verified by an arbitrary {@link SerializableFunction},
+ * though.
+ */
+ @Test
+ @Category(RunnableOnService.class)
+ public void testSerializablePredicate() throws Exception {
+ Pipeline pipeline = TestPipeline.create();
+
+ PCollection<NotSerializableObject> pcollection = pipeline
+ .apply(Create.of(
+ new NotSerializableObject(),
+ new NotSerializableObject())
+ .withCoder(NotSerializableObjectCoder.of()));
+
+ PAssert.that(pcollection).satisfies(
+ new SerializableFunction<Iterable<NotSerializableObject>, Void>() {
+ @Override
+ public Void apply(Iterable<NotSerializableObject> contents) {
+ return null; // no problem!
+ }
+ });
+
+ pipeline.run();
+ }
+
+ /**
+ * Basic test of succeeding {@link PAssert} using a {@link SerializableMatcher}.
+ */
+ @Test
+ @Category(RunnableOnService.class)
+ public void testBasicMatcherSuccess() throws Exception {
+ Pipeline pipeline = TestPipeline.create();
+ PCollection<Integer> pcollection = pipeline.apply(Create.of(42));
+ PAssert.that(pcollection).containsInAnyOrder(anything());
+ pipeline.run();
+ }
+
+ /**
+ * Basic test of failing {@link PAssert} using a {@link SerializableMatcher}.
+ */
+ @Test
+ @Category(RunnableOnService.class)
+ public void testBasicMatcherFailure() throws Exception {
+ Pipeline pipeline = TestPipeline.create();
+ PCollection<Integer> pcollection = pipeline.apply(Create.of(42));
+ PAssert.that(pcollection).containsInAnyOrder(not(anything()));
+ runExpectingAssertionFailure(pipeline);
+ }
+
+ /**
+ * Test that we throw an error at pipeline construction time when the user mistakenly uses
+ * {@code PAssert.thatSingleton().equals()} instead of the test method {@code .isEqualTo}.
+ */
+ @SuppressWarnings("deprecation") // test of deprecated function
+ @Test
+ public void testPAssertEqualsSingletonUnsupported() throws Exception {
+ thrown.expect(UnsupportedOperationException.class);
+ thrown.expectMessage("isEqualTo");
+
+ Pipeline pipeline = TestPipeline.create();
+ PCollection<Integer> pcollection = pipeline.apply(Create.of(42));
+ PAssert.thatSingleton(pcollection).equals(42);
+ }
+
+ /**
+ * Test that we throw an error at pipeline construction time when the user mistakenly uses
+ * {@code PAssert.that().equals()} instead of the test method {@code .containsInAnyOrder}.
+ */
+ @SuppressWarnings("deprecation") // test of deprecated function
+ @Test
+ public void testPAssertEqualsIterableUnsupported() throws Exception {
+ thrown.expect(UnsupportedOperationException.class);
+ thrown.expectMessage("containsInAnyOrder");
+
+ Pipeline pipeline = TestPipeline.create();
+ PCollection<Integer> pcollection = pipeline.apply(Create.of(42));
+ PAssert.that(pcollection).equals(42);
+ }
+
+ /**
+ * Test that {@code PAssert.thatSingleton().hashCode()} is unsupported.
+ * See {@link #testPAssertEqualsSingletonUnsupported}.
+ */
+ @SuppressWarnings("deprecation") // test of deprecated function
+ @Test
+ public void testPAssertHashCodeSingletonUnsupported() throws Exception {
+ thrown.expect(UnsupportedOperationException.class);
+ thrown.expectMessage(".hashCode() is not supported.");
+
+ Pipeline pipeline = TestPipeline.create();
+ PCollection<Integer> pcollection = pipeline.apply(Create.of(42));
+ PAssert.thatSingleton(pcollection).hashCode();
+ }
+
+ /**
+ * Test that {@code PAssert.thatIterable().hashCode()} is unsupported.
+ * See {@link #testPAssertEqualsIterableUnsupported}.
+ */
+ @SuppressWarnings("deprecation") // test of deprecated function
+ @Test
+ public void testPAssertHashCodeIterableUnsupported() throws Exception {
+ thrown.expect(UnsupportedOperationException.class);
+ thrown.expectMessage(".hashCode() is not supported.");
+
+ Pipeline pipeline = TestPipeline.create();
+ PCollection<Integer> pcollection = pipeline.apply(Create.of(42));
+ PAssert.that(pcollection).hashCode();
+ }
+
+ /**
+ * Basic test for {@code isEqualTo}.
+ */
+ @Test
+ @Category(RunnableOnService.class)
+ public void testIsEqualTo() throws Exception {
+ Pipeline pipeline = TestPipeline.create();
+ PCollection<Integer> pcollection = pipeline.apply(Create.of(43));
+ PAssert.thatSingleton(pcollection).isEqualTo(43);
+ pipeline.run();
+ }
+
+ /**
+ * Basic test for {@code notEqualTo}.
+ */
+ @Test
+ @Category(RunnableOnService.class)
+ public void testNotEqualTo() throws Exception {
+ Pipeline pipeline = TestPipeline.create();
+ PCollection<Integer> pcollection = pipeline.apply(Create.of(43));
+ PAssert.thatSingleton(pcollection).notEqualTo(42);
+ pipeline.run();
+ }
+
+ /**
+ * Tests that {@code containsInAnyOrder} is actually order-independent.
+ */
+ @Test
+ @Category(RunnableOnService.class)
+ public void testContainsInAnyOrder() throws Exception {
+ Pipeline pipeline = TestPipeline.create();
+ PCollection<Integer> pcollection = pipeline.apply(Create.of(1, 2, 3, 4));
+ PAssert.that(pcollection).containsInAnyOrder(2, 1, 4, 3);
+ pipeline.run();
+ }
+
+ /**
+ * Tests that {@code containsInAnyOrder} fails when and how it should.
+ */
+ @Test
+ @Category(RunnableOnService.class)
+ public void testContainsInAnyOrderFalse() throws Exception {
+ Pipeline pipeline = TestPipeline.create();
+
+ PCollection<Integer> pcollection = pipeline
+ .apply(Create.of(1, 2, 3, 4));
+
+ PAssert.that(pcollection).containsInAnyOrder(2, 1, 4, 3, 7);
+
+ // The service runner does not give an exception we can usefully inspect.
+ @Nullable
+ Throwable exc = runExpectingAssertionFailure(pipeline);
+ Pattern expectedPattern = Pattern.compile(
+ "Expected: iterable over \\[((<4>|<7>|<3>|<2>|<1>)(, )?){5}\\] in any order");
+ if (exc != null) {
+ // A loose pattern, but should get the job done.
+ assertTrue(
+ "Expected error message from PAssert with substring matching "
+ + expectedPattern
+ + " but the message was \""
+ + exc.getMessage()
+ + "\"",
+ expectedPattern.matcher(exc.getMessage()).find());
+ }
+ }
+
+ private static Throwable runExpectingAssertionFailure(Pipeline pipeline) {
+ // Even though this test will succeed or fail adequately whether local or on the service,
+ // it results in a different exception depending on the runner.
+ if (pipeline.getRunner() instanceof DirectPipelineRunner) {
+ // We cannot use thrown.expect(AssertionError.class) because the AssertionError
+ // is first caught by JUnit and causes a test failure.
+ try {
+ pipeline.run();
+ } catch (AssertionError exc) {
+ return exc;
+ }
+ } else if (pipeline.getRunner() instanceof TestDataflowPipelineRunner) {
+ // Separately, if this is run on the service, then the TestDataflowPipelineRunner throws
+ // an IllegalStateException with a basic message.
+ try {
+ pipeline.run();
+ } catch (IllegalStateException exc) {
+ assertThat(exc.getMessage(), containsString("The dataflow failed."));
+ return null;
+ }
+ }
+ fail("assertion should have failed");
+ throw new RuntimeException("unreachable");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/TestDataflowPipelineRunnerTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/TestDataflowPipelineRunnerTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/TestDataflowPipelineRunnerTest.java
index 4ea3d25..e15e7ef 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/TestDataflowPipelineRunnerTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/testing/TestDataflowPipelineRunnerTest.java
@@ -109,7 +109,7 @@ public class TestDataflowPipelineRunnerTest {
public void testRunBatchJobThatSucceeds() throws Exception {
Pipeline p = TestPipeline.create(options);
PCollection<Integer> pc = p.apply(Create.of(1, 2, 3));
- DataflowAssert.that(pc).containsInAnyOrder(1, 2, 3);
+ PAssert.that(pc).containsInAnyOrder(1, 2, 3);
DataflowPipelineJob mockJob = Mockito.mock(DataflowPipelineJob.class);
when(mockJob.getDataflowClient()).thenReturn(service);
@@ -133,7 +133,7 @@ public class TestDataflowPipelineRunnerTest {
Pipeline p = TestPipeline.create(options);
PCollection<Integer> pc = p.apply(Create.of(1, 2, 3));
- DataflowAssert.that(pc).containsInAnyOrder(1, 2, 3);
+ PAssert.that(pc).containsInAnyOrder(1, 2, 3);
DataflowPipelineJob mockJob = Mockito.mock(DataflowPipelineJob.class);
when(mockJob.getDataflowClient()).thenReturn(service);
@@ -153,7 +153,7 @@ public class TestDataflowPipelineRunnerTest {
options.setStreaming(true);
Pipeline p = TestPipeline.create(options);
PCollection<Integer> pc = p.apply(Create.of(1, 2, 3));
- DataflowAssert.that(pc).containsInAnyOrder(1, 2, 3);
+ PAssert.that(pc).containsInAnyOrder(1, 2, 3);
DataflowPipelineJob mockJob = Mockito.mock(DataflowPipelineJob.class);
when(mockJob.getDataflowClient()).thenReturn(service);
@@ -178,7 +178,7 @@ public class TestDataflowPipelineRunnerTest {
options.setStreaming(true);
Pipeline p = TestPipeline.create(options);
PCollection<Integer> pc = p.apply(Create.of(1, 2, 3));
- DataflowAssert.that(pc).containsInAnyOrder(1, 2, 3);
+ PAssert.that(pc).containsInAnyOrder(1, 2, 3);
DataflowPipelineJob mockJob = Mockito.mock(DataflowPipelineJob.class);
when(mockJob.getDataflowClient()).thenReturn(service);
@@ -196,12 +196,12 @@ public class TestDataflowPipelineRunnerTest {
}
@Test
- public void testCheckingForSuccessWhenDataflowAssertSucceeds() throws Exception {
+ public void testCheckingForSuccessWhenPAssertSucceeds() throws Exception {
DataflowPipelineJob job =
spy(new DataflowPipelineJob("test-project", "test-job", service, null));
Pipeline p = TestPipeline.create(options);
PCollection<Integer> pc = p.apply(Create.of(1, 2, 3));
- DataflowAssert.that(pc).containsInAnyOrder(1, 2, 3);
+ PAssert.that(pc).containsInAnyOrder(1, 2, 3);
TestDataflowPipelineRunner runner = (TestDataflowPipelineRunner) p.getRunner();
when(request.execute()).thenReturn(
@@ -211,12 +211,12 @@ public class TestDataflowPipelineRunnerTest {
}
@Test
- public void testCheckingForSuccessWhenDataflowAssertFails() throws Exception {
+ public void testCheckingForSuccessWhenPAssertFails() throws Exception {
DataflowPipelineJob job =
spy(new DataflowPipelineJob("test-project", "test-job", service, null));
Pipeline p = TestPipeline.create(options);
PCollection<Integer> pc = p.apply(Create.of(1, 2, 3));
- DataflowAssert.that(pc).containsInAnyOrder(1, 2, 3);
+ PAssert.that(pc).containsInAnyOrder(1, 2, 3);
TestDataflowPipelineRunner runner = (TestDataflowPipelineRunner) p.getRunner();
when(request.execute()).thenReturn(
@@ -231,7 +231,7 @@ public class TestDataflowPipelineRunnerTest {
spy(new DataflowPipelineJob("test-project", "test-job", service, null));
Pipeline p = TestPipeline.create(options);
PCollection<Integer> pc = p.apply(Create.of(1, 2, 3));
- DataflowAssert.that(pc).containsInAnyOrder(1, 2, 3);
+ PAssert.that(pc).containsInAnyOrder(1, 2, 3);
TestDataflowPipelineRunner runner = (TestDataflowPipelineRunner) p.getRunner();
when(request.execute()).thenReturn(
@@ -243,7 +243,7 @@ public class TestDataflowPipelineRunnerTest {
private LowLevelHttpResponse generateMockMetricResponse(boolean success, boolean tentative)
throws Exception {
MetricStructuredName name = new MetricStructuredName();
- name.setName(success ? "DataflowAssertSuccess" : "DataflowAssertFailure");
+ name.setName(success ? "PAssertSuccess" : "PAssertFailure");
name.setContext(
tentative ? ImmutableMap.of("tentative", "") : ImmutableMap.<String, String>of());
@@ -267,7 +267,7 @@ public class TestDataflowPipelineRunnerTest {
spy(new DataflowPipelineJob("test-project", "test-job", service, null));
Pipeline p = TestPipeline.create(options);
PCollection<Integer> pc = p.apply(Create.of(1, 2, 3));
- DataflowAssert.that(pc).containsInAnyOrder(1, 2, 3);
+ PAssert.that(pc).containsInAnyOrder(1, 2, 3);
TestDataflowPipelineRunner runner = (TestDataflowPipelineRunner) p.getRunner();
when(request.execute()).thenReturn(
@@ -284,7 +284,7 @@ public class TestDataflowPipelineRunnerTest {
options.setStreaming(true);
Pipeline p = TestPipeline.create(options);
PCollection<Integer> pc = p.apply(Create.of(1, 2, 3));
- DataflowAssert.that(pc).containsInAnyOrder(1, 2, 3);
+ PAssert.that(pc).containsInAnyOrder(1, 2, 3);
DataflowPipelineJob mockJob = Mockito.mock(DataflowPipelineJob.class);
when(mockJob.getDataflowClient()).thenReturn(service);
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ApproximateQuantilesTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ApproximateQuantilesTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ApproximateQuantilesTest.java
index 1f22757..bd6c8a2 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ApproximateQuantilesTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ApproximateQuantilesTest.java
@@ -25,7 +25,7 @@ import com.google.cloud.dataflow.sdk.coders.BigEndianIntegerCoder;
import com.google.cloud.dataflow.sdk.coders.KvCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
import com.google.cloud.dataflow.sdk.runners.DirectPipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.ApproximateQuantiles.ApproximateQuantilesCombineFn;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -74,7 +74,7 @@ public class ApproximateQuantilesTest {
PCollection<List<Integer>> quantiles =
input.apply(ApproximateQuantiles.<Integer>globally(5));
- DataflowAssert.that(quantiles)
+ PAssert.that(quantiles)
.containsInAnyOrder(Arrays.asList(0, 25, 50, 75, 100));
p.run();
}
@@ -88,7 +88,7 @@ public class ApproximateQuantilesTest {
input.apply(
ApproximateQuantiles.globally(5, new DescendingIntComparator()));
- DataflowAssert.that(quantiles)
+ PAssert.that(quantiles)
.containsInAnyOrder(Arrays.asList(100, 75, 50, 25, 0));
p.run();
}
@@ -101,7 +101,7 @@ public class ApproximateQuantilesTest {
PCollection<KV<String, List<Integer>>> quantiles = input.apply(
ApproximateQuantiles.<String, Integer>perKey(2));
- DataflowAssert.that(quantiles)
+ PAssert.that(quantiles)
.containsInAnyOrder(
KV.of("a", Arrays.asList(1, 3)),
KV.of("b", Arrays.asList(1, 100)));
@@ -118,7 +118,7 @@ public class ApproximateQuantilesTest {
ApproximateQuantiles.<String, Integer, DescendingIntComparator>perKey(
2, new DescendingIntComparator()));
- DataflowAssert.that(quantiles)
+ PAssert.that(quantiles)
.containsInAnyOrder(
KV.of("a", Arrays.asList(3, 1)),
KV.of("b", Arrays.asList(100, 1)));
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ApproximateUniqueTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ApproximateUniqueTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ApproximateUniqueTest.java
index b1beb68..b6cd697 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ApproximateUniqueTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ApproximateUniqueTest.java
@@ -23,7 +23,7 @@ import static org.junit.Assert.fail;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.TestUtils;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -73,7 +73,7 @@ public class ApproximateUniqueTest implements Serializable {
PCollection<Long> estimate = input
.apply(ApproximateUnique.<Integer>globally(1000));
- DataflowAssert.thatSingleton(estimate).isEqualTo(3L);
+ PAssert.thatSingleton(estimate).isEqualTo(3L);
p.run();
}
@@ -101,7 +101,7 @@ public class ApproximateUniqueTest implements Serializable {
PCollection<Long> estimate =
input.apply(ApproximateUnique.<Double>globally(sampleSize));
- DataflowAssert.thatSingleton(estimate).satisfies(new VerifyEstimateFn(uniqueCount, sampleSize));
+ PAssert.thatSingleton(estimate).satisfies(new VerifyEstimateFn(uniqueCount, sampleSize));
p.run();
}
@@ -138,7 +138,7 @@ public class ApproximateUniqueTest implements Serializable {
PCollection<Long> estimate =
input.apply(ApproximateUnique.<Integer>globally(sampleSize));
- DataflowAssert.thatSingleton(estimate).satisfies(new VerifyEstimateFn(uniqueCount, sampleSize));
+ PAssert.thatSingleton(estimate).satisfies(new VerifyEstimateFn(uniqueCount, sampleSize));
p.run();
}
@@ -161,7 +161,7 @@ public class ApproximateUniqueTest implements Serializable {
PCollection<KV<Long, Long>> counts =
input.apply(ApproximateUnique.<Long, Long>perKey(sampleSize));
- DataflowAssert.that(counts).satisfies(new VerifyEstimatePerKeyFn(sampleSize));
+ PAssert.that(counts).satisfies(new VerifyEstimatePerKeyFn(sampleSize));
p.run();
@@ -220,7 +220,7 @@ public class ApproximateUniqueTest implements Serializable {
})
.withSideInputs(exact));
- DataflowAssert.that(approximateAndExact).satisfies(new VerifyEstimatePerKeyFn(sampleSize));
+ PAssert.that(approximateAndExact).satisfies(new VerifyEstimatePerKeyFn(sampleSize));
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineFnsTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineFnsTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineFnsTest.java
index ce941be..7d3aedf 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineFnsTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineFnsTest.java
@@ -27,7 +27,7 @@ import com.google.cloud.dataflow.sdk.coders.KvCoder;
import com.google.cloud.dataflow.sdk.coders.NullableCoder;
import com.google.cloud.dataflow.sdk.coders.StandardCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Combine.BinaryCombineFn;
@@ -166,9 +166,9 @@ public class CombineFnsTest {
new ConcatString().<String>asKeyedFn(),
concatStringTag)))
.apply("ExtractPerKeyResult", ParDo.of(new ExtractResultDoFn(maxIntTag, concatStringTag)));
- DataflowAssert.that(combineGlobally).containsInAnyOrder(
+ PAssert.that(combineGlobally).containsInAnyOrder(
KV.of("global", KV.of(13, "111134")));
- DataflowAssert.that(combinePerKey).containsInAnyOrder(
+ PAssert.that(combinePerKey).containsInAnyOrder(
KV.of("a", KV.of(4, "114")),
KV.of("b", KV.of(13, "113")));
p.run();
@@ -228,9 +228,9 @@ public class CombineFnsTest {
concatStringTag))
.withSideInputs(ImmutableList.of(view)))
.apply("ExtractPerKeyResult", ParDo.of(new ExtractResultDoFn(maxIntTag, concatStringTag)));
- DataflowAssert.that(combineGlobally).containsInAnyOrder(
+ PAssert.that(combineGlobally).containsInAnyOrder(
KV.of("global", KV.of(13, "111134GI")));
- DataflowAssert.that(combinePerKey).containsInAnyOrder(
+ PAssert.that(combinePerKey).containsInAnyOrder(
KV.of("a", KV.of(4, "114Ia")),
KV.of("b", KV.of(13, "113Ib")));
p.run();
@@ -271,7 +271,7 @@ public class CombineFnsTest {
new OutputNullString().<String>asKeyedFn(),
concatStringTag)))
.apply("ExtractPerKeyResult", ParDo.of(new ExtractResultDoFn(maxIntTag, concatStringTag)));
- DataflowAssert.that(combinePerKey).containsInAnyOrder(
+ PAssert.that(combinePerKey).containsInAnyOrder(
KV.of("a", KV.of(4, (String) null)),
KV.of("b", KV.of(13, (String) null)));
p.run();
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineTest.java
index c150b94..fce86fd 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CombineTest.java
@@ -36,7 +36,7 @@ import com.google.cloud.dataflow.sdk.coders.SerializableCoder;
import com.google.cloud.dataflow.sdk.coders.StandardCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
import com.google.cloud.dataflow.sdk.runners.DirectPipelineRunner;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.Combine.KeyedCombineFn;
@@ -130,8 +130,8 @@ public class CombineTest implements Serializable {
PCollection<KV<String, String>> sumPerKey = input
.apply(Combine.perKey(new TestKeyedCombineFn()));
- DataflowAssert.that(sum).containsInAnyOrder(globalSum);
- DataflowAssert.that(sumPerKey).containsInAnyOrder(perKeyCombines);
+ PAssert.that(sum).containsInAnyOrder(globalSum);
+ PAssert.that(sumPerKey).containsInAnyOrder(perKeyCombines);
p.run();
}
@@ -159,9 +159,9 @@ public class CombineTest implements Serializable {
.withoutDefaults()
.withSideInputs(Arrays.asList(globallySumView)));
- DataflowAssert.that(sum).containsInAnyOrder(globalSum);
- DataflowAssert.that(combinePerKey).containsInAnyOrder(perKeyCombines);
- DataflowAssert.that(combineGlobally).containsInAnyOrder(globallyCombines);
+ PAssert.that(sum).containsInAnyOrder(globalSum);
+ PAssert.that(combinePerKey).containsInAnyOrder(perKeyCombines);
+ PAssert.that(combineGlobally).containsInAnyOrder(globallyCombines);
p.run();
}
@@ -213,8 +213,8 @@ public class CombineTest implements Serializable {
PCollection<KV<String, Set<Integer>>> uniquePerKey = input
.apply(Combine.<String, Integer, Set<Integer>>perKey(new UniqueInts()));
- DataflowAssert.that(unique).containsInAnyOrder(globalUnique);
- DataflowAssert.that(uniquePerKey).containsInAnyOrder(perKeyUnique);
+ PAssert.that(unique).containsInAnyOrder(globalUnique);
+ PAssert.that(uniquePerKey).containsInAnyOrder(perKeyUnique);
p.run();
}
@@ -249,8 +249,8 @@ public class CombineTest implements Serializable {
PCollection<KV<String, Double>> meanPerKey = input.apply(
Combine.<String, Integer, Double>perKey(new MeanInts()));
- DataflowAssert.that(mean).containsInAnyOrder(globalMean);
- DataflowAssert.that(meanPerKey).containsInAnyOrder(perKeyMeans);
+ PAssert.that(mean).containsInAnyOrder(globalMean);
+ PAssert.that(meanPerKey).containsInAnyOrder(perKeyMeans);
p.run();
}
@@ -273,8 +273,8 @@ public class CombineTest implements Serializable {
PCollection<KV<String, String>> sumPerKey = input
.apply(Combine.perKey(new TestKeyedCombineFn()));
- DataflowAssert.that(sum).containsInAnyOrder(2, 5, 13);
- DataflowAssert.that(sumPerKey).containsInAnyOrder(
+ PAssert.that(sum).containsInAnyOrder(2, 5, 13);
+ PAssert.that(sumPerKey).containsInAnyOrder(
KV.of("a", "11a"),
KV.of("a", "4a"),
KV.of("b", "1b"),
@@ -310,13 +310,13 @@ public class CombineTest implements Serializable {
.withoutDefaults()
.withSideInputs(Arrays.asList(globallySumView)));
- DataflowAssert.that(sum).containsInAnyOrder(2, 5, 13);
- DataflowAssert.that(combinePerKeyWithContext).containsInAnyOrder(
+ PAssert.that(sum).containsInAnyOrder(2, 5, 13);
+ PAssert.that(combinePerKeyWithContext).containsInAnyOrder(
KV.of("a", "112a"),
KV.of("a", "45a"),
KV.of("b", "15b"),
KV.of("b", "1133b"));
- DataflowAssert.that(combineGloballyWithContext).containsInAnyOrder("112G", "145G", "1133G");
+ PAssert.that(combineGloballyWithContext).containsInAnyOrder("112G", "145G", "1133G");
p.run();
}
@@ -348,8 +348,8 @@ public class CombineTest implements Serializable {
.withoutDefaults()
.withSideInputs(Arrays.asList(globallySumView)));
- DataflowAssert.that(sum).containsInAnyOrder(1, 2, 1, 4, 5, 14, 13);
- DataflowAssert.that(combinePerKeyWithContext).containsInAnyOrder(
+ PAssert.that(sum).containsInAnyOrder(1, 2, 1, 4, 5, 14, 13);
+ PAssert.that(combinePerKeyWithContext).containsInAnyOrder(
KV.of("a", "11a"),
KV.of("a", "112a"),
KV.of("a", "11a"),
@@ -358,7 +358,7 @@ public class CombineTest implements Serializable {
KV.of("b", "15b"),
KV.of("b", "11134b"),
KV.of("b", "1133b"));
- DataflowAssert.that(combineGloballyWithContext).containsInAnyOrder(
+ PAssert.that(combineGloballyWithContext).containsInAnyOrder(
"11G", "112G", "11G", "44G", "145G", "11134G", "1133G");
p.run();
}
@@ -384,7 +384,7 @@ public class CombineTest implements Serializable {
.apply(Sum.integersGlobally())
.apply(ParDo.of(new FormatPaneInfo()));
- DataflowAssert.that(output).containsInAnyOrder("1: false", "2: true");
+ PAssert.that(output).containsInAnyOrder("1: false", "2: true");
}
@Test
@@ -405,8 +405,8 @@ public class CombineTest implements Serializable {
PCollection<KV<String, String>> sumPerKey = input
.apply(Combine.perKey(new TestKeyedCombineFn()));
- DataflowAssert.that(sum).containsInAnyOrder(7, 13);
- DataflowAssert.that(sumPerKey).containsInAnyOrder(
+ PAssert.that(sum).containsInAnyOrder(7, 13);
+ PAssert.that(sumPerKey).containsInAnyOrder(
KV.of("a", "114a"),
KV.of("b", "1b"),
KV.of("b", "13b"));
@@ -447,12 +447,12 @@ public class CombineTest implements Serializable {
.withoutDefaults()
.withSideInputs(Arrays.asList(globallyFixedWindowsView)));
- DataflowAssert.that(fixedWindowsSum).containsInAnyOrder(2, 4, 1, 13);
- DataflowAssert.that(sessionsCombinePerKey).containsInAnyOrder(
+ PAssert.that(fixedWindowsSum).containsInAnyOrder(2, 4, 1, 13);
+ PAssert.that(sessionsCombinePerKey).containsInAnyOrder(
KV.of("a", "1114a"),
KV.of("b", "11b"),
KV.of("b", "013b"));
- DataflowAssert.that(sessionsCombineGlobally).containsInAnyOrder("11114G", "013G");
+ PAssert.that(sessionsCombineGlobally).containsInAnyOrder("11114G", "013G");
p.run();
}
@@ -466,7 +466,7 @@ public class CombineTest implements Serializable {
.apply(Window.<Integer>into(FixedWindows.of(Duration.millis(1))))
.apply(Combine.globally(new MeanInts()).withoutDefaults());
- DataflowAssert.that(mean).empty();
+ PAssert.that(mean).empty();
p.run();
}
@@ -551,10 +551,10 @@ public class CombineTest implements Serializable {
Combine.perKey(mean).withHotKeyFanout(splitHotKeyFanout));
List<KV<String, Double>> expected = Arrays.asList(KV.of("a", 2.0), KV.of("b", 7.0));
- DataflowAssert.that(coldMean).containsInAnyOrder(expected);
- DataflowAssert.that(warmMean).containsInAnyOrder(expected);
- DataflowAssert.that(hotMean).containsInAnyOrder(expected);
- DataflowAssert.that(splitMean).containsInAnyOrder(expected);
+ PAssert.that(coldMean).containsInAnyOrder(expected);
+ PAssert.that(warmMean).containsInAnyOrder(expected);
+ PAssert.that(hotMean).containsInAnyOrder(expected);
+ PAssert.that(splitMean).containsInAnyOrder(expected);
p.run();
}
@@ -582,7 +582,7 @@ public class CombineTest implements Serializable {
.apply(Sum.integersGlobally().withoutDefaults().withFanout(2))
.apply(ParDo.of(new GetLast()));
- DataflowAssert.that(output).containsInAnyOrder(15);
+ PAssert.that(output).containsInAnyOrder(15);
p.run();
}
@@ -597,8 +597,8 @@ public class CombineTest implements Serializable {
.apply("ObjProduct", Combine.<String, Integer, Integer>perKey(new TestProdObj()));
List<KV<String, Integer>> expected = Arrays.asList(KV.of("a", 16), KV.of("b", 169));
- DataflowAssert.that(intProduct).containsInAnyOrder(expected);
- DataflowAssert.that(objProduct).containsInAnyOrder(expected);
+ PAssert.that(intProduct).containsInAnyOrder(expected);
+ PAssert.that(objProduct).containsInAnyOrder(expected);
p.run();
}
@@ -658,7 +658,7 @@ public class CombineTest implements Serializable {
}
}).withSideInputs(view));
- DataflowAssert.thatSingleton(output).isEqualTo(0);
+ PAssert.thatSingleton(output).isEqualTo(0);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CountTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CountTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CountTest.java
index f8664c3..1a5ca8b 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CountTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CountTest.java
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals;
import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -58,7 +58,7 @@ public class CountTest {
PCollection<KV<String, Long>> output =
input.apply(Count.<String>perElement());
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder(
KV.of("hi", 4L),
KV.of("there", 1L),
@@ -80,7 +80,7 @@ public class CountTest {
PCollection<KV<String, Long>> output =
input.apply(Count.<String>perElement());
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
@@ -94,7 +94,7 @@ public class CountTest {
PCollection<Long> output =
input.apply(Count.<String>globally());
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder(13L);
p.run();
}
@@ -109,7 +109,7 @@ public class CountTest {
PCollection<Long> output =
input.apply(Count.<String>globally());
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder(0L);
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CreateTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CreateTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CreateTest.java
index 9ace4e4..432795d 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CreateTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/CreateTest.java
@@ -27,7 +27,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.SerializableCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
import com.google.cloud.dataflow.sdk.coders.VoidCoder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -65,7 +65,7 @@ public class CreateTest {
PCollection<String> output =
p.apply(Create.of(LINES));
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder(LINES_ARRAY);
p.run();
}
@@ -79,7 +79,7 @@ public class CreateTest {
p.apply(Create.of(NO_LINES)
.withCoder(StringUtf8Coder.of()));
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder(NO_LINES_ARRAY);
p.run();
}
@@ -122,7 +122,7 @@ public class CreateTest {
PCollection<String> output =
p.apply(Create.of(null, "test1", null, "test2", null)
.withCoder(SerializableCoder.of(String.class)));
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder(null, "test1", null, "test2", null);
p.run();
}
@@ -136,7 +136,7 @@ public class CreateTest {
TimestampedValue.of("a", new Instant(0)),
TimestampedValue.of("b", new Instant(0))));
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder(
TimestampedValue.of("a", new Instant(0)),
TimestampedValue.of("b", new Instant(0)));
@@ -162,7 +162,7 @@ public class CreateTest {
p.apply(Create.timestamped(data))
.apply(ParDo.of(new PrintTimestamps()));
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder("a:1", "b:2", "c:3");
p.run();
}
@@ -176,7 +176,7 @@ public class CreateTest {
.apply(Create.timestamped(new ArrayList<TimestampedValue<String>>())
.withCoder(StringUtf8Coder.of()));
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
@@ -213,7 +213,7 @@ public class CreateTest {
public void testCreateWithVoidType() throws Exception {
Pipeline p = TestPipeline.create();
PCollection<Void> output = p.apply(Create.of((Void) null, (Void) null));
- DataflowAssert.that(output).containsInAnyOrder((Void) null, (Void) null);
+ PAssert.that(output).containsInAnyOrder((Void) null, (Void) null);
p.run();
}
@@ -226,7 +226,7 @@ public class CreateTest {
KV.of((Void) null, (Void) null),
KV.of((Void) null, (Void) null)));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of((Void) null, (Void) null),
KV.of((Void) null, (Void) null));
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FilterTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FilterTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FilterTest.java
index 1af8777..3bbe5a5 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FilterTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FilterTest.java
@@ -17,7 +17,7 @@
*/
package com.google.cloud.dataflow.sdk.transforms;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.PCollection;
@@ -65,7 +65,7 @@ public class FilterTest implements Serializable {
.apply(Create.of(591, 11789, 1257, 24578, 24799, 307))
.apply(Filter.by(new TrivialFn(true)));
- DataflowAssert.that(output).containsInAnyOrder(591, 11789, 1257, 24578, 24799, 307);
+ PAssert.that(output).containsInAnyOrder(591, 11789, 1257, 24578, 24799, 307);
p.run();
}
@@ -78,7 +78,7 @@ public class FilterTest implements Serializable {
.apply(Create.of(1, 2, 4, 5))
.apply(Filter.by(new TrivialFn(false)));
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
@@ -92,7 +92,7 @@ public class FilterTest implements Serializable {
.apply(Create.of(1, 2, 3, 4, 5, 6, 7))
.apply(Filter.by(new EvenFn()));
- DataflowAssert.that(output).containsInAnyOrder(2, 4, 6);
+ PAssert.that(output).containsInAnyOrder(2, 4, 6);
p.run();
}
@@ -105,7 +105,7 @@ public class FilterTest implements Serializable {
.apply(Create.of(591, 11789, 1257, 24578, 24799, 307))
.apply(Filter.byPredicate(new TrivialFn(true)));
- DataflowAssert.that(output).containsInAnyOrder(591, 11789, 1257, 24578, 24799, 307);
+ PAssert.that(output).containsInAnyOrder(591, 11789, 1257, 24578, 24799, 307);
p.run();
}
@@ -117,7 +117,7 @@ public class FilterTest implements Serializable {
.apply(Create.of(1, 2, 4, 5))
.apply(Filter.byPredicate(new TrivialFn(false)));
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
@@ -130,7 +130,7 @@ public class FilterTest implements Serializable {
.apply(Create.of(1, 2, 3, 4, 5, 6, 7))
.apply(Filter.byPredicate(new EvenFn()));
- DataflowAssert.that(output).containsInAnyOrder(2, 4, 6);
+ PAssert.that(output).containsInAnyOrder(2, 4, 6);
p.run();
}
@@ -143,7 +143,7 @@ public class FilterTest implements Serializable {
.apply(Create.of(1, 2, 3, 4, 5, 6, 7))
.apply(Filter.lessThan(4));
- DataflowAssert.that(output).containsInAnyOrder(1, 2, 3);
+ PAssert.that(output).containsInAnyOrder(1, 2, 3);
p.run();
}
@@ -155,7 +155,7 @@ public class FilterTest implements Serializable {
.apply(Create.of(1, 2, 3, 4, 5, 6, 7))
.apply(Filter.greaterThan(4));
- DataflowAssert.that(output).containsInAnyOrder(5, 6, 7);
+ PAssert.that(output).containsInAnyOrder(5, 6, 7);
p.run();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlatMapElementsTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlatMapElementsTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlatMapElementsTest.java
index b204b47..323b238 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlatMapElementsTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlatMapElementsTest.java
@@ -21,7 +21,7 @@ import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
import com.google.cloud.dataflow.sdk.values.PCollection;
@@ -68,7 +68,7 @@ public class FlatMapElementsTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(1, -2, -1, -3, 2, 3);
+ PAssert.that(output).containsInAnyOrder(1, -2, -1, -3, 2, 3);
pipeline.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlattenTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlattenTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlattenTest.java
index f5b3fdc..a2ded26 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlattenTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/FlattenTest.java
@@ -31,7 +31,7 @@ import com.google.cloud.dataflow.sdk.coders.ListCoder;
import com.google.cloud.dataflow.sdk.coders.SetCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
import com.google.cloud.dataflow.sdk.coders.VoidCoder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.windowing.FixedWindows;
@@ -82,7 +82,7 @@ public class FlattenTest implements Serializable {
makePCollectionListOfStrings(p, inputs)
.apply(Flatten.<String>pCollections());
- DataflowAssert.that(output).containsInAnyOrder(flattenLists(inputs));
+ PAssert.that(output).containsInAnyOrder(flattenLists(inputs));
p.run();
}
@@ -99,7 +99,7 @@ public class FlattenTest implements Serializable {
.apply(Flatten.<String>pCollections())
.apply(ParDo.of(new IdentityFn<String>(){}));
- DataflowAssert.that(output).containsInAnyOrder(flattenLists(inputs));
+ PAssert.that(output).containsInAnyOrder(flattenLists(inputs));
p.run();
}
@@ -112,7 +112,7 @@ public class FlattenTest implements Serializable {
PCollectionList.<String>empty(p)
.apply(Flatten.<String>pCollections()).setCoder(StringUtf8Coder.of());
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
@@ -137,7 +137,7 @@ public class FlattenTest implements Serializable {
}
}));
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
@@ -152,7 +152,7 @@ public class FlattenTest implements Serializable {
.apply(Flatten.<String>pCollections()).setCoder(StringUtf8Coder.of())
.apply(ParDo.of(new IdentityFn<String>(){}));
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
@@ -184,7 +184,7 @@ public class FlattenTest implements Serializable {
PCollection<String> output =
input.apply(Flatten.<String>iterables());
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder(LINES_ARRAY);
p.run();
@@ -200,7 +200,7 @@ public class FlattenTest implements Serializable {
PCollection<String> output = input.apply(Flatten.<String>iterables());
- DataflowAssert.that(output).containsInAnyOrder(LINES_ARRAY);
+ PAssert.that(output).containsInAnyOrder(LINES_ARRAY);
p.run();
}
@@ -217,7 +217,7 @@ public class FlattenTest implements Serializable {
PCollection<String> output = input.apply(Flatten.<String>iterables());
- DataflowAssert.that(output).containsInAnyOrder(LINES_ARRAY);
+ PAssert.that(output).containsInAnyOrder(LINES_ARRAY);
p.run();
}
@@ -236,7 +236,7 @@ public class FlattenTest implements Serializable {
PCollection<String> output = input.apply(Flatten.<String>iterables());
- DataflowAssert.that(output).containsInAnyOrder(LINES_ARRAY);
+ PAssert.that(output).containsInAnyOrder(LINES_ARRAY);
p.run();
}
@@ -253,7 +253,7 @@ public class FlattenTest implements Serializable {
PCollection<String> output =
input.apply(Flatten.<String>iterables());
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder(NO_LINES_ARRAY);
p.run();
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/GroupByKeyTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/GroupByKeyTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/GroupByKeyTest.java
index 6fb811e..59729a0 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/GroupByKeyTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/GroupByKeyTest.java
@@ -31,7 +31,7 @@ import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
import com.google.cloud.dataflow.sdk.options.DirectPipelineOptions;
import com.google.cloud.dataflow.sdk.options.PipelineOptionsFactory;
import com.google.cloud.dataflow.sdk.runners.DirectPipelineRunner;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.windowing.FixedWindows;
@@ -91,7 +91,7 @@ public class GroupByKeyTest {
PCollection<KV<String, Iterable<Integer>>> output =
input.apply(GroupByKey.<String, Integer>create());
- DataflowAssert.that(output)
+ PAssert.that(output)
.satisfies(new AssertThatHasExpectedContentsForTestGroupByKey());
p.run();
@@ -133,7 +133,7 @@ public class GroupByKeyTest {
input.apply(Window.<KV<String, Integer>>into(FixedWindows.of(new Duration(5))))
.apply(GroupByKey.<String, Integer>create());
- DataflowAssert.that(output)
+ PAssert.that(output)
.satisfies(new AssertThatHasExpectedContentsForTestGroupByKeyAndWindows());
p.run();
@@ -170,7 +170,7 @@ public class GroupByKeyTest {
PCollection<KV<String, Iterable<Integer>>> output =
input.apply(GroupByKey.<String, Integer>create());
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/KeysTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/KeysTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/KeysTest.java
index 66d9e40..27f894a 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/KeysTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/KeysTest.java
@@ -21,7 +21,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.BigEndianIntegerCoder;
import com.google.cloud.dataflow.sdk.coders.KvCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -62,7 +62,7 @@ public class KeysTest {
KvCoder.of(StringUtf8Coder.of(), BigEndianIntegerCoder.of())));
PCollection<String> output = input.apply(Keys.<String>create());
- DataflowAssert.that(output)
+ PAssert.that(output)
.containsInAnyOrder("one", "two", "three", "dup", "dup");
p.run();
@@ -78,7 +78,7 @@ public class KeysTest {
KvCoder.of(StringUtf8Coder.of(), BigEndianIntegerCoder.of())));
PCollection<String> output = input.apply(Keys.<String>create());
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/KvSwapTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/KvSwapTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/KvSwapTest.java
index fa49564..b084dbc 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/KvSwapTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/KvSwapTest.java
@@ -21,7 +21,7 @@ import com.google.cloud.dataflow.sdk.Pipeline;
import com.google.cloud.dataflow.sdk.coders.BigEndianIntegerCoder;
import com.google.cloud.dataflow.sdk.coders.KvCoder;
import com.google.cloud.dataflow.sdk.coders.StringUtf8Coder;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
@@ -64,7 +64,7 @@ public class KvSwapTest {
PCollection<KV<Integer, String>> output = input.apply(
KvSwap.<String, Integer>create());
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
KV.of(1, "one"),
KV.of(2, "two"),
KV.of(3, "three"),
@@ -86,7 +86,7 @@ public class KvSwapTest {
PCollection<KV<Integer, String>> output = input.apply(
KvSwap.<String, Integer>create());
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
p.run();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/MapElementsTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/MapElementsTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/MapElementsTest.java
index c9f5d16..7fb13a2 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/MapElementsTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/MapElementsTest.java
@@ -21,7 +21,7 @@ import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import com.google.cloud.dataflow.sdk.Pipeline;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.values.KV;
import com.google.cloud.dataflow.sdk.values.PCollection;
@@ -59,7 +59,7 @@ public class MapElementsTest implements Serializable {
}
}));
- DataflowAssert.that(output).containsInAnyOrder(-2, -1, -3);
+ PAssert.that(output).containsInAnyOrder(-2, -1, -3);
pipeline.run();
}
@@ -79,7 +79,7 @@ public class MapElementsTest implements Serializable {
}
}).withOutputType(new TypeDescriptor<Integer>() {}));
- DataflowAssert.that(output).containsInAnyOrder(-2, -1, -3);
+ PAssert.that(output).containsInAnyOrder(-2, -1, -3);
pipeline.run();
}
http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/d73ceab8/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ParDoTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ParDoTest.java b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ParDoTest.java
index abbb078..4a55bea 100644
--- a/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ParDoTest.java
+++ b/sdks/java/core/src/test/java/com/google/cloud/dataflow/sdk/transforms/ParDoTest.java
@@ -38,7 +38,7 @@ import com.google.cloud.dataflow.sdk.coders.CoderException;
import com.google.cloud.dataflow.sdk.coders.ListCoder;
import com.google.cloud.dataflow.sdk.coders.VarIntCoder;
import com.google.cloud.dataflow.sdk.runners.DirectPipelineRunner;
-import com.google.cloud.dataflow.sdk.testing.DataflowAssert;
+import com.google.cloud.dataflow.sdk.testing.PAssert;
import com.google.cloud.dataflow.sdk.testing.RunnableOnService;
import com.google.cloud.dataflow.sdk.testing.TestPipeline;
import com.google.cloud.dataflow.sdk.transforms.DoFn.RequiresWindowAccess;
@@ -343,7 +343,7 @@ public class ParDoTest implements Serializable {
.apply(Create.of(inputs))
.apply(ParDo.of(new TestDoFn()));
- DataflowAssert.that(output)
+ PAssert.that(output)
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs));
pipeline.run();
@@ -360,7 +360,7 @@ public class ParDoTest implements Serializable {
.apply(Create.of(inputs))
.apply(ParDo.of(new TestDoFnWithContext()));
- DataflowAssert.that(output)
+ PAssert.that(output)
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs));
pipeline.run();
@@ -377,7 +377,7 @@ public class ParDoTest implements Serializable {
.apply(Create.of(inputs).withCoder(VarIntCoder.of()))
.apply("TestDoFn", ParDo.of(new TestDoFn()));
- DataflowAssert.that(output)
+ PAssert.that(output)
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs));
pipeline.run();
@@ -395,7 +395,7 @@ public class ParDoTest implements Serializable {
.apply(Create.of(inputs).withCoder(VarIntCoder.of()))
.apply("TestDoFn", ParDo.of(new TestNoOutputDoFn()));
- DataflowAssert.that(output).empty();
+ PAssert.that(output).empty();
pipeline.run();
}
@@ -426,19 +426,19 @@ public class ParDoTest implements Serializable {
.and(sideOutputTagUnwritten)
.and(sideOutputTag2)));
- DataflowAssert.that(outputs.get(mainOutputTag))
+ PAssert.that(outputs.get(mainOutputTag))
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs));
- DataflowAssert.that(outputs.get(sideOutputTag1))
+ PAssert.that(outputs.get(sideOutputTag1))
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs)
.fromSideOutput(sideOutputTag1));
- DataflowAssert.that(outputs.get(sideOutputTag2))
+ PAssert.that(outputs.get(sideOutputTag2))
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs)
.fromSideOutput(sideOutputTag2));
- DataflowAssert.that(outputs.get(sideOutputTag3))
+ PAssert.that(outputs.get(sideOutputTag3))
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs)
.fromSideOutput(sideOutputTag3));
- DataflowAssert.that(outputs.get(sideOutputTagUnwritten)).empty();
+ PAssert.that(outputs.get(sideOutputTagUnwritten)).empty();
pipeline.run();
}
@@ -467,19 +467,19 @@ public class ParDoTest implements Serializable {
TupleTagList.of(sideOutputTag3).and(sideOutputTag1)
.and(sideOutputTagUnwritten).and(sideOutputTag2)));
- DataflowAssert.that(outputs.get(mainOutputTag))
+ PAssert.that(outputs.get(mainOutputTag))
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs));
- DataflowAssert.that(outputs.get(sideOutputTag1))
+ PAssert.that(outputs.get(sideOutputTag1))
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs)
.fromSideOutput(sideOutputTag1));
- DataflowAssert.that(outputs.get(sideOutputTag2))
+ PAssert.that(outputs.get(sideOutputTag2))
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs)
.fromSideOutput(sideOutputTag2));
- DataflowAssert.that(outputs.get(sideOutputTag3))
+ PAssert.that(outputs.get(sideOutputTag3))
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs)
.fromSideOutput(sideOutputTag3));
- DataflowAssert.that(outputs.get(sideOutputTagUnwritten)).empty();
+ PAssert.that(outputs.get(sideOutputTagUnwritten)).empty();
pipeline.run();
}
@@ -503,10 +503,10 @@ public class ParDoTest implements Serializable {
mainOutputTag,
TupleTagList.of(sideOutputTag1).and(sideOutputTag2)));
- DataflowAssert.that(outputs.get(mainOutputTag)).empty();
+ PAssert.that(outputs.get(mainOutputTag)).empty();
- DataflowAssert.that(outputs.get(sideOutputTag1)).empty();
- DataflowAssert.that(outputs.get(sideOutputTag2)).empty();
+ PAssert.that(outputs.get(sideOutputTag1)).empty();
+ PAssert.that(outputs.get(sideOutputTag2)).empty();
pipeline.run();
}
@@ -531,8 +531,8 @@ public class ParDoTest implements Serializable {
c.sideOutput(sideOutputTag, c.element());
}}));
- DataflowAssert.that(outputs.get(mainOutputTag)).empty();
- DataflowAssert.that(outputs.get(sideOutputTag)).containsInAnyOrder(inputs);
+ PAssert.that(outputs.get(mainOutputTag)).empty();
+ PAssert.that(outputs.get(sideOutputTag)).containsInAnyOrder(inputs);
pipeline.run();
}
@@ -551,7 +551,7 @@ public class ParDoTest implements Serializable {
Arrays.<PCollectionView<Integer>>asList(),
Arrays.asList(sideTag))));
- DataflowAssert.that(output)
+ PAssert.that(output)
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs));
pipeline.run();
@@ -617,7 +617,7 @@ public class ParDoTest implements Serializable {
Arrays.asList(sideInput1, sideInput2),
Arrays.<TupleTag<String>>asList())));
- DataflowAssert.that(output)
+ PAssert.that(output)
.satisfies(ParDoTest.HasExpectedOutput
.forInput(inputs)
.andSideInputs(11, 222));
@@ -651,7 +651,7 @@ public class ParDoTest implements Serializable {
Arrays.asList(sideInput1, sideInput2),
Arrays.<TupleTag<String>>asList())));
- DataflowAssert.that(output)
+ PAssert.that(output)
.satisfies(ParDoTest.HasExpectedOutput
.forInput(inputs)
.andSideInputs(11, 222));
@@ -689,7 +689,7 @@ public class ParDoTest implements Serializable {
Arrays.asList(sideInput1, sideInput2),
Arrays.<TupleTag<String>>asList())));
- DataflowAssert.that(outputs.get(mainOutputTag))
+ PAssert.that(outputs.get(mainOutputTag))
.satisfies(ParDoTest.HasExpectedOutput
.forInput(inputs)
.andSideInputs(11, 222));
@@ -727,7 +727,7 @@ public class ParDoTest implements Serializable {
Arrays.asList(sideInput1, sideInput2),
Arrays.<TupleTag<String>>asList())));
- DataflowAssert.that(outputs.get(mainOutputTag))
+ PAssert.that(outputs.get(mainOutputTag))
.satisfies(ParDoTest.HasExpectedOutput
.forInput(inputs)
.andSideInputs(11, 222));
@@ -896,7 +896,7 @@ public class ParDoTest implements Serializable {
// Test that Coder inference of the result works through
// user-defined PTransforms.
- DataflowAssert.that(output)
+ PAssert.that(output)
.satisfies(ParDoTest.HasExpectedOutput.forInput(inputs));
pipeline.run();
@@ -918,8 +918,8 @@ public class ParDoTest implements Serializable {
PCollection<Integer> by3then2 = by3
.apply("Filter2sAgain", ParDo.of(new MultiFilter.FilterFn(2)));
- DataflowAssert.that(by2then3).containsInAnyOrder(6);
- DataflowAssert.that(by3then2).containsInAnyOrder(6);
+ PAssert.that(by2then3).containsInAnyOrder(6);
+ PAssert.that(by3then2).containsInAnyOrder(6);
pipeline.run();
}
@@ -1003,7 +1003,7 @@ public class ParDoTest implements Serializable {
}
}
- /** DataflowAssert "matcher" for expected output. */
+ /** PAssert "matcher" for expected output. */
static class HasExpectedOutput
implements SerializableFunction<Iterable<String>, Void>, Serializable {
private final List<Integer> inputs;
@@ -1209,7 +1209,7 @@ public class ParDoTest implements Serializable {
.apply(ParDo.of(new TestShiftTimestampDoFn(Duration.ZERO, Duration.ZERO)))
.apply(ParDo.of(new TestFormatTimestampDoFn()));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
"processing: 3, timestamp: 3",
"processing: 42, timestamp: 42",
"processing: 6, timestamp: 6");
@@ -1240,7 +1240,7 @@ public class ParDoTest implements Serializable {
.apply(ParDo.of(new TestShiftTimestampDoFn(Duration.ZERO, Duration.ZERO)))
.apply(ParDo.of(new TestFormatTimestampDoFn()));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
"processing: 3, timestamp: 3",
"processing: 42, timestamp: 42",
"processing: 6, timestamp: 6");
@@ -1262,7 +1262,7 @@ public class ParDoTest implements Serializable {
Duration.millis(-1000))))
.apply(ParDo.of(new TestFormatTimestampDoFn()));
- DataflowAssert.that(output).containsInAnyOrder(
+ PAssert.that(output).containsInAnyOrder(
"processing: 3, timestamp: -997",
"processing: 42, timestamp: -958",
"processing: 6, timestamp: -994");
@@ -1369,7 +1369,7 @@ public class ParDoTest implements Serializable {
}))
.apply(ParDo.of(new PrintingDoFn()));
- DataflowAssert.that(output).satisfies(new Checker());
+ PAssert.that(output).satisfies(new Checker());
pipeline.run();
}