Search in sources :

Example 1 with ListDocumentsPagedResponse

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

Example 2 with ListDocumentsPagedResponse

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

Example 3 with ListDocumentsPagedResponse

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

Example 4 with ListDocumentsPagedResponse

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

Aggregations

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