diff --git a/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextTests.java b/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextTests.java index 450c83322a9..6d130f47467 100644 --- a/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextTests.java +++ b/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextTests.java @@ -46,8 +46,6 @@ 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 ByteArrayOutputStream bout; private PrintStream out; @@ -115,8 +113,8 @@ public void tearDown() { @Test public void testBatchTranslateText() throws InterruptedException, ExecutionException, IOException, TimeoutException { - BatchTranslateText.batchTranslateText(PROJECT_ID, "en", "es", INPUT_URI, OUTPUT_URI); - + String outputUri = String.format("gs://%s/%s%s/", PROJECT_ID, PREFIX, UUID.randomUUID()); + BatchTranslateText.batchTranslateText(PROJECT_ID, "en", "es", INPUT_URI, outputUri); String got = bout.toString(); assertThat(got).contains("Total Characters: 13"); } diff --git a/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextWithGlossaryAndModelTests.java b/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextWithGlossaryAndModelTests.java index 7499aa6c9a0..f359edf9bd5 100644 --- a/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextWithGlossaryAndModelTests.java +++ b/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextWithGlossaryAndModelTests.java @@ -49,8 +49,6 @@ public class BatchTranslateTextWithGlossaryAndModelTests { 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_MODEL_GLOS_OUTPUT_"; - private static final String OUTPUT_URI = - String.format("gs://%s/%s%s/", PROJECT_ID, PREFIX, UUID.randomUUID()); private ByteArrayOutputStream bout; private PrintStream out; @@ -121,8 +119,9 @@ public void tearDown() { @Test public void testBatchTranslateTextWithGlossaryAndModel() throws InterruptedException, ExecutionException, IOException, TimeoutException { + String outputUri = String.format("gs://%s/%s%s/", PROJECT_ID, PREFIX, UUID.randomUUID()); BatchTranslateTextWithGlossaryAndModel.batchTranslateTextWithGlossaryAndModel( - PROJECT_ID, "en", "ja", INPUT_URI, OUTPUT_URI, GLOSSARY_ID, MODEL_ID); + PROJECT_ID, "en", "ja", INPUT_URI, outputUri, GLOSSARY_ID, MODEL_ID); String got = bout.toString(); assertThat(got).contains("Total Characters: 25"); } diff --git a/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextWithGlossaryTests.java b/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextWithGlossaryTests.java index d19b76548c0..7e2702effe2 100644 --- a/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextWithGlossaryTests.java +++ b/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextWithGlossaryTests.java @@ -48,8 +48,6 @@ public class BatchTranslateTextWithGlossaryTests { "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 ByteArrayOutputStream bout; private PrintStream out; @@ -120,8 +118,9 @@ public void tearDown() { @Test public void testBatchTranslateTextWithGlossary() throws InterruptedException, ExecutionException, IOException, TimeoutException { + String outputUri = String.format("gs://%s/%s%s/", PROJECT_ID, PREFIX, UUID.randomUUID()); BatchTranslateTextWithGlossary.batchTranslateTextWithGlossary( - PROJECT_ID, "en", "ja", INPUT_URI, OUTPUT_URI, GLOSSARY_ID); + PROJECT_ID, "en", "ja", INPUT_URI, outputUri, GLOSSARY_ID); String got = bout.toString(); assertThat(got).contains("Total Characters: 9"); } diff --git a/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextWithModelTests.java b/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextWithModelTests.java index c0a5a054f4d..efcd65daf0c 100644 --- a/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextWithModelTests.java +++ b/translate/snippets/src/test/java/com/example/translate/BatchTranslateTextWithModelTests.java @@ -48,8 +48,6 @@ public class BatchTranslateTextWithModelTests { "gs://cloud-samples-data/translation/custom_model_text.txt"; 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 ByteArrayOutputStream bout; private PrintStream out; @@ -116,8 +114,9 @@ public void tearDown() { @Test public void testBatchTranslateTextWithModel() throws InterruptedException, ExecutionException, IOException, TimeoutException { + String outputUri = String.format("gs://%s/%s%s/", PROJECT_ID, PREFIX, UUID.randomUUID()); BatchTranslateTextWithModel.batchTranslateTextWithModel( - PROJECT_ID, "en", "ja", INPUT_URI, OUTPUT_URI, MODEL_ID); + PROJECT_ID, "en", "ja", INPUT_URI, outputUri, MODEL_ID); String got = bout.toString(); assertThat(got).contains("Total Characters: 15"); } diff --git a/translate/snippets/src/test/java/com/example/translatev3beta1/BatchTranslateDocumentTests.java b/translate/snippets/src/test/java/com/example/translatev3beta1/BatchTranslateDocumentTests.java index 588ae493691..8c68aac45db 100644 --- a/translate/snippets/src/test/java/com/example/translatev3beta1/BatchTranslateDocumentTests.java +++ b/translate/snippets/src/test/java/com/example/translatev3beta1/BatchTranslateDocumentTests.java @@ -45,8 +45,6 @@ public class BatchTranslateDocumentTests { private static final String INPUT_URI = "gs://java-docs-samples-testing/translation/invoice2.docx"; private static final String PREFIX = "BATCH_DOC_TRANSLATION_OUTPUT_"; - private static final String OUTPUT_URI = - String.format("gs://%s/%s%s/", PROJECT_ID, PREFIX, UUID.randomUUID()); private ByteArrayOutputStream bout; private PrintStream out; @@ -109,8 +107,9 @@ public void tearDown() { @Test public void testBatchTranslateDocument() throws InterruptedException, ExecutionException, IOException, TimeoutException { + String outputUri = String.format("gs://%s/%s%s/", PROJECT_ID, PREFIX, UUID.randomUUID()); BatchTranslateDocument.batchTranslateDocument( - PROJECT_ID, "en-US", "fr-FR", INPUT_URI, OUTPUT_URI, 1000); + PROJECT_ID, "en-US", "fr-FR", INPUT_URI, outputUri, 1000); String got = bout.toString(); assertThat(got).contains("Total Pages:");