Search in sources :

Example 21 with SubWorkflowParams

use of com.netflix.conductor.common.metadata.workflow.SubWorkflowParams in project conductor by Netflix.

the class AbstractWorkflowServiceTest method createSubWorkflow.

private void createSubWorkflow(Map<String, String> subWorkflowTaskToDomain) {
    WorkflowTask wft1 = new WorkflowTask();
    wft1.setName("junit_task_5");
    Map<String, Object> ip1 = new HashMap<>();
    ip1.put("p1", "${workflow.input.param1}");
    ip1.put("p2", "${workflow.input.param2}");
    wft1.setInputParameters(ip1);
    wft1.setTaskReferenceName("a1");
    WorkflowTask wft2 = new WorkflowTask();
    wft2.setName("subWorkflowTask");
    wft2.setType(SUB_WORKFLOW.name());
    SubWorkflowParams swp = new SubWorkflowParams();
    swp.setName(LINEAR_WORKFLOW_T1_T2);
    swp.setTaskToDomain(subWorkflowTaskToDomain);
    wft2.setSubWorkflowParam(swp);
    Map<String, Object> ip2 = new HashMap<>();
    ip2.put("test", "test value");
    ip2.put("param1", "sub workflow input param1");
    ip2.put("param2", 42);
    wft2.setInputParameters(ip2);
    wft2.setTaskReferenceName("a2");
    WorkflowTask wft3 = new WorkflowTask();
    wft3.setName("junit_task_6");
    Map<String, Object> ip3 = new HashMap<>();
    ip3.put("p1", "${workflow.input.param1}");
    ip3.put("p2", "${workflow.input.param2}");
    wft3.setInputParameters(ip3);
    wft3.setTaskReferenceName("a3");
    WorkflowDef main = new WorkflowDef();
    main.setSchemaVersion(2);
    main.setInputParameters(Arrays.asList("param1", "param2"));
    main.setName(WF_WITH_SUB_WF);
    main.getTasks().addAll(Arrays.asList(wft1, wft2, wft3));
    metadataService.updateWorkflowDef(Collections.singletonList(main));
}
Also used : SubWorkflowParams(com.netflix.conductor.common.metadata.workflow.SubWorkflowParams) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) HashMap(java.util.HashMap) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask)

Example 22 with SubWorkflowParams

use of com.netflix.conductor.common.metadata.workflow.SubWorkflowParams in project conductor by Netflix.

the class AbstractWorkflowServiceTest method createForkJoinNestedWorkflowWithSubworkflow.

private void createForkJoinNestedWorkflowWithSubworkflow(int schemaVersion) {
    WorkflowDef def = new WorkflowDef();
    def.setName(FORK_JOIN_NESTED_WF);
    def.setDescription(def.getName());
    def.setSchemaVersion(1);
    def.setVersion(1);
    def.setInputParameters(Arrays.asList("param1", "param2"));
    Map<String, Object> ip1 = new HashMap<>();
    ip1.put("p1", "workflow.input.param1");
    ip1.put("p2", "workflow.input.param2");
    ip1.put("case", "workflow.input.case");
    WorkflowTask[] tasks = new WorkflowTask[21];
    for (int i = 10; i < 21; i++) {
        WorkflowTask wft = new WorkflowTask();
        wft.setName("junit_task_" + i);
        wft.setInputParameters(ip1);
        wft.setTaskReferenceName("t" + i);
        tasks[i] = wft;
    }
    WorkflowTask d1 = new WorkflowTask();
    d1.setType(TaskType.DECISION.name());
    d1.setName("Decision");
    d1.setTaskReferenceName("d1");
    d1.setInputParameters(ip1);
    d1.setDefaultCase(Arrays.asList(tasks[18], tasks[20]));
    d1.setCaseValueParam("case");
    Map<String, List<WorkflowTask>> decisionCases = new HashMap<>();
    decisionCases.put("a", Arrays.asList(tasks[16], tasks[19], tasks[20]));
    decisionCases.put("b", Arrays.asList(tasks[17], tasks[20]));
    d1.setDecisionCases(decisionCases);
    WorkflowTask subWorkflow = new WorkflowTask();
    subWorkflow.setType(SUB_WORKFLOW.name());
    SubWorkflowParams sw = new SubWorkflowParams();
    sw.setName(LINEAR_WORKFLOW_T1_T2);
    subWorkflow.setSubWorkflowParam(sw);
    subWorkflow.setTaskReferenceName("sw1");
    WorkflowTask fork2 = new WorkflowTask();
    fork2.setType(TaskType.FORK_JOIN.name());
    fork2.setName("fork2");
    fork2.setTaskReferenceName("fork2");
    fork2.getForkTasks().add(Arrays.asList(tasks[12], tasks[14]));
    fork2.getForkTasks().add(Arrays.asList(tasks[13], d1));
    WorkflowTask join2 = new WorkflowTask();
    join2.setType(TaskType.JOIN.name());
    join2.setTaskReferenceName("join2");
    join2.setJoinOn(Arrays.asList("t14", "t20"));
    WorkflowTask fork1 = new WorkflowTask();
    fork1.setType(TaskType.FORK_JOIN.name());
    fork1.setTaskReferenceName("fork1");
    fork1.getForkTasks().add(Arrays.asList(tasks[11]));
    fork1.getForkTasks().add(Arrays.asList(fork2, join2));
    fork1.getForkTasks().add(Arrays.asList(subWorkflow));
    WorkflowTask join1 = new WorkflowTask();
    join1.setType(TaskType.JOIN.name());
    join1.setTaskReferenceName("join1");
    join1.setJoinOn(Arrays.asList("t11", "join2", "sw1"));
    def.getTasks().add(fork1);
    def.getTasks().add(join1);
    def.getTasks().add(tasks[15]);
    metadataService.updateWorkflowDef(def);
}
Also used : SubWorkflowParams(com.netflix.conductor.common.metadata.workflow.SubWorkflowParams) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) HashMap(java.util.HashMap) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) List(java.util.List) DynamicForkJoinTaskList(com.netflix.conductor.common.metadata.workflow.DynamicForkJoinTaskList) LinkedList(java.util.LinkedList)

Example 23 with SubWorkflowParams

use of com.netflix.conductor.common.metadata.workflow.SubWorkflowParams in project conductor by Netflix.

the class WorkflowServiceTest method createWorkflowWithSubWorkflowWithInlineSubWorkflow.

private void createWorkflowWithSubWorkflowWithInlineSubWorkflow() {
    registerWorkflow(createWorkflowWithInlineSubWorkflow());
    WorkflowTask workflowTask = new WorkflowTask();
    workflowTask.setName("subWorkflowTask");
    workflowTask.setType(SUB_WORKFLOW.name());
    SubWorkflowParams swp = new SubWorkflowParams();
    swp.setName(WF_WITH_INLINE_SUB_WF);
    workflowTask.setSubWorkflowParam(swp);
    Map<String, Object> input = new HashMap<>();
    input.put("test", "test value");
    input.put("param1", "sub workflow task input param1");
    input.put("param2", 21);
    workflowTask.setInputParameters(input);
    workflowTask.setTaskReferenceName("sw2");
    WorkflowDef main = new WorkflowDef();
    main.setSchemaVersion(2);
    main.setInputParameters(Arrays.asList("param1", "param2"));
    main.setName(WF_WITH_SUB_WF_WITH_INLINE_SUB_WF);
    main.getTasks().add(workflowTask);
    Map<String, Object> outputParameters = new HashMap<>();
    outputParameters.put("o1", "${workflow.input.param1}");
    outputParameters.put("o2", "${sw2.output.o2}");
    main.setOutputParameters(outputParameters);
    metadataService.updateWorkflowDef(Collections.singletonList(main));
}
Also used : SubWorkflowParams(com.netflix.conductor.common.metadata.workflow.SubWorkflowParams) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) HashMap(java.util.HashMap) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask)

Example 24 with SubWorkflowParams

use of com.netflix.conductor.common.metadata.workflow.SubWorkflowParams in project conductor by Netflix.

the class SubWorkflowParamsTest method testSetWorkflowDefinition.

@Test(expected = IllegalArgumentException.class)
public void testSetWorkflowDefinition() {
    // name is null
    SubWorkflowParams subWorkflowParams = new SubWorkflowParams();
    subWorkflowParams.setName("dummy-name");
    subWorkflowParams.setWorkflowDefinition(new Object());
}
Also used : SubWorkflowParams(com.netflix.conductor.common.metadata.workflow.SubWorkflowParams) Test(org.junit.Test)

Example 25 with SubWorkflowParams

use of com.netflix.conductor.common.metadata.workflow.SubWorkflowParams in project conductor by Netflix.

the class SubWorkflowParamsTest method testGetWorkflowDef.

@Test
public void testGetWorkflowDef() {
    // name is null
    SubWorkflowParams subWorkflowParams = new SubWorkflowParams();
    subWorkflowParams.setName("dummy-name");
    WorkflowDef def = new WorkflowDef();
    def.setName("test_workflow");
    def.setVersion(1);
    WorkflowTask task = new WorkflowTask();
    task.setName("test_task");
    task.setTaskReferenceName("t1");
    def.getTasks().add(task);
    subWorkflowParams.setWorkflowDefinition(def);
    assertEquals(def, subWorkflowParams.getWorkflowDefinition());
    assertEquals(def, subWorkflowParams.getWorkflowDef());
}
Also used : SubWorkflowParams(com.netflix.conductor.common.metadata.workflow.SubWorkflowParams) WorkflowDef(com.netflix.conductor.common.metadata.workflow.WorkflowDef) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) Test(org.junit.Test)

Aggregations

SubWorkflowParams (com.netflix.conductor.common.metadata.workflow.SubWorkflowParams)26 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)21 WorkflowDef (com.netflix.conductor.common.metadata.workflow.WorkflowDef)17 Test (org.junit.Test)13 HashMap (java.util.HashMap)12 LinkedList (java.util.LinkedList)5 Task (com.netflix.conductor.common.metadata.tasks.Task)4 Workflow (com.netflix.conductor.common.run.Workflow)4 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)4 TaskDef (com.netflix.conductor.common.metadata.tasks.TaskDef)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 ConstraintViolation (javax.validation.ConstraintViolation)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 DynamicForkJoinTaskList (com.netflix.conductor.common.metadata.workflow.DynamicForkJoinTaskList)1 JsonMapperProvider (com.netflix.conductor.common.utils.JsonMapperProvider)1 ApplicationException (com.netflix.conductor.core.execution.ApplicationException)1 TerminateWorkflowException (com.netflix.conductor.core.execution.TerminateWorkflowException)1