You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by pe...@apache.org on 2017/07/24 02:53:51 UTC
[1/2] beam git commit: ReshuffleTest: replace Iterable equal tests
with matchers.
Repository: beam
Updated Branches:
refs/heads/master f39874860 -> 49d4cf4de
ReshuffleTest: replace Iterable equal tests with matchers.
Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/b1adbfbc
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/b1adbfbc
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/b1adbfbc
Branch: refs/heads/master
Commit: b1adbfbcf0a949a92a022c86b061ba3b64b69c9b
Parents: f398748
Author: Pei He <pe...@apache.org>
Authored: Wed Jul 19 20:38:49 2017 +0800
Committer: Pei He <pe...@apache.org>
Committed: Mon Jul 24 10:53:00 2017 +0800
----------------------------------------------------------------------
.../beam/sdk/transforms/ReshuffleTest.java | 22 ++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/beam/blob/b1adbfbc/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ReshuffleTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ReshuffleTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ReshuffleTest.java
index 3cd7cf9..0eb8e2d 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ReshuffleTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ReshuffleTest.java
@@ -17,7 +17,10 @@
*/
package org.apache.beam.sdk.transforms;
+import static org.apache.beam.sdk.TestUtils.KvMatcher.isKv;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
+import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
@@ -70,9 +73,16 @@ public class ReshuffleTest implements Serializable {
KV.of("k1", 3),
KV.of("k2", 4));
- private static final List<KV<String, Iterable<Integer>>> GROUPED_TESTABLE_KVS = ImmutableList.of(
- KV.of("k1", (Iterable<Integer>) ImmutableList.of(3)),
- KV.of("k2", (Iterable<Integer>) ImmutableList.of(4)));
+ private static class AssertThatHasExpectedContents
+ implements SerializableFunction<Iterable<KV<String, Iterable<Integer>>>, Void> {
+ @Override
+ public Void apply(Iterable<KV<String, Iterable<Integer>>> actual) {
+ assertThat(actual, containsInAnyOrder(
+ isKv(is("k1"), containsInAnyOrder(3)),
+ isKv(is("k2"), containsInAnyOrder(4))));
+ return null;
+ }
+ }
@Rule
public final transient TestPipeline pipeline = TestPipeline.create();
@@ -167,7 +177,7 @@ public class ReshuffleTest implements Serializable {
PCollection<KV<String, Iterable<Integer>>> output = input
.apply(Reshuffle.<String, Iterable<Integer>>of());
- PAssert.that(output).containsInAnyOrder(GROUPED_TESTABLE_KVS);
+ PAssert.that(output).satisfies(new AssertThatHasExpectedContents());
assertEquals(
input.getWindowingStrategy(),
@@ -190,7 +200,7 @@ public class ReshuffleTest implements Serializable {
PCollection<KV<String, Iterable<Integer>>> output = input
.apply(Reshuffle.<String, Iterable<Integer>>of());
- PAssert.that(output).containsInAnyOrder(GROUPED_TESTABLE_KVS);
+ PAssert.that(output).satisfies(new AssertThatHasExpectedContents());
assertEquals(
input.getWindowingStrategy(),
@@ -213,7 +223,7 @@ public class ReshuffleTest implements Serializable {
PCollection<KV<String, Iterable<Integer>>> output = input
.apply(Reshuffle.<String, Iterable<Integer>>of());
- PAssert.that(output).containsInAnyOrder(GROUPED_TESTABLE_KVS);
+ PAssert.that(output).satisfies(new AssertThatHasExpectedContents());
assertEquals(
input.getWindowingStrategy(),
[2/2] beam git commit: This closes #3593
Posted by pe...@apache.org.
This closes #3593
Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/49d4cf4d
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/49d4cf4d
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/49d4cf4d
Branch: refs/heads/master
Commit: 49d4cf4de48f121f583ddf7e2b7d0e56370a735c
Parents: f398748 b1adbfb
Author: Pei He <pe...@apache.org>
Authored: Mon Jul 24 10:53:27 2017 +0800
Committer: Pei He <pe...@apache.org>
Committed: Mon Jul 24 10:53:27 2017 +0800
----------------------------------------------------------------------
.../beam/sdk/transforms/ReshuffleTest.java | 22 ++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------