@Test
    @SuppressWarnings("unchecked")
    public void testTerminateWorkflowWithFailureWorkflow() {
        WorkflowDef workflowDef = new WorkflowDef();
        workflowDef.setName("workflow");
        workflowDef.setFailureWorkflow("failure_workflow");

        WorkflowModel workflow = new WorkflowModel();
        workflow.setWorkflowId("1");
        workflow.setCorrelationId("testid");
        workflow.setWorkflowDefinition(new WorkflowDef());
        workflow.setStatus(WorkflowModel.Status.RUNNING);
        workflow.setOwnerApp("junit_test");
        workflow.setEndTime(100L);
        workflow.setOutput(Collections.EMPTY_MAP);
        workflow.setWorkflowDefinition(workflowDef);

        TaskModel successTask = new TaskModel();
        successTask.setTaskId("taskid1");
        successTask.setReferenceTaskName("success");
        successTask.setStatus(TaskModel.Status.COMPLETED);

        TaskModel failedTask = new TaskModel();
        failedTask.setTaskId("taskid2");
        failedTask.setReferenceTaskName("failed");
        failedTask.setStatus(TaskModel.Status.FAILED);
        workflow.getTasks().addAll(Arrays.asList(successTask, failedTask));

        WorkflowDef failureWorkflowDef = new WorkflowDef();
        failureWorkflowDef.setName("failure_workflow");
        when(metadataDAO.getLatestWorkflowDef(failureWorkflowDef.getName()))
                .thenReturn(Optional.of(failureWorkflowDef));

        when(executionDAOFacade.getWorkflowModel(workflow.getWorkflowId(), true))
                .thenReturn(workflow);
        when(executionLockService.acquireLock(anyString())).thenReturn(true);

        workflowExecutor.decide(workflow.getWorkflowId());

        assertEquals(WorkflowModel.Status.FAILED, workflow.getStatus());
        ArgumentCaptor<WorkflowCreationEvent> argumentCaptor =
                ArgumentCaptor.forClass(WorkflowCreationEvent.class);
        verify(eventPublisher, times(1)).publishEvent(argumentCaptor.capture());
        StartWorkflowInput startWorkflowInput = argumentCaptor.getValue().getStartWorkflowInput();
        assertEquals(workflow.getCorrelationId(), startWorkflowInput.getCorrelationId());
        assertEquals(
                workflow.getWorkflowId(), startWorkflowInput.getWorkflowInput().get("workflowId"));
        assertEquals(
                failedTask.getTaskId(), startWorkflowInput.getWorkflowInput().get("failureTaskId"));
        assertNotNull(
                failedTask.getTaskId(),
                startWorkflowInput.getWorkflowInput().get("failedWorkflow"));
    }
Simulate Queue push failures and assert that scheduleTask doesn't throw an exception.
core/src/test/java/com/netflix/conductor/core/execution/TestWorkflowExecutor.java