Search in sources :

Example 6 with ListVersionsPagedResponse

use of com.google.cloud.dialogflow.v2.VersionsClient.ListVersionsPagedResponse in project java-dialogflow by googleapis.

the class VersionsClientTest method listVersionsTest.

@Test
public void listVersionsTest() throws Exception {
    Version responsesElement = Version.newBuilder().build();
    ListVersionsResponse expectedResponse = ListVersionsResponse.newBuilder().setNextPageToken("").addAllVersions(Arrays.asList(responsesElement)).build();
    mockVersions.addResponse(expectedResponse);
    AgentName parent = AgentName.ofProjectName("[PROJECT]");
    ListVersionsPagedResponse pagedListResponse = client.listVersions(parent);
    List<Version> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getVersionsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockVersions.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListVersionsRequest actualRequest = ((ListVersionsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListVersionsPagedResponse(com.google.cloud.dialogflow.v2.VersionsClient.ListVersionsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 7 with ListVersionsPagedResponse

use of com.google.cloud.dialogflow.v2.VersionsClient.ListVersionsPagedResponse in project java-dialogflow-cx by googleapis.

the class VersionsClientTest method listVersionsTest2.

@Test
public void listVersionsTest2() throws Exception {
    Version responsesElement = Version.newBuilder().build();
    ListVersionsResponse expectedResponse = ListVersionsResponse.newBuilder().setNextPageToken("").addAllVersions(Arrays.asList(responsesElement)).build();
    mockVersions.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListVersionsPagedResponse pagedListResponse = client.listVersions(parent);
    List<Version> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getVersionsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockVersions.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListVersionsRequest actualRequest = ((ListVersionsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListVersionsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.VersionsClient.ListVersionsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 8 with ListVersionsPagedResponse

use of com.google.cloud.dialogflow.v2.VersionsClient.ListVersionsPagedResponse in project java-dialogflow-cx by googleapis.

the class VersionsClientTest method listVersionsTest.

@Test
public void listVersionsTest() throws Exception {
    Version responsesElement = Version.newBuilder().build();
    ListVersionsResponse expectedResponse = ListVersionsResponse.newBuilder().setNextPageToken("").addAllVersions(Arrays.asList(responsesElement)).build();
    mockVersions.addResponse(expectedResponse);
    FlowName parent = FlowName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]");
    ListVersionsPagedResponse pagedListResponse = client.listVersions(parent);
    List<Version> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getVersionsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockVersions.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListVersionsRequest actualRequest = ((ListVersionsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListVersionsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.VersionsClient.ListVersionsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)8 Test (org.junit.Test)8 ListVersionsPagedResponse (com.google.cloud.dialogflow.cx.v3.VersionsClient.ListVersionsPagedResponse)2 ListVersionsPagedResponse (com.google.cloud.dialogflow.cx.v3beta1.VersionsClient.ListVersionsPagedResponse)2 ListVersionsPagedResponse (com.google.cloud.dialogflow.v2.VersionsClient.ListVersionsPagedResponse)2 ListVersionsPagedResponse (com.google.cloud.dialogflow.v2beta1.VersionsClient.ListVersionsPagedResponse)2