diff --git a/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentStream.java b/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentStream.java index ffeffcd4dce..27febe126a7 100644 --- a/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentStream.java +++ b/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentStream.java @@ -96,7 +96,11 @@ static void detectIntentStream(String projectId, String audioFilePath, String se System.out.format( "Detected Intent: %s (confidence: %f)\n", queryResult.getIntent().getDisplayName(), queryResult.getIntentDetectionConfidence()); - System.out.format("Fulfillment Text: '%s'\n", queryResult.getFulfillmentText()); + System.out.format( + "Fulfillment Text: '%s'\n", + queryResult.getFulfillmentMessagesCount() > 0 + ? queryResult.getFulfillmentMessages(0).getText() + : "Triggered Default Fallback Intent"); } } } diff --git a/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithLocation.java b/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithLocation.java index 5ef3237b6dd..9c6e943dcd4 100644 --- a/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithLocation.java +++ b/dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithLocation.java @@ -35,17 +35,22 @@ public class DetectIntentWithLocation { // DialogFlow API Detect Intent sample with text inputs. public static Map detectIntentWithLocation( - String projectId, String locationId, List texts, String sessionId, + String projectId, + String locationId, + List texts, + String sessionId, String languageCode) throws IOException, ApiException { - SessionsSettings sessionsSettings = SessionsSettings.newBuilder() - .setEndpoint(locationId + "-dialogflow.googleapis.com:443").build(); + SessionsSettings sessionsSettings = + SessionsSettings.newBuilder() + .setEndpoint(locationId + "-dialogflow.googleapis.com:443") + .build(); Map queryResults = Maps.newHashMap(); // Instantiates a client try (SessionsClient sessionsClient = SessionsClient.create(sessionsSettings)) { // Set the session name using the projectId (my-project-id), locationId and sessionId (UUID) - SessionName session = SessionName - .ofProjectLocationSessionName(projectId, locationId, sessionId); + SessionName session = + SessionName.ofProjectLocationSessionName(projectId, locationId, sessionId); System.out.println("Session Path: " + session.toString()); // Detect intents for each text input diff --git a/dialogflow/snippets/src/test/java/com/example/dialogflow/CreateDocumentTest.java b/dialogflow/snippets/src/test/java/com/example/dialogflow/CreateDocumentTest.java index dc9c0d4ef89..41c8d17e8b5 100644 --- a/dialogflow/snippets/src/test/java/com/example/dialogflow/CreateDocumentTest.java +++ b/dialogflow/snippets/src/test/java/com/example/dialogflow/CreateDocumentTest.java @@ -86,8 +86,7 @@ public void tearDown() throws IOException { System.setOut(null); } - @Rule - public MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3); + @Rule public MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3); @Test public void testCreateDocument() throws Exception { diff --git a/dialogflow/snippets/src/test/java/com/example/dialogflow/DetectIntentWithSentimentAndTextToSpeechIT.java b/dialogflow/snippets/src/test/java/com/example/dialogflow/DetectIntentWithSentimentAndTextToSpeechIT.java index c0584150efc..64962cc77de 100644 --- a/dialogflow/snippets/src/test/java/com/example/dialogflow/DetectIntentWithSentimentAndTextToSpeechIT.java +++ b/dialogflow/snippets/src/test/java/com/example/dialogflow/DetectIntentWithSentimentAndTextToSpeechIT.java @@ -32,9 +32,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** - * Integration (system) tests for {@link DetectIntentWithSentimentAnalysis}. - */ +/** Integration (system) tests for {@link DetectIntentWithSentimentAnalysis}. */ @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") public class DetectIntentWithSentimentAndTextToSpeechIT { @@ -78,8 +76,8 @@ public void testDetectIntentTexts() throws Exception { @Test public void testDetectIntentTextsWithLocation() throws Exception { Map queryResults = - DetectIntentWithLocation - .detectIntentWithLocation(PROJECT_ID, LOCATION_ID, TEXTS, SESSION_ID, LANGUAGE_CODE); + DetectIntentWithLocation.detectIntentWithLocation( + PROJECT_ID, LOCATION_ID, TEXTS, SESSION_ID, LANGUAGE_CODE); com.google.cloud.dialogflow.v2beta1.QueryResult finalResult = queryResults.get(TEXTS.get(TEXTS.size() - 1)); assertTrue(finalResult.getAllRequiredParamsPresent());