Skip to content

Commit

Permalink
chore: fix batch test (#585)
Browse files Browse the repository at this point in the history
* chore: fix batch test

* fixed nit

* 🦉 Updates from OwlBot

* Update samples/snippets/src/test/java/com/example/translate/BatchTranslateTextTests.java

Co-authored-by: Averi Kitsch <[email protected]>

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Averi Kitsch <[email protected]>
  • Loading branch information
3 people authored and Shabirmean committed Nov 17, 2022
1 parent 752e1ae commit d76d1e2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class BatchTranslateTextTests {

private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String INPUT_URI = "gs://cloud-samples-data/translation/text.txt";
private static final String PREFIX = "BATCH_TRANSLATION_OUTPUT/";
private static final String OUTPUT_URI =
String.format("gs://%s/%s%s/", PROJECT_ID, PREFIX, UUID.randomUUID());
private static final String PREFIX =
String.format("translation-%s/%s", UUID.randomUUID(), "BATCH_TRANSLATION_OUTPUT/");
private static final String OUTPUT_URI = String.format("gs://%s/%s", PROJECT_ID, PREFIX);

private ByteArrayOutputStream bout;
private PrintStream out;
Expand Down Expand Up @@ -97,6 +98,9 @@ public void setUp() {
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);

// clean up bucket before the use to prevent concurrency issue.
cleanUpBucket();
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class BatchTranslateTextWithGlossaryAndModelTests {

private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String INPUT_URI =
"gs://cloud-samples-data/translation/text_with_custom_model_and_glossary.txt";
private static final String GLOSSARY_ID = "DO_NOT_DELETE_TEST_GLOSSARY";
private static final String MODEL_ID = "TRL3645318651705294848";
private static final String PREFIX = "BATCH_TRANSLATION_WITH_MODEL_OUTPUT/";
private static final String OUTPUT_URI =
String.format("gs://%s/%s%s/", PROJECT_ID, PREFIX, UUID.randomUUID());
private static final String PREFIX =
String.format("translation-%s/%s", UUID.randomUUID(), "BATCH_TRANSLATION_WITH_MODEL_OUTPUT/");
private static final String OUTPUT_URI = String.format("gs://%s/%s", PROJECT_ID, PREFIX);

private ByteArrayOutputStream bout;
private PrintStream out;
Expand Down Expand Up @@ -103,6 +104,9 @@ public void setUp() {
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);

// clear up bucket before the use to prevent concurrency issue.
cleanUpBucket();
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class BatchTranslateTextWithGlossaryTests {

private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String INPUT_URI =
"gs://cloud-samples-data/translation/text_with_glossary.txt";
private static final String GLOSSARY_ID = "DO_NOT_DELETE_TEST_GLOSSARY";
private static final String PREFIX = "BATCH_TRANSLATION_GLOSSARY_OUTPUT/";
private static final String OUTPUT_URI =
String.format("gs://%s/%s%s/", PROJECT_ID, PREFIX, UUID.randomUUID());
private static final String PREFIX =
String.format("translation-%s/%s", UUID.randomUUID(), "BATCH_TRANSLATION_GLOSSARY_OUTPUT/");
private static final String OUTPUT_URI = String.format("gs://%s/%s", PROJECT_ID, PREFIX);

private ByteArrayOutputStream bout;
private PrintStream out;
Expand Down Expand Up @@ -101,6 +102,9 @@ public void setUp() {
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);

// clear up bucket before the use to prevent concurrency issue.
cleanUpBucket();
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class BatchTranslateTextWithModelTests {

private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
private static final String INPUT_URI =
"gs://cloud-samples-data/translation/custom_model_text.txt";
private static final String MODEL_ID = "TRL3645318651705294848";
private static final String PREFIX = "BATCH_TRANSLATION_MODEL_GLOS_OUTPUT/";
private static final String OUTPUT_URI =
String.format("gs://%s/%s%s/", PROJECT_ID, PREFIX, UUID.randomUUID());
private static final String PREFIX =
String.format("translation-%s/%s", UUID.randomUUID(), "BATCH_TRANSLATION_MODEL_GLOS_OUTPUT/");
private static final String OUTPUT_URI = String.format("gs://%s/%s", PROJECT_ID, PREFIX);

private ByteArrayOutputStream bout;
private PrintStream out;
Expand Down Expand Up @@ -98,6 +99,9 @@ public void setUp() {
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);

// clear up bucket before the use to prevent concurrency issue.
cleanUpBucket();
}

@After
Expand Down

0 comments on commit d76d1e2

Please sign in to comment.