use of com.google.cloud.dialogflow.v2.DocumentsClient.ListDocumentsPagedResponse in project java-dialogflow by googleapis.
the class DocumentsClientTest method listDocumentsTest2.
@Test
public void listDocumentsTest2() throws Exception {
Document responsesElement = Document.newBuilder().build();
ListDocumentsResponse expectedResponse = ListDocumentsResponse.newBuilder().setNextPageToken("").addAllDocuments(Arrays.asList(responsesElement)).build();
mockDocuments.addResponse(expectedResponse);
String parent = "parent-995424086";
ListDocumentsPagedResponse pagedListResponse = client.listDocuments(parent);
List<Document> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getDocumentsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDocuments.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListDocumentsRequest actualRequest = ((ListDocumentsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.v2.DocumentsClient.ListDocumentsPagedResponse in project java-dialogflow by googleapis.
the class DocumentsClientTest method listDocumentsTest.
@Test
public void listDocumentsTest() throws Exception {
Document responsesElement = Document.newBuilder().build();
ListDocumentsResponse expectedResponse = ListDocumentsResponse.newBuilder().setNextPageToken("").addAllDocuments(Arrays.asList(responsesElement)).build();
mockDocuments.addResponse(expectedResponse);
KnowledgeBaseName parent = KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]");
ListDocumentsPagedResponse pagedListResponse = client.listDocuments(parent);
List<Document> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getDocumentsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDocuments.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListDocumentsRequest actualRequest = ((ListDocumentsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.v2.DocumentsClient.ListDocumentsPagedResponse in project java-dialogflow by googleapis.
the class DocumentsClientTest method listDocumentsTest2.
@Test
public void listDocumentsTest2() throws Exception {
Document responsesElement = Document.newBuilder().build();
ListDocumentsResponse expectedResponse = ListDocumentsResponse.newBuilder().setNextPageToken("").addAllDocuments(Arrays.asList(responsesElement)).build();
mockDocuments.addResponse(expectedResponse);
String parent = "parent-995424086";
ListDocumentsPagedResponse pagedListResponse = client.listDocuments(parent);
List<Document> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getDocumentsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDocuments.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListDocumentsRequest actualRequest = ((ListDocumentsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dialogflow.v2.DocumentsClient.ListDocumentsPagedResponse in project java-dialogflow by googleapis.
the class DocumentsClientTest method listDocumentsTest.
@Test
public void listDocumentsTest() throws Exception {
Document responsesElement = Document.newBuilder().build();
ListDocumentsResponse expectedResponse = ListDocumentsResponse.newBuilder().setNextPageToken("").addAllDocuments(Arrays.asList(responsesElement)).build();
mockDocuments.addResponse(expectedResponse);
KnowledgeBaseName parent = KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]");
ListDocumentsPagedResponse pagedListResponse = client.listDocuments(parent);
List<Document> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getDocumentsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDocuments.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListDocumentsRequest actualRequest = ((ListDocumentsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations