Search in sources :

Example 1 with ListAgentsRequest

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

the class AgentsClientTest method listAgentsTest.

@Test
public void listAgentsTest() throws Exception {
    Agent responsesElement = Agent.newBuilder().build();
    ListAgentsResponse expectedResponse = ListAgentsResponse.newBuilder().setNextPageToken("").addAllAgents(Arrays.asList(responsesElement)).build();
    mockAgents.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListAgentsPagedResponse pagedListResponse = client.listAgents(parent);
    List<Agent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getAgentsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockAgents.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListAgentsRequest actualRequest = ((ListAgentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListAgentsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.AgentsClient.ListAgentsPagedResponse) Test(org.junit.Test)

Example 2 with ListAgentsRequest

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

the class AgentsClientTest method listAgentsTest2.

@Test
public void listAgentsTest2() throws Exception {
    Agent responsesElement = Agent.newBuilder().build();
    ListAgentsResponse expectedResponse = ListAgentsResponse.newBuilder().setNextPageToken("").addAllAgents(Arrays.asList(responsesElement)).build();
    mockAgents.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListAgentsPagedResponse pagedListResponse = client.listAgents(parent);
    List<Agent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getAgentsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockAgents.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListAgentsRequest actualRequest = ((ListAgentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListAgentsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.AgentsClient.ListAgentsPagedResponse) Test(org.junit.Test)

Example 3 with ListAgentsRequest

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

the class ITSystemTest method listAgentsTest.

@Test
public void listAgentsTest() {
    ListAgentsRequest request = ListAgentsRequest.newBuilder().setParent(PARENT.toString()).build();
    Iterable<Agent> agents = agentsClient.listAgents(request).iterateAll();
    boolean isAgentExists = false;
    for (Agent agent : agents) {
        if (agentName.equals(agent.getName())) {
            assertAgentDetails(agent);
            isAgentExists = true;
        }
    }
    assertTrue(isAgentExists);
}
Also used : Agent(com.google.cloud.dialogflow.cx.v3beta1.Agent) ListAgentsRequest(com.google.cloud.dialogflow.cx.v3beta1.ListAgentsRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 ListAgentsPagedResponse (com.google.cloud.dialogflow.cx.v3beta1.AgentsClient.ListAgentsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Agent (com.google.cloud.dialogflow.cx.v3beta1.Agent)1 ListAgentsRequest (com.google.cloud.dialogflow.cx.v3beta1.ListAgentsRequest)1