From c1c3c8397a2804d1039d9527ecf72f6bc64a7274 Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Tue, 29 Nov 2016 22:20:48 -0600 Subject: [PATCH] samples: Translate API no longer requires an API key. (#425) --- .../main/java/com/example/translate/QuickstartSample.java | 6 +----- .../test/java/com/example/translate/QuickstartSampleIT.java | 5 +---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/translate/snippets/src/main/java/com/example/translate/QuickstartSample.java b/translate/snippets/src/main/java/com/example/translate/QuickstartSample.java index 75523d0dcaf..8339650d077 100644 --- a/translate/snippets/src/main/java/com/example/translate/QuickstartSample.java +++ b/translate/snippets/src/main/java/com/example/translate/QuickstartSample.java @@ -26,11 +26,7 @@ public class QuickstartSample { public static void main(String... args) throws Exception { // Instantiates a client - Translate translate = - TranslateOptions.builder() - .apiKey(args[0]) // .apiKey("YOUR_API_KEY") - .build() - .service(); + Translate translate = TranslateOptions.getDefaultInstance().getService(); // The text to translate String text = "Hello, world!"; diff --git a/translate/snippets/src/test/java/com/example/translate/QuickstartSampleIT.java b/translate/snippets/src/test/java/com/example/translate/QuickstartSampleIT.java index c91651b2a74..e27b59cba97 100644 --- a/translate/snippets/src/test/java/com/example/translate/QuickstartSampleIT.java +++ b/translate/snippets/src/test/java/com/example/translate/QuickstartSampleIT.java @@ -50,11 +50,8 @@ public void tearDown() { @Test public void testQuickstart() throws Exception { - // Arrange - String apiKey = System.getenv("GOOGLE_API_KEY"); - // Act - QuickstartSample.main(apiKey); + QuickstartSample.main(); // Assert String got = bout.toString();