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()));
}
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()));
}
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()));
}
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()));
}
Aggregations