beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amits...@apache.org
Subject [6/9] beam git commit: Exopse RegexMatcher as part of the SDK.
Date Mon, 20 Feb 2017 09:58:02 GMT
Exopse RegexMatcher as part of the SDK.


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/c18f8a2c
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/c18f8a2c
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/c18f8a2c

Branch: refs/heads/master
Commit: c18f8a2c33a74ea00f8bbba6fb7cd766de9082f4
Parents: 705695e
Author: Sela <ansela@paypal.com>
Authored: Sun Feb 12 18:33:55 2017 +0200
Committer: Sela <ansela@paypal.com>
Committed: Mon Feb 20 11:30:15 2017 +0200

----------------------------------------------------------------------
 .../runners/dataflow/util/PackageUtilTest.java  | 30 +-----------------
 .../apache/beam/sdk/testing/RegexMatcher.java   | 32 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/c18f8a2c/runners/google-cloud-dataflow-java/src/test/java/org/apache/beam/runners/dataflow/util/PackageUtilTest.java
----------------------------------------------------------------------
diff --git a/runners/google-cloud-dataflow-java/src/test/java/org/apache/beam/runners/dataflow/util/PackageUtilTest.java
b/runners/google-cloud-dataflow-java/src/test/java/org/apache/beam/runners/dataflow/util/PackageUtilTest.java
index 800c5a9..a11872f 100644
--- a/runners/google-cloud-dataflow-java/src/test/java/org/apache/beam/runners/dataflow/util/PackageUtilTest.java
+++ b/runners/google-cloud-dataflow-java/src/test/java/org/apache/beam/runners/dataflow/util/PackageUtilTest.java
@@ -66,7 +66,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import java.util.regex.Pattern;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 import org.apache.beam.runners.dataflow.util.PackageUtil.PackageAttributes;
@@ -74,11 +73,10 @@ import org.apache.beam.sdk.options.GcsOptions;
 import org.apache.beam.sdk.options.PipelineOptionsFactory;
 import org.apache.beam.sdk.testing.ExpectedLogs;
 import org.apache.beam.sdk.testing.FastNanoClockAndSleeper;
+import org.apache.beam.sdk.testing.RegexMatcher;
 import org.apache.beam.sdk.util.GcsUtil;
 import org.apache.beam.sdk.util.IOChannelUtils;
 import org.apache.beam.sdk.util.gcsfs.GcsPath;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
 import org.hamcrest.Matchers;
 import org.junit.Before;
 import org.junit.Rule;
@@ -107,32 +105,6 @@ public class PackageUtilTest {
   // 128 bits, base64 encoded is 171 bits, rounds to 22 bytes
   private static final String HASH_PATTERN = "[a-zA-Z0-9+-]{22}";
 
-  // Hamcrest matcher to assert a string matches a pattern
-  private static class RegexMatcher extends BaseMatcher<String> {
-    private final Pattern pattern;
-
-    public RegexMatcher(String regex) {
-      this.pattern = Pattern.compile(regex);
-    }
-
-    @Override
-    public boolean matches(Object o) {
-      if (!(o instanceof String)) {
-        return false;
-      }
-      return pattern.matcher((String) o).matches();
-    }
-
-    @Override
-    public void describeTo(Description description) {
-      description.appendText(String.format("matches regular expression %s", pattern));
-    }
-
-    public static RegexMatcher matches(String regex) {
-      return new RegexMatcher(regex);
-    }
-  }
-
   @Before
   public void setUp() {
     MockitoAnnotations.initMocks(this);

http://git-wip-us.apache.org/repos/asf/beam/blob/c18f8a2c/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/RegexMatcher.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/RegexMatcher.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/RegexMatcher.java
new file mode 100644
index 0000000..a4b14fe
--- /dev/null
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/RegexMatcher.java
@@ -0,0 +1,32 @@
+package org.apache.beam.sdk.testing;
+
+import java.util.regex.Pattern;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+
+
+/** Hamcrest matcher to assert a string matches a pattern. */
+public class RegexMatcher extends BaseMatcher<String> {
+  private final Pattern pattern;
+
+  public RegexMatcher(String regex) {
+    this.pattern = Pattern.compile(regex);
+  }
+
+  @Override
+  public boolean matches(Object o) {
+    if (!(o instanceof String)) {
+      return false;
+    }
+    return pattern.matcher((String) o).matches();
+  }
+
+  @Override
+  public void describeTo(Description description) {
+    description.appendText(String.format("matches regular expression %s", pattern));
+  }
+
+  public static RegexMatcher matches(String regex) {
+    return new RegexMatcher(regex);
+  }
+}


Mime
View raw message