Skip to content

Commit 91cd1b3

Browse files
nnegreychingor13
authored andcommitted
samples: Fix failing tests (#1591)
* Fix failing tests * Replace with regex * x and y not just x
1 parent 81da681 commit 91cd1b3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

vision/snippets/src/test/java/com/example/vision/DetectIT.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.io.IOException;
2828
import java.io.PrintStream;
2929
import java.util.UUID;
30+
import java.util.regex.Pattern;
3031

3132
import org.junit.After;
3233
import org.junit.Before;
@@ -46,7 +47,7 @@ public class DetectIT {
4647
private static final String OUTPUT_PREFIX = "OCR_PDF_TEST_OUTPUT_" + UUID.randomUUID().toString();
4748

4849
@Before
49-
public void setUp() throws IOException {
50+
public void setUp() {
5051
bout = new ByteArrayOutputStream();
5152
out = new PrintStream(bout);
5253
System.setOut(out);
@@ -312,8 +313,8 @@ public void testCropHints() throws Exception {
312313
// Assert
313314
String got = bout.toString();
314315
assertThat(got).contains("vertices {");
315-
assertThat(got).contains("x: 599");
316-
assertThat(got).contains("y: 475");
316+
assertThat(got).containsMatch(Pattern.compile("x: 2\\d{2}"));
317+
assertThat(got).containsMatch(Pattern.compile("y: 4\\d{2}"));
317318
}
318319

319320
@Test
@@ -325,8 +326,8 @@ public void testCropHintsGcs() throws Exception {
325326
// Assert
326327
String got = bout.toString();
327328
assertThat(got).contains("vertices {");
328-
assertThat(got).contains("x: 599");
329-
assertThat(got).contains("y: 475");
329+
assertThat(got).containsMatch(Pattern.compile("x: 2\\d{2}"));
330+
assertThat(got).containsMatch(Pattern.compile("y: 4\\d{2}"));
330331
}
331332

332333
@Test

0 commit comments

Comments
 (0)