@Test
public void testStartSubWorkflow() {

    WorkflowDef workflowDef = new WorkflowDef();
    Workflow workflowInstance = new Workflow();
    workflowInstance.setWorkflowDefinition(workflowDef);
    Task task = new Task();
    task.setOutputData(new HashMap<>());
    Map<String, Object> inputData = new HashMap<>();
    inputData.put("subWorkflowName", "UnitWorkFlow");
    inputData.put("subWorkflowVersion", 3);
    task.setInputData(inputData);
    String workflowId = "workflow_1";
    Workflow workflow = new Workflow();
    workflow.setWorkflowId(workflowId);
    when(workflowExecutor.startWorkflow(eq("UnitWorkFlow"), eq(3), eq(inputData), eq(null), any(), any(), any(), eq(null), any()))
            .thenReturn(workflowId);
    when(workflowExecutor.getWorkflow(anyString(), eq(false))).thenReturn(workflow);
    workflow.setStatus(Workflow.WorkflowStatus.RUNNING);
    subWorkflow.start(workflowInstance, task, workflowExecutor);
    assertEquals("workflow_1", task.getSubWorkflowId());
    assertEquals(Task.Status.IN_PROGRESS, task.getStatus());
    workflow.setStatus(Workflow.WorkflowStatus.TERMINATED);
    subWorkflow.start(workflowInstance, task, workflowExecutor);
    assertEquals("workflow_1", task.getSubWorkflowId());
    assertEquals(Task.Status.FAILED, task.getStatus());
    workflow.setStatus(Workflow.WorkflowStatus.COMPLETED);
    subWorkflow.start(workflowInstance, task, workflowExecutor);
    assertEquals("workflow_1", task.getSubWorkflowId());
    assertEquals(Task.Status.COMPLETED, task.getStatus());
}