Search in sources :

Example 1 with ListContextsPagedResponse

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListContextsPagedResponse(com.google.cloud.dialogflow.v2.ContextsClient.ListContextsPagedResponse) Test(org.junit.Test)

Example 2 with ListContextsPagedResponse

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListContextsPagedResponse(com.google.cloud.dialogflow.v2beta1.ContextsClient.ListContextsPagedResponse) Test(org.junit.Test)

Example 3 with ListContextsPagedResponse

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListContextsPagedResponse(com.google.cloud.dialogflow.v2.ContextsClient.ListContextsPagedResponse) Test(org.junit.Test)

Example 4 with ListContextsPagedResponse

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListContextsPagedResponse(com.google.cloud.dialogflow.v2beta1.ContextsClient.ListContextsPagedResponse) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 ListContextsPagedResponse (com.google.cloud.dialogflow.v2.ContextsClient.ListContextsPagedResponse)2 ListContextsPagedResponse (com.google.cloud.dialogflow.v2beta1.ContextsClient.ListContextsPagedResponse)2