Search in sources :

Example 1 with Terminate

use of com.netflix.conductor.core.execution.tasks.Terminate in project conductor by Netflix.

the class TestWorkflowExecutor method testExecuteSystemTaskWithAsyncComplete.

@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());
}
Also used : Task(com.netflix.conductor.common.metadata.tasks.Task) WorkflowSystemTask(com.netflix.conductor.core.execution.tasks.WorkflowSystemTask) WorkflowTask(com.netflix.conductor.common.metadata.workflow.WorkflowTask) SubWorkflow(com.netflix.conductor.core.execution.tasks.SubWorkflow) Workflow(com.netflix.conductor.common.run.Workflow) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Terminate(com.netflix.conductor.core.execution.tasks.Terminate) Test(org.junit.Test)

Aggregations

Task (com.netflix.conductor.common.metadata.tasks.Task)1 WorkflowTask (com.netflix.conductor.common.metadata.workflow.WorkflowTask)1 Workflow (com.netflix.conductor.common.run.Workflow)1 SubWorkflow (com.netflix.conductor.core.execution.tasks.SubWorkflow)1 Terminate (com.netflix.conductor.core.execution.tasks.Terminate)1 WorkflowSystemTask (com.netflix.conductor.core.execution.tasks.WorkflowSystemTask)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1