Search in sources :

Example 1 with ListAgentsPagedResponse

use of com.google.cloud.dialogflow.cx.v3beta1.AgentsClient.ListAgentsPagedResponse 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 ListAgentsPagedResponse

use of com.google.cloud.dialogflow.cx.v3beta1.AgentsClient.ListAgentsPagedResponse 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 ListAgentsPagedResponse

use of com.google.cloud.dialogflow.cx.v3beta1.AgentsClient.ListAgentsPagedResponse 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.v3.AgentsClient.ListAgentsPagedResponse) Test(org.junit.Test)

Example 4 with ListAgentsPagedResponse

use of com.google.cloud.dialogflow.cx.v3beta1.AgentsClient.ListAgentsPagedResponse 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.v3.AgentsClient.ListAgentsPagedResponse) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 ListAgentsPagedResponse (com.google.cloud.dialogflow.cx.v3.AgentsClient.ListAgentsPagedResponse)2 ListAgentsPagedResponse (com.google.cloud.dialogflow.cx.v3beta1.AgentsClient.ListAgentsPagedResponse)2