Search in sources :

Example 1 with ListIntentsRequest

use of com.google.cloud.dialogflow.cx.v3beta1.ListIntentsRequest in project java-dialogflow-cx by googleapis.

the class ITSystemTest method listIntentsTest.

@Test
public void listIntentsTest() {
    ListIntentsRequest request = ListIntentsRequest.newBuilder().setParent(agentName).build();
    IntentsClient.ListIntentsPagedResponse pagedListResponse = intentsClient.listIntents(request);
    List<Intent> intents = Lists.newArrayList(pagedListResponse.iterateAll());
    boolean isIntentExists = false;
    for (Intent intent : intents) {
        if (intent.getName().equals(intentsName)) {
            assertIntentDetails(intent);
            isIntentExists = true;
        }
    }
    assertTrue(isIntentExists);
}
Also used : IntentsClient(com.google.cloud.dialogflow.cx.v3beta1.IntentsClient) ListIntentsRequest(com.google.cloud.dialogflow.cx.v3beta1.ListIntentsRequest) Intent(com.google.cloud.dialogflow.cx.v3beta1.Intent) Test(org.junit.Test)

Example 2 with ListIntentsRequest

use of com.google.cloud.dialogflow.cx.v3beta1.ListIntentsRequest in project java-dialogflow by googleapis.

the class ITSystemTest method listIntentsTest.

@Test
public void listIntentsTest() {
    ListIntentsRequest request = ListIntentsRequest.newBuilder().setParent(PROJECT_AGENT_NAME.toString()).build();
    for (Intent actualIntent : intentsClient.listIntents(request).iterateAll()) {
        if (intent.getName().equals(actualIntent.getName())) {
            assertEquals(intent.getDisplayName(), actualIntent.getDisplayName());
            assertEquals(intent.getAction(), actualIntent.getAction());
            assertEquals(intent.getEvents(0), actualIntent.getEvents(0));
            assertEquals(intent.getEventsCount(), actualIntent.getEventsCount());
        }
    }
}
Also used : ListIntentsRequest(com.google.cloud.dialogflow.v2.ListIntentsRequest) Intent(com.google.cloud.dialogflow.v2.Intent) Test(org.junit.Test)

Example 3 with ListIntentsRequest

use of com.google.cloud.dialogflow.cx.v3beta1.ListIntentsRequest in project java-dialogflow-cx by googleapis.

the class IntentsClientTest method listIntentsTest.

@Test
public void listIntentsTest() throws Exception {
    Intent responsesElement = Intent.newBuilder().build();
    ListIntentsResponse expectedResponse = ListIntentsResponse.newBuilder().setNextPageToken("").addAllIntents(Arrays.asList(responsesElement)).build();
    mockIntents.addResponse(expectedResponse);
    AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
    ListIntentsPagedResponse pagedListResponse = client.listIntents(parent);
    List<Intent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIntentsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockIntents.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIntentsRequest actualRequest = ((ListIntentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListIntentsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.IntentsClient.ListIntentsPagedResponse) Test(org.junit.Test)

Example 4 with ListIntentsRequest

use of com.google.cloud.dialogflow.cx.v3beta1.ListIntentsRequest in project java-dialogflow-cx by googleapis.

the class IntentsClientTest method listIntentsTest2.

@Test
public void listIntentsTest2() throws Exception {
    Intent responsesElement = Intent.newBuilder().build();
    ListIntentsResponse expectedResponse = ListIntentsResponse.newBuilder().setNextPageToken("").addAllIntents(Arrays.asList(responsesElement)).build();
    mockIntents.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListIntentsPagedResponse pagedListResponse = client.listIntents(parent);
    List<Intent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIntentsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockIntents.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIntentsRequest actualRequest = ((ListIntentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListIntentsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.IntentsClient.ListIntentsPagedResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 ListIntentsPagedResponse (com.google.cloud.dialogflow.cx.v3beta1.IntentsClient.ListIntentsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Intent (com.google.cloud.dialogflow.cx.v3beta1.Intent)1 IntentsClient (com.google.cloud.dialogflow.cx.v3beta1.IntentsClient)1 ListIntentsRequest (com.google.cloud.dialogflow.cx.v3beta1.ListIntentsRequest)1 Intent (com.google.cloud.dialogflow.v2.Intent)1 ListIntentsRequest (com.google.cloud.dialogflow.v2.ListIntentsRequest)1