Skip to content

Commit 81da681

Browse files
shollymanchingor13
authored andcommitted
samples: vision: address flakes due to collisions. (#1458)
* vision: address flakes due to collisions. * beta: convert batch future to actually wait for output properly. * explicit imports * additional explicit import
1 parent 16df5e8 commit 81da681

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.io.ByteArrayOutputStream;
2727
import java.io.IOException;
2828
import java.io.PrintStream;
29+
import java.util.UUID;
2930

3031
import org.junit.After;
3132
import org.junit.Before;
@@ -42,7 +43,7 @@ public class DetectIT {
4243
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
4344
private static final String ASSET_BUCKET = "cloud-samples-data";
4445
private static final String OUTPUT_BUCKET = PROJECT_ID;
45-
private static final String OUTPUT_PREFIX = "OCR_PDF_TEST_OUTPUT";
46+
private static final String OUTPUT_PREFIX = "OCR_PDF_TEST_OUTPUT_" + UUID.randomUUID().toString();
4647

4748
@Before
4849
public void setUp() throws IOException {
@@ -363,13 +364,13 @@ public void testDetectDocumentsGcs() throws Exception {
363364

364365
// Assert
365366
String got = bout.toString();
367+
366368
assertThat(got).contains("OIL, GAS AND MINERAL LEASE");
367369

368370
Storage storage = StorageOptions.getDefaultInstance().getService();
369371

370372
Page<Blob> blobs = storage.list(OUTPUT_BUCKET, BlobListOption.currentDirectory(),
371373
BlobListOption.prefix(OUTPUT_PREFIX + "/"));
372-
373374
for (Blob blob : blobs.iterateAll()) {
374375
blob.delete();
375376
}
@@ -397,4 +398,4 @@ public void testDetectLocalizedObjectsGcs() throws Exception {
397398
String got = bout.toString().toLowerCase();
398399
assertThat(got).contains("dog");
399400
}
400-
}
401+
}

0 commit comments

Comments
 (0)