ExecutionDAOFacade { public void removeWorkflow(String workflowId, boolean archiveWorkflow) { try { Workflow workflow = getWorkflowById(workflowId, true); removeWorkflowIndex(workflow, archiveWorkflow); try { executionDAO.removeWorkflow(workflowId); } catch (Exception ex) { Monitors.recordDaoError("executionDao", "removeWorkflow"); throw ex; } } catch (ApplicationException ae) { throw ae; } catch (Exception e) { throw new ApplicationException(ApplicationException.Code.BACKEND_ERROR, "Error removing workflow: " + workflowId, e); } } @Inject  ExecutionDAOFacade(ExecutionDAO executionDAO, QueueDAO queueDAO, IndexDAO indexDAO,
        RateLimitingDAO rateLimitingDao, PollDataDAO pollDataDAO, ObjectMapper objectMapper, Configuration config); @PreDestroy void shutdownExecutorService(); Workflow getWorkflowById(String workflowId, boolean includeTasks); List<Workflow> getWorkflowsByCorrelationId(String workflowName, String correlationId, boolean includeTasks); List<Workflow> getWorkflowsByName(String workflowName, Long startTime, Long endTime); List<Workflow> getPendingWorkflowsByName(String workflowName, int version); List<String> getRunningWorkflowIds(String workflowName, int version); long getPendingWorkflowCount(String workflowName); String createWorkflow(Workflow workflow); String updateWorkflow(Workflow workflow); void removeFromPendingWorkflow(String workflowType, String workflowId); void removeWorkflow(String workflowId, boolean archiveWorkflow); void removeWorkflowWithExpiry(String workflowId, boolean archiveWorkflow, int ttlSeconds); void resetWorkflow(String workflowId); List<Task> createTasks(List<Task> tasks); List<Task> getTasksForWorkflow(String workflowId); Task getTaskById(String taskId); List<Task> getTasksByName(String taskName, String startKey, int count); List<Task> getPendingTasksForTaskType(String taskType); long getInProgressTaskCount(String taskDefName); void updateTask(Task task); void updateTasks(List<Task> tasks); void removeTask(String taskId); List<PollData> getTaskPollData(String taskName); List<PollData> getAllPollData(); PollData getTaskPollDataByDomain(String taskName, String domain); void updateTaskLastPoll(String taskName, String domain, String workerId); boolean addEventExecution(EventExecution eventExecution); void updateEventExecution(EventExecution eventExecution); void removeEventExecution(EventExecution eventExecution); boolean exceedsInProgressLimit(Task task); boolean exceedsRateLimitPerFrequency(Task task, TaskDef taskDef); void addTaskExecLog(List<TaskExecLog> logs); void addMessage(String queue, Message message); SearchResult<String> searchWorkflows(String query, String freeText, int start, int count, List<String> sort); SearchResult<String> searchTasks(String query, String freeText, int start, int count, List<String> sort); List<TaskExecLog> getTaskExecutionLogs(String taskId);  }
@Test public void testRemoveWorkflow() { Workflow workflow = new Workflow(); workflow.setStatus(WorkflowStatus.COMPLETED); when(executionDAO.getWorkflow(anyString(), anyBoolean())).thenReturn(workflow); executionDAOFacade.removeWorkflow("workflowId", false); verify(indexDAO, never()).updateWorkflow(any(), any(), any()); verify(indexDAO, times(1)).asyncRemoveWorkflow(workflow.getWorkflowId()); }