diff --git a/google-cloud-jar-parent/pom.xml b/google-cloud-jar-parent/pom.xml
index 20fa3e5ec4a7..e26fb46c8d96 100644
--- a/google-cloud-jar-parent/pom.xml
+++ b/google-cloud-jar-parent/pom.xml
@@ -71,6 +71,12 @@
+
+ org.awaitility
+ awaitility
+ 4.3.0
+ test
+
junit
junit
diff --git a/java-dialogflow/google-cloud-dialogflow/pom.xml b/java-dialogflow/google-cloud-dialogflow/pom.xml
index a1ea3b32b036..0983326ba4df 100644
--- a/java-dialogflow/google-cloud-dialogflow/pom.xml
+++ b/java-dialogflow/google-cloud-dialogflow/pom.xml
@@ -87,6 +87,11 @@
google-cloud-core
test
+
+ org.awaitility
+ awaitility
+ test
+
com.google.api.grpc
diff --git a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/it/ITSystemTest.java b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/it/ITSystemTest.java
index 0f5d52d84320..5a82dd05cf3d 100644
--- a/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/it/ITSystemTest.java
+++ b/java-dialogflow/google-cloud-dialogflow/src/test/java/com/google/cloud/dialogflow/v2/it/ITSystemTest.java
@@ -15,7 +15,10 @@
*/
package com.google.cloud.dialogflow.v2.it;
+import static com.google.common.collect.Streams.stream;
+import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import com.google.cloud.ServiceOptions;
import com.google.cloud.dialogflow.v2.Agent;
@@ -54,10 +57,11 @@
import com.google.protobuf.Struct;
import com.google.protobuf.Value;
import java.io.IOException;
+import java.time.Duration;
import java.util.UUID;
+import java.util.concurrent.atomic.AtomicReference;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
public class ITSystemTest {
@@ -259,7 +263,6 @@ public void getIntentTest() {
}
@Test
- @Ignore("b/423958346")
public void detectIntentTest() {
QueryInput queryInput =
QueryInput.newBuilder()
@@ -279,8 +282,17 @@ public void detectIntentTest() {
.setSession(SESSION_NAME.toString())
.setQueryInput(queryInput)
.build();
- DetectIntentResponse response = sessionsClient.detectIntent(request);
- QueryResult result = response.getQueryResult();
+ AtomicReference responseRef = new AtomicReference<>();
+ await()
+ .atMost(Duration.ofSeconds(30))
+ .pollInterval(Duration.ofSeconds(2))
+ .until(
+ () -> {
+ DetectIntentResponse response = sessionsClient.detectIntent(request);
+ responseRef.set(response);
+ return !response.getQueryResult().getQueryText().isEmpty();
+ });
+ QueryResult result = responseRef.get().getQueryResult();
assertEquals(EVENT_NAME, result.getQueryText());
assertEquals(ACTION_NAME, result.getAction());
assertEquals(DEFAULT_LANGUAGE_CODE, result.getLanguageCode());
@@ -288,13 +300,13 @@ public void detectIntentTest() {
}
@Test
- @Ignore("b/423958346")
public void listContextsTest() {
ListContextsRequest request =
ListContextsRequest.newBuilder().setParent(SESSION_NAME.toString()).build();
- for (Context actualContext : contextsClient.listContexts(request).iterateAll()) {
- assertEquals(context.getName(), actualContext.getName());
- }
+ boolean contextNameInActualContext =
+ stream(contextsClient.listContexts(request).iterateAll())
+ .anyMatch(actualContext -> context.getName().equals(actualContext.getName()));
+ assertTrue(contextNameInActualContext);
}
@Test