Search in sources :

Example 1 with Workflow

use of com.google.cloud.workflows.v1.Workflow in project java-workflows by googleapis.

the class WorkflowsClientTest method listWorkflowsTest2.

@Test
public void listWorkflowsTest2() throws Exception {
    Workflow responsesElement = Workflow.newBuilder().build();
    ListWorkflowsResponse expectedResponse = ListWorkflowsResponse.newBuilder().setNextPageToken("").addAllWorkflows(Arrays.asList(responsesElement)).build();
    mockWorkflows.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListWorkflowsPagedResponse pagedListResponse = client.listWorkflows(parent);
    List<Workflow> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getWorkflowsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockWorkflows.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListWorkflowsRequest actualRequest = ((ListWorkflowsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListWorkflowsPagedResponse(com.google.cloud.workflows.v1.WorkflowsClient.ListWorkflowsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 2 with Workflow

use of com.google.cloud.workflows.v1.Workflow in project java-docs-samples by GoogleCloudPlatform.

the class WorkflowsQuickstartTest method deployWorkflow.

private static void deployWorkflow(String projectId, String location, String workflowId) throws IOException, InterruptedException, ExecutionException {
    if (workflowsClient == null) {
        workflowsClient = WorkflowsClient.create();
    }
    LocationName parent = LocationName.of(projectId, location);
    String source = new String(Files.readAllBytes(Paths.get("src/test/java/com/example/workflows/resources/source.yaml")));
    Workflow workflow = Workflow.newBuilder().setSourceContents(source).build();
    // Deploy workflow
    workflowsClient.createWorkflowAsync(parent, workflow, workflowId).get();
}
Also used : Workflow(com.google.cloud.workflows.v1.Workflow) LocationName(com.google.cloud.workflows.v1.LocationName)

Example 3 with Workflow

use of com.google.cloud.workflows.v1.Workflow in project java-workflows by googleapis.

the class WorkflowsClientTest method listWorkflowsTest.

@Test
public void listWorkflowsTest() throws Exception {
    Workflow responsesElement = Workflow.newBuilder().build();
    ListWorkflowsResponse expectedResponse = ListWorkflowsResponse.newBuilder().setNextPageToken("").addAllWorkflows(Arrays.asList(responsesElement)).build();
    mockWorkflows.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListWorkflowsPagedResponse pagedListResponse = client.listWorkflows(parent);
    List<Workflow> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getWorkflowsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockWorkflows.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListWorkflowsRequest actualRequest = ((ListWorkflowsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListWorkflowsPagedResponse(com.google.cloud.workflows.v1.WorkflowsClient.ListWorkflowsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Aggregations

ListWorkflowsPagedResponse (com.google.cloud.workflows.v1.WorkflowsClient.ListWorkflowsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 LocationName (com.google.cloud.workflows.v1.LocationName)1 Workflow (com.google.cloud.workflows.v1.Workflow)1