use of com.google.cloud.dialogflow.v2beta1.ContextsClient.ListContextsPagedResponse in project java-dialogflow by googleapis.
the class ContextsClientTest method listContextsTest.
@Test
public void listContextsTest() throws Exception {
Context responsesElement = Context.newBuilder().build();
ListContextsResponse expectedResponse = ListContextsResponse.newBuilder().setNextPageToken("").addAllContexts(Arrays.asList(responsesElement)).build();
mockContexts.addResponse(expectedResponse);
SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]");
ListContextsPagedResponse pagedListResponse = client.listContexts(parent);
List<Context> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getContextsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockContexts.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListContextsRequest actualRequest = ((ListContextsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.v2beta1.ContextsClient.ListContextsPagedResponse in project java-dialogflow by googleapis.
the class ContextsClientTest method listContextsTest.
@Test
public void listContextsTest() throws Exception {
Context responsesElement = Context.newBuilder().build();
ListContextsResponse expectedResponse = ListContextsResponse.newBuilder().setNextPageToken("").addAllContexts(Arrays.asList(responsesElement)).build();
mockContexts.addResponse(expectedResponse);
SessionName parent = SessionName.ofProjectSessionName("[PROJECT]", "[SESSION]");
ListContextsPagedResponse pagedListResponse = client.listContexts(parent);
List<Context> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getContextsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockContexts.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListContextsRequest actualRequest = ((ListContextsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.v2beta1.ContextsClient.ListContextsPagedResponse in project java-dialogflow by googleapis.
the class ContextsClientTest method listContextsTest2.
@Test
public void listContextsTest2() throws Exception {
Context responsesElement = Context.newBuilder().build();
ListContextsResponse expectedResponse = ListContextsResponse.newBuilder().setNextPageToken("").addAllContexts(Arrays.asList(responsesElement)).build();
mockContexts.addResponse(expectedResponse);
String parent = "parent-995424086";
ListContextsPagedResponse pagedListResponse = client.listContexts(parent);
List<Context> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getContextsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockContexts.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListContextsRequest actualRequest = ((ListContextsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.v2beta1.ContextsClient.ListContextsPagedResponse in project java-dialogflow by googleapis.
the class ContextsClientTest method listContextsTest2.
@Test
public void listContextsTest2() throws Exception {
Context responsesElement = Context.newBuilder().build();
ListContextsResponse expectedResponse = ListContextsResponse.newBuilder().setNextPageToken("").addAllContexts(Arrays.asList(responsesElement)).build();
mockContexts.addResponse(expectedResponse);
String parent = "parent-995424086";
ListContextsPagedResponse pagedListResponse = client.listContexts(parent);
List<Context> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getContextsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockContexts.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListContextsRequest actualRequest = ((ListContextsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations