Search in sources :

Example 1 with ListFlowsRequest

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

the class ITSystemTest method listFlowsTest.

@Test
public void listFlowsTest() {
    ListFlowsRequest request = ListFlowsRequest.newBuilder().setParent(agentName).build();
    FlowsClient.ListFlowsPagedResponse pagedListResponse = flowsClient.listFlows(request);
    List<Flow> flows = Lists.newArrayList(pagedListResponse.iterateAll());
    boolean isFlowExists = false;
    for (Flow flow : flows) {
        if (flow.getName().equals(flowName)) {
            assertFlowDetails(flow);
            isFlowExists = true;
        }
    }
    assertTrue(isFlowExists);
}
Also used : FlowsClient(com.google.cloud.dialogflow.cx.v3beta1.FlowsClient) ListFlowsRequest(com.google.cloud.dialogflow.cx.v3beta1.ListFlowsRequest) Flow(com.google.cloud.dialogflow.cx.v3beta1.Flow) Test(org.junit.Test)

Example 2 with ListFlowsRequest

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

the class FlowsClientTest method listFlowsTest.

@Test
public void listFlowsTest() throws Exception {
    Flow responsesElement = Flow.newBuilder().build();
    ListFlowsResponse expectedResponse = ListFlowsResponse.newBuilder().setNextPageToken("").addAllFlows(Arrays.asList(responsesElement)).build();
    mockFlows.addResponse(expectedResponse);
    AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
    ListFlowsPagedResponse pagedListResponse = client.listFlows(parent);
    List<Flow> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getFlowsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockFlows.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListFlowsRequest actualRequest = ((ListFlowsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListFlowsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.FlowsClient.ListFlowsPagedResponse) Test(org.junit.Test)

Example 3 with ListFlowsRequest

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

the class FlowsClientTest method listFlowsTest2.

@Test
public void listFlowsTest2() throws Exception {
    Flow responsesElement = Flow.newBuilder().build();
    ListFlowsResponse expectedResponse = ListFlowsResponse.newBuilder().setNextPageToken("").addAllFlows(Arrays.asList(responsesElement)).build();
    mockFlows.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListFlowsPagedResponse pagedListResponse = client.listFlows(parent);
    List<Flow> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getFlowsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockFlows.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListFlowsRequest actualRequest = ((ListFlowsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListFlowsPagedResponse(com.google.cloud.dialogflow.cx.v3beta1.FlowsClient.ListFlowsPagedResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 ListFlowsPagedResponse (com.google.cloud.dialogflow.cx.v3beta1.FlowsClient.ListFlowsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Flow (com.google.cloud.dialogflow.cx.v3beta1.Flow)1 FlowsClient (com.google.cloud.dialogflow.cx.v3beta1.FlowsClient)1 ListFlowsRequest (com.google.cloud.dialogflow.cx.v3beta1.ListFlowsRequest)1