@Test
public void testExecuteSystemTaskWithAsyncComplete() {

    String workflowId = "workflow-id";
    Terminate terminate = new Terminate();
    String task1Id = IDGenerator.generate();
    Task task1 = new Task();
    task1.setTaskType(TaskType.WAIT.name());
    task1.setReferenceTaskName("waitTask");
    task1.setWorkflowInstanceId(workflowId);
    task1.setScheduledTime(System.currentTimeMillis());
    task1.setTaskId(task1Id);
    task1.getInputData().put("asyncComplete", true);
    task1.setStatus(Status.IN_PROGRESS);
    Workflow workflow = new Workflow();
    workflow.setWorkflowId(workflowId);
    workflow.setStatus(Workflow.WorkflowStatus.RUNNING);
    when(executionDAOFacade.getTaskById(anyString())).thenReturn(task1);
    when(executionDAOFacade.getWorkflowById(anyString(), anyBoolean())).thenReturn(workflow);
    workflowExecutor.executeSystemTask(terminate, task1Id,30);
    // An asyncComplete task shouldn't be executed through this logic, and the Terminate task should remain IN_PROGRESS.
    assertEquals(Status.IN_PROGRESS, task1.getStatus());
}