Search in sources :

Example 1 with ListMessagesPagedResponse

use of com.google.cloud.dialogflow.v2.ConversationsClient.ListMessagesPagedResponse in project java-dialogflow by googleapis.

the class ConversationsClientTest method listMessagesTest.

@Test
public void listMessagesTest() throws Exception {
    Message responsesElement = Message.newBuilder().build();
    ListMessagesResponse expectedResponse = ListMessagesResponse.newBuilder().setNextPageToken("").addAllMessages(Arrays.asList(responsesElement)).build();
    mockConversations.addResponse(expectedResponse);
    ConversationName parent = ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
    ListMessagesPagedResponse pagedListResponse = client.listMessages(parent);
    List<Message> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getMessagesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConversations.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListMessagesRequest actualRequest = ((ListMessagesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) AbstractMessage(com.google.protobuf.AbstractMessage) ListMessagesPagedResponse(com.google.cloud.dialogflow.v2beta1.ConversationsClient.ListMessagesPagedResponse) Test(org.junit.Test)

Example 2 with ListMessagesPagedResponse

use of com.google.cloud.dialogflow.v2.ConversationsClient.ListMessagesPagedResponse in project java-dialogflow by googleapis.

the class ConversationsClientTest method listMessagesTest2.

@Test
public void listMessagesTest2() throws Exception {
    Message responsesElement = Message.newBuilder().build();
    ListMessagesResponse expectedResponse = ListMessagesResponse.newBuilder().setNextPageToken("").addAllMessages(Arrays.asList(responsesElement)).build();
    mockConversations.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListMessagesPagedResponse pagedListResponse = client.listMessages(parent);
    List<Message> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getMessagesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConversations.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListMessagesRequest actualRequest = ((ListMessagesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) AbstractMessage(com.google.protobuf.AbstractMessage) ListMessagesPagedResponse(com.google.cloud.dialogflow.v2beta1.ConversationsClient.ListMessagesPagedResponse) Test(org.junit.Test)

Example 3 with ListMessagesPagedResponse

use of com.google.cloud.dialogflow.v2.ConversationsClient.ListMessagesPagedResponse in project java-dialogflow by googleapis.

the class ConversationsClientTest method listMessagesTest.

@Test
public void listMessagesTest() throws Exception {
    Message responsesElement = Message.newBuilder().build();
    ListMessagesResponse expectedResponse = ListMessagesResponse.newBuilder().setNextPageToken("").addAllMessages(Arrays.asList(responsesElement)).build();
    mockConversations.addResponse(expectedResponse);
    ConversationName parent = ConversationName.ofProjectConversationName("[PROJECT]", "[CONVERSATION]");
    ListMessagesPagedResponse pagedListResponse = client.listMessages(parent);
    List<Message> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getMessagesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConversations.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListMessagesRequest actualRequest = ((ListMessagesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) AbstractMessage(com.google.protobuf.AbstractMessage) ListMessagesPagedResponse(com.google.cloud.dialogflow.v2.ConversationsClient.ListMessagesPagedResponse) Test(org.junit.Test)

Example 4 with ListMessagesPagedResponse

use of com.google.cloud.dialogflow.v2.ConversationsClient.ListMessagesPagedResponse in project java-dialogflow by googleapis.

the class ConversationsClientTest method listMessagesTest2.

@Test
public void listMessagesTest2() throws Exception {
    Message responsesElement = Message.newBuilder().build();
    ListMessagesResponse expectedResponse = ListMessagesResponse.newBuilder().setNextPageToken("").addAllMessages(Arrays.asList(responsesElement)).build();
    mockConversations.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListMessagesPagedResponse pagedListResponse = client.listMessages(parent);
    List<Message> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getMessagesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConversations.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListMessagesRequest actualRequest = ((ListMessagesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) AbstractMessage(com.google.protobuf.AbstractMessage) ListMessagesPagedResponse(com.google.cloud.dialogflow.v2.ConversationsClient.ListMessagesPagedResponse) Test(org.junit.Test)

Aggregations

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