Search in sources :

Example 1 with ListKnowledgeBasesPagedResponse

use of com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse in project java-dialogflow by googleapis.

the class KnowledgeBasesClientTest method listKnowledgeBasesTest2.

@Test
public void listKnowledgeBasesTest2() throws Exception {
    KnowledgeBase responsesElement = KnowledgeBase.newBuilder().build();
    ListKnowledgeBasesResponse expectedResponse = ListKnowledgeBasesResponse.newBuilder().setNextPageToken("").addAllKnowledgeBases(Arrays.asList(responsesElement)).build();
    mockKnowledgeBases.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListKnowledgeBasesPagedResponse pagedListResponse = client.listKnowledgeBases(parent);
    List<KnowledgeBase> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getKnowledgeBasesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockKnowledgeBases.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListKnowledgeBasesRequest actualRequest = ((ListKnowledgeBasesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListKnowledgeBasesPagedResponse(com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse) Test(org.junit.Test)

Example 2 with ListKnowledgeBasesPagedResponse

use of com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse in project java-dialogflow by googleapis.

the class KnowledgeBasesClientTest method listKnowledgeBasesTest3.

@Test
public void listKnowledgeBasesTest3() throws Exception {
    KnowledgeBase responsesElement = KnowledgeBase.newBuilder().build();
    ListKnowledgeBasesResponse expectedResponse = ListKnowledgeBasesResponse.newBuilder().setNextPageToken("").addAllKnowledgeBases(Arrays.asList(responsesElement)).build();
    mockKnowledgeBases.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListKnowledgeBasesPagedResponse pagedListResponse = client.listKnowledgeBases(parent);
    List<KnowledgeBase> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getKnowledgeBasesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockKnowledgeBases.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListKnowledgeBasesRequest actualRequest = ((ListKnowledgeBasesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListKnowledgeBasesPagedResponse(com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse) Test(org.junit.Test)

Example 3 with ListKnowledgeBasesPagedResponse

use of com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse in project java-dialogflow by googleapis.

the class KnowledgeBasesClientTest method listKnowledgeBasesTest.

@Test
public void listKnowledgeBasesTest() throws Exception {
    KnowledgeBase responsesElement = KnowledgeBase.newBuilder().build();
    ListKnowledgeBasesResponse expectedResponse = ListKnowledgeBasesResponse.newBuilder().setNextPageToken("").addAllKnowledgeBases(Arrays.asList(responsesElement)).build();
    mockKnowledgeBases.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListKnowledgeBasesPagedResponse pagedListResponse = client.listKnowledgeBases(parent);
    List<KnowledgeBase> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getKnowledgeBasesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockKnowledgeBases.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListKnowledgeBasesRequest actualRequest = ((ListKnowledgeBasesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListKnowledgeBasesPagedResponse(com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse) Test(org.junit.Test)

Example 4 with ListKnowledgeBasesPagedResponse

use of com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse in project java-dialogflow by googleapis.

the class KnowledgeBasesClientTest method listKnowledgeBasesTest3.

@Test
public void listKnowledgeBasesTest3() throws Exception {
    KnowledgeBase responsesElement = KnowledgeBase.newBuilder().build();
    ListKnowledgeBasesResponse expectedResponse = ListKnowledgeBasesResponse.newBuilder().setNextPageToken("").addAllKnowledgeBases(Arrays.asList(responsesElement)).build();
    mockKnowledgeBases.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListKnowledgeBasesPagedResponse pagedListResponse = client.listKnowledgeBases(parent);
    List<KnowledgeBase> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getKnowledgeBasesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockKnowledgeBases.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListKnowledgeBasesRequest actualRequest = ((ListKnowledgeBasesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListKnowledgeBasesPagedResponse(com.google.cloud.dialogflow.v2.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse) Test(org.junit.Test)

Example 5 with ListKnowledgeBasesPagedResponse

use of com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse in project java-dialogflow by googleapis.

the class KnowledgeBasesClientTest method listKnowledgeBasesTest.

@Test
public void listKnowledgeBasesTest() throws Exception {
    KnowledgeBase responsesElement = KnowledgeBase.newBuilder().build();
    ListKnowledgeBasesResponse expectedResponse = ListKnowledgeBasesResponse.newBuilder().setNextPageToken("").addAllKnowledgeBases(Arrays.asList(responsesElement)).build();
    mockKnowledgeBases.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListKnowledgeBasesPagedResponse pagedListResponse = client.listKnowledgeBases(parent);
    List<KnowledgeBase> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getKnowledgeBasesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockKnowledgeBases.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListKnowledgeBasesRequest actualRequest = ((ListKnowledgeBasesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListKnowledgeBasesPagedResponse(com.google.cloud.dialogflow.v2.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)6 Test (org.junit.Test)6 ListKnowledgeBasesPagedResponse (com.google.cloud.dialogflow.v2.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse)3 ListKnowledgeBasesPagedResponse (com.google.cloud.dialogflow.v2beta1.KnowledgeBasesClient.ListKnowledgeBasesPagedResponse)3