Skip to content

Commit ae30e45

Browse files
b-loved-dreamerShabirmean
authored andcommitted
samples: updated legacy field (#493)
1 parent b66ded7 commit ae30e45

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentStream.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ static void detectIntentStream(String projectId, String audioFilePath, String se
9696
System.out.format(
9797
"Detected Intent: %s (confidence: %f)\n",
9898
queryResult.getIntent().getDisplayName(), queryResult.getIntentDetectionConfidence());
99-
System.out.format("Fulfillment Text: '%s'\n", queryResult.getFulfillmentText());
99+
System.out.format(
100+
"Fulfillment Text: '%s'\n",
101+
queryResult.getFulfillmentMessagesCount() > 0
102+
? queryResult.getFulfillmentMessages(0).getText()
103+
: "Triggered Default Fallback Intent");
100104
}
101105
}
102106
}

dialogflow/snippets/src/main/java/com/example/dialogflow/DetectIntentWithLocation.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,22 @@ public class DetectIntentWithLocation {
3535

3636
// DialogFlow API Detect Intent sample with text inputs.
3737
public static Map<String, QueryResult> detectIntentWithLocation(
38-
String projectId, String locationId, List<String> texts, String sessionId,
38+
String projectId,
39+
String locationId,
40+
List<String> texts,
41+
String sessionId,
3942
String languageCode)
4043
throws IOException, ApiException {
41-
SessionsSettings sessionsSettings = SessionsSettings.newBuilder()
42-
.setEndpoint(locationId + "-dialogflow.googleapis.com:443").build();
44+
SessionsSettings sessionsSettings =
45+
SessionsSettings.newBuilder()
46+
.setEndpoint(locationId + "-dialogflow.googleapis.com:443")
47+
.build();
4348
Map<String, QueryResult> queryResults = Maps.newHashMap();
4449
// Instantiates a client
4550
try (SessionsClient sessionsClient = SessionsClient.create(sessionsSettings)) {
4651
// Set the session name using the projectId (my-project-id), locationId and sessionId (UUID)
47-
SessionName session = SessionName
48-
.ofProjectLocationSessionName(projectId, locationId, sessionId);
52+
SessionName session =
53+
SessionName.ofProjectLocationSessionName(projectId, locationId, sessionId);
4954
System.out.println("Session Path: " + session.toString());
5055

5156
// Detect intents for each text input

dialogflow/snippets/src/test/java/com/example/dialogflow/CreateDocumentTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ public void tearDown() throws IOException {
8686
System.setOut(null);
8787
}
8888

89-
@Rule
90-
public MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);
89+
@Rule public MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3);
9190

9291
@Test
9392
public void testCreateDocument() throws Exception {

dialogflow/snippets/src/test/java/com/example/dialogflow/DetectIntentWithSentimentAndTextToSpeechIT.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
import org.junit.runner.RunWith;
3333
import org.junit.runners.JUnit4;
3434

35-
/**
36-
* Integration (system) tests for {@link DetectIntentWithSentimentAnalysis}.
37-
*/
35+
/** Integration (system) tests for {@link DetectIntentWithSentimentAnalysis}. */
3836
@RunWith(JUnit4.class)
3937
@SuppressWarnings("checkstyle:abbreviationaswordinname")
4038
public class DetectIntentWithSentimentAndTextToSpeechIT {
@@ -78,8 +76,8 @@ public void testDetectIntentTexts() throws Exception {
7876
@Test
7977
public void testDetectIntentTextsWithLocation() throws Exception {
8078
Map<String, com.google.cloud.dialogflow.v2beta1.QueryResult> queryResults =
81-
DetectIntentWithLocation
82-
.detectIntentWithLocation(PROJECT_ID, LOCATION_ID, TEXTS, SESSION_ID, LANGUAGE_CODE);
79+
DetectIntentWithLocation.detectIntentWithLocation(
80+
PROJECT_ID, LOCATION_ID, TEXTS, SESSION_ID, LANGUAGE_CODE);
8381
com.google.cloud.dialogflow.v2beta1.QueryResult finalResult =
8482
queryResults.get(TEXTS.get(TEXTS.size() - 1));
8583
assertTrue(finalResult.getAllRequiredParamsPresent());

0 commit comments

Comments
 (0)