From e47ad52cf0cc839b1e42d1361f61955909f14c4d Mon Sep 17 00:00:00 2001 From: nnegrey Date: Wed, 25 Sep 2019 08:14:56 -0600 Subject: [PATCH 1/3] Fix failing tests --- .../src/test/java/com/example/vision/DetectIT.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java b/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java index 3f4857d9e63..c742b03c55c 100644 --- a/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java +++ b/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java @@ -46,7 +46,7 @@ public class DetectIT { private static final String OUTPUT_PREFIX = "OCR_PDF_TEST_OUTPUT_" + UUID.randomUUID().toString(); @Before - public void setUp() throws IOException { + public void setUp() { bout = new ByteArrayOutputStream(); out = new PrintStream(bout); System.setOut(out); @@ -312,8 +312,8 @@ public void testCropHints() throws Exception { // Assert String got = bout.toString(); assertThat(got).contains("vertices {"); - assertThat(got).contains("x: 599"); - assertThat(got).contains("y: 475"); + assertThat(got).contains("x: 2"); // Assert in the 200 range + assertThat(got).contains("y: 4"); // Assert in the 400 range } @Test @@ -325,8 +325,8 @@ public void testCropHintsGcs() throws Exception { // Assert String got = bout.toString(); assertThat(got).contains("vertices {"); - assertThat(got).contains("x: 599"); - assertThat(got).contains("y: 475"); + assertThat(got).contains("x: 2"); // Assert in the 200 range + assertThat(got).contains("y: 4"); // Assert in the 400 range } @Test From ec5cb18752603f410fc3a5a80941cb59c029c31a Mon Sep 17 00:00:00 2001 From: nnegrey Date: Mon, 30 Sep 2019 10:52:48 -0600 Subject: [PATCH 2/3] Replace with regex --- .../src/test/java/com/example/vision/DetectIT.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java b/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java index c742b03c55c..98beefc8f92 100644 --- a/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java +++ b/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java @@ -27,6 +27,7 @@ import java.io.IOException; import java.io.PrintStream; import java.util.UUID; +import java.util.regex.Pattern; import org.junit.After; import org.junit.Before; @@ -312,8 +313,8 @@ public void testCropHints() throws Exception { // Assert String got = bout.toString(); assertThat(got).contains("vertices {"); - assertThat(got).contains("x: 2"); // Assert in the 200 range - assertThat(got).contains("y: 4"); // Assert in the 400 range + assertThat(got).containsMatch(Pattern.compile("x: 2\\d{2}")); + assertThat(got).containsMatch(Pattern.compile("x: 4\\d{2}")); } @Test @@ -325,8 +326,8 @@ public void testCropHintsGcs() throws Exception { // Assert String got = bout.toString(); assertThat(got).contains("vertices {"); - assertThat(got).contains("x: 2"); // Assert in the 200 range - assertThat(got).contains("y: 4"); // Assert in the 400 range + assertThat(got).containsMatch(Pattern.compile("x: 2\\d{2}")); + assertThat(got).containsMatch(Pattern.compile("x: 4\\d{2}")); } @Test From 3e6c337ee8feafab0519d449c15f061345f902a0 Mon Sep 17 00:00:00 2001 From: nnegrey Date: Mon, 30 Sep 2019 10:56:47 -0600 Subject: [PATCH 3/3] x and y not just x --- .../src/test/java/com/example/vision/DetectIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java b/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java index 98beefc8f92..5390db983c5 100644 --- a/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java +++ b/vision/cloud-client/src/test/java/com/example/vision/DetectIT.java @@ -314,7 +314,7 @@ public void testCropHints() throws Exception { String got = bout.toString(); assertThat(got).contains("vertices {"); assertThat(got).containsMatch(Pattern.compile("x: 2\\d{2}")); - assertThat(got).containsMatch(Pattern.compile("x: 4\\d{2}")); + assertThat(got).containsMatch(Pattern.compile("y: 4\\d{2}")); } @Test @@ -327,7 +327,7 @@ public void testCropHintsGcs() throws Exception { String got = bout.toString(); assertThat(got).contains("vertices {"); assertThat(got).containsMatch(Pattern.compile("x: 2\\d{2}")); - assertThat(got).containsMatch(Pattern.compile("x: 4\\d{2}")); + assertThat(got).containsMatch(Pattern.compile("y: 4\\d{2}")); } @Test