use of com.google.cloud.dialogflow.cx.v3.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()));
}
use of com.google.cloud.dialogflow.cx.v3.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()));
}
use of com.google.cloud.dialogflow.cx.v3.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()));
}
use of com.google.cloud.dialogflow.cx.v3.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()));
}
Aggregations