Search in sources :

Example 1 with ListVersionsRequest

use of com.google.cloud.dialogflow.cx.v3beta1.ListVersionsRequest in project java-dialogflow-cx by googleapis.

the class ITSystemTest method listVersionsTest.

@Test
public void listVersionsTest() {
    ListVersionsRequest versionsRequest = ListVersionsRequest.newBuilder().setParent(flowName).build();
    VersionsClient.ListVersionsPagedResponse pagedListResponse = versionsClient.listVersions(versionsRequest);
    List<Version> versions = Lists.newArrayList(pagedListResponse.iterateAll());
    boolean isVersionNameExists = false;
    for (Version version : versions) {
        if (version.getName().equals(versionName)) {
            assertVersionDetails(version);
            isVersionNameExists = true;
        }
    }
    assertTrue(isVersionNameExists);
}
Also used : Version(com.google.cloud.dialogflow.cx.v3beta1.Version) VersionsClient(com.google.cloud.dialogflow.cx.v3beta1.VersionsClient) ListVersionsRequest(com.google.cloud.dialogflow.cx.v3beta1.ListVersionsRequest) Test(org.junit.Test)

Example 2 with ListVersionsRequest

use of com.google.cloud.dialogflow.cx.v3beta1.ListVersionsRequest 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 3 with ListVersionsRequest

use of com.google.cloud.dialogflow.cx.v3beta1.ListVersionsRequest 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

Test (org.junit.Test)3 ListVersionsPagedResponse (com.google.cloud.dialogflow.cx.v3beta1.VersionsClient.ListVersionsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 ListVersionsRequest (com.google.cloud.dialogflow.cx.v3beta1.ListVersionsRequest)1 Version (com.google.cloud.dialogflow.cx.v3beta1.Version)1 VersionsClient (com.google.cloud.dialogflow.cx.v3beta1.VersionsClient)1