@Test public void shoulNotifyOnSuccessfulTask() { when(taskActivityService.addSuccessfulExecution(TASK_ACTIVITY_ID)).thenReturn(true); when(taskActivityService.getTaskActivityById(TASK_ACTIVITY_ID)).thenReturn(taskActivity); when(taskService.getTask(task.getId())).thenReturn(task); postExecutionHandler.handleActionExecuted(createEventParameters(), new HashMap<>(), TASK_ACTIVITY_ID); ArgumentCaptor<MotechEvent> captorEvent = ArgumentCaptor.forClass(MotechEvent.class); verify(eventRelay).sendEventMessage(captorEvent.capture()); MotechEvent motechEvent = captorEvent.getValue(); assertEquals(EventSubjects.createHandlerSuccessSubject(task.getName()), motechEvent.getSubject()); }
public void handleActionExecuted(Map<String, Object> params, Map<String, Object> metadata, Long activityId) { boolean taskFinished = activityService.addSuccessfulExecution(activityId); if (taskFinished) { Long taskId = activityService.getTaskActivityById(activityId).getTask(); Task task = taskService.getTask(taskId); handleSuccess(params, task); } }
TasksPostExecutionHandler { public void handleActionExecuted(Map<String, Object> params, Map<String, Object> metadata, Long activityId) { boolean taskFinished = activityService.addSuccessfulExecution(activityId); if (taskFinished) { Long taskId = activityService.getTaskActivityById(activityId).getTask(); Task task = taskService.getTask(taskId); handleSuccess(params, task); } } }
TasksPostExecutionHandler { public void handleActionExecuted(Map<String, Object> params, Map<String, Object> metadata, Long activityId) { boolean taskFinished = activityService.addSuccessfulExecution(activityId); if (taskFinished) { Long taskId = activityService.getTaskActivityById(activityId).getTask(); Task task = taskService.getTask(taskId); handleSuccess(params, task); } }  }
TasksPostExecutionHandler { public void handleActionExecuted(Map<String, Object> params, Map<String, Object> metadata, Long activityId) { boolean taskFinished = activityService.addSuccessfulExecution(activityId); if (taskFinished) { Long taskId = activityService.getTaskActivityById(activityId).getTask(); Task task = taskService.getTask(taskId); handleSuccess(params, task); } }  void handleActionExecuted(Map<String, Object> params, Map<String, Object> metadata, Long activityId); void handleError(Map<String, Object> params, Map<String, Object> metadata, Task task, TaskHandlerException e, Long activityId); }
TasksPostExecutionHandler { public void handleActionExecuted(Map<String, Object> params, Map<String, Object> metadata, Long activityId) { boolean taskFinished = activityService.addSuccessfulExecution(activityId); if (taskFinished) { Long taskId = activityService.getTaskActivityById(activityId).getTask(); Task task = taskService.getTask(taskId); handleSuccess(params, task); } }  void handleActionExecuted(Map<String, Object> params, Map<String, Object> metadata, Long activityId); void handleError(Map<String, Object> params, Map<String, Object> metadata, Task task, TaskHandlerException e, Long activityId);  }