Search in sources :

Example 1 with ListExperimentsPagedResponse

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

the class ExperimentsClientTest method listExperimentsTest.

@Test
public void listExperimentsTest() throws Exception {
    Experiment responsesElement = Experiment.newBuilder().build();
    ListExperimentsResponse expectedResponse = ListExperimentsResponse.newBuilder().setNextPageToken("").addAllExperiments(Arrays.asList(responsesElement)).build();
    mockExperiments.addResponse(expectedResponse);
    EnvironmentName parent = EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]");
    ListExperimentsPagedResponse pagedListResponse = client.listExperiments(parent);
    List<Experiment> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getExperimentsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockExperiments.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListExperimentsRequest actualRequest = ((ListExperimentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListExperimentsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.ExperimentsClient.ListExperimentsPagedResponse) Test(org.junit.Test)

Example 2 with ListExperimentsPagedResponse

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

the class ExperimentsClientTest method listExperimentsTest2.

@Test
public void listExperimentsTest2() throws Exception {
    Experiment responsesElement = Experiment.newBuilder().build();
    ListExperimentsResponse expectedResponse = ListExperimentsResponse.newBuilder().setNextPageToken("").addAllExperiments(Arrays.asList(responsesElement)).build();
    mockExperiments.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListExperimentsPagedResponse pagedListResponse = client.listExperiments(parent);
    List<Experiment> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getExperimentsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockExperiments.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListExperimentsRequest actualRequest = ((ListExperimentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListExperimentsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.ExperimentsClient.ListExperimentsPagedResponse) Test(org.junit.Test)

Example 3 with ListExperimentsPagedResponse

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

the class ExperimentsClientTest method listExperimentsTest2.

@Test
public void listExperimentsTest2() throws Exception {
    Experiment responsesElement = Experiment.newBuilder().build();
    ListExperimentsResponse expectedResponse = ListExperimentsResponse.newBuilder().setNextPageToken("").addAllExperiments(Arrays.asList(responsesElement)).build();
    mockExperiments.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListExperimentsPagedResponse pagedListResponse = client.listExperiments(parent);
    List<Experiment> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getExperimentsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockExperiments.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListExperimentsRequest actualRequest = ((ListExperimentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListExperimentsPagedResponse(com.google.cloud.dialogflow.cx.v3.ExperimentsClient.ListExperimentsPagedResponse) Test(org.junit.Test)

Example 4 with ListExperimentsPagedResponse

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

the class ExperimentsClientTest method listExperimentsTest.

@Test
public void listExperimentsTest() throws Exception {
    Experiment responsesElement = Experiment.newBuilder().build();
    ListExperimentsResponse expectedResponse = ListExperimentsResponse.newBuilder().setNextPageToken("").addAllExperiments(Arrays.asList(responsesElement)).build();
    mockExperiments.addResponse(expectedResponse);
    EnvironmentName parent = EnvironmentName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]");
    ListExperimentsPagedResponse pagedListResponse = client.listExperiments(parent);
    List<Experiment> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getExperimentsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockExperiments.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListExperimentsRequest actualRequest = ((ListExperimentsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListExperimentsPagedResponse(com.google.cloud.dialogflow.cx.v3.ExperimentsClient.ListExperimentsPagedResponse) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 ListExperimentsPagedResponse (com.google.cloud.dialogflow.cx.v3.ExperimentsClient.ListExperimentsPagedResponse)2 ListExperimentsPagedResponse (com.google.cloud.dialogflow.cx.v3beta1.ExperimentsClient.ListExperimentsPagedResponse)2