@Test(expected = TaskNotFoundException.class) public void shouldThrowExceptionDuringExportingIfTaskNotFound() { long taskId = 12345; when(tasksDataService.findById(taskId)).thenReturn(null); taskService.exportTask(taskId); }
@Override @Transactional public String exportTask(Long taskId) { Task task = getTask(taskId); if (null != task) { LOGGER.info("Exporting task: {} with ID: {}", task.getName(), task.getId()); JsonNode node = new ObjectMapper().valueToTree(task.toDto()); removeIgnoredFields(node); return node.toString(); } else { throw new TaskNotFoundException(taskId); } }
TaskServiceImpl implements TaskService { @Override @Transactional public String exportTask(Long taskId) { Task task = getTask(taskId); if (null != task) { LOGGER.info("Exporting task: {} with ID: {}", task.getName(), task.getId()); JsonNode node = new ObjectMapper().valueToTree(task.toDto()); removeIgnoredFields(node); return node.toString(); } else { throw new TaskNotFoundException(taskId); } } }
TaskServiceImpl implements TaskService { @Override @Transactional public String exportTask(Long taskId) { Task task = getTask(taskId); if (null != task) { LOGGER.info("Exporting task: {} with ID: {}", task.getName(), task.getId()); JsonNode node = new ObjectMapper().valueToTree(task.toDto()); removeIgnoredFields(node); return node.toString(); } else { throw new TaskNotFoundException(taskId); } }  }
TaskServiceImpl implements TaskService { @Override @Transactional public String exportTask(Long taskId) { Task task = getTask(taskId); if (null != task) { LOGGER.info("Exporting task: {} with ID: {}", task.getName(), task.getId()); JsonNode node = new ObjectMapper().valueToTree(task.toDto()); removeIgnoredFields(node); return node.toString(); } else { throw new TaskNotFoundException(taskId); } }  @Override @Transactional Set<TaskError> save(final Task task); @Override @Transactional void setEnabledOrDisabled(final Task task); @Override @Transactional ActionEvent getActionEventFor(TaskActionInformation taskActionInformation); @Override @Transactional List<Task> getAllTasks(); @Override @Transactional List<Task> findTasksByName(String name); @Override @Transactional List<Task> findActiveTasksForTrigger(final TriggerEvent trigger); @Override @Transactional List<Task> findActiveTasksForTriggerSubject(final String subject); @Override TasksEventParser findCustomParser(String name); @Override @Transactional Task getTask(Long taskId); @Override @Transactional void deleteTask(Long taskId); @MotechListener(subjects = CHANNEL_UPDATE_SUBJECT) @Transactional void validateTasksAfterChannelUpdate(MotechEvent event); @MotechListener(subjects = DATA_PROVIDER_UPDATE_SUBJECT) @Transactional void validateTasksAfterTaskDataProviderUpdate(MotechEvent event); @Override @Transactional String exportTask(Long taskId); @Override @Transactional Task importTask(String json); @Override @Transactional List<Task> findTasksDependentOnModule(final String moduleName); @Autowired void setTasksDataService(TasksDataService tasksDataService); @Autowired void setChannelService(ChannelService channelService); @Autowired void setProviderService(TaskDataProviderService providerService); @Autowired void setEventRelay(EventRelay eventRelay); @Autowired void setBundleContext(BundleContext bundleContext); @Autowired void setTaskValidator(TaskValidator taskValidator); @Autowired void setTriggerEventService(TriggerEventService triggerEventService); @Autowired void setTaskMigrationManager(TaskMigrationManager taskMigrationManager); }
TaskServiceImpl implements TaskService { @Override @Transactional public String exportTask(Long taskId) { Task task = getTask(taskId); if (null != task) { LOGGER.info("Exporting task: {} with ID: {}", task.getName(), task.getId()); JsonNode node = new ObjectMapper().valueToTree(task.toDto()); removeIgnoredFields(node); return node.toString(); } else { throw new TaskNotFoundException(taskId); } }  @Override @Transactional Set<TaskError> save(final Task task); @Override @Transactional void setEnabledOrDisabled(final Task task); @Override @Transactional ActionEvent getActionEventFor(TaskActionInformation taskActionInformation); @Override @Transactional List<Task> getAllTasks(); @Override @Transactional List<Task> findTasksByName(String name); @Override @Transactional List<Task> findActiveTasksForTrigger(final TriggerEvent trigger); @Override @Transactional List<Task> findActiveTasksForTriggerSubject(final String subject); @Override TasksEventParser findCustomParser(String name); @Override @Transactional Task getTask(Long taskId); @Override @Transactional void deleteTask(Long taskId); @MotechListener(subjects = CHANNEL_UPDATE_SUBJECT) @Transactional void validateTasksAfterChannelUpdate(MotechEvent event); @MotechListener(subjects = DATA_PROVIDER_UPDATE_SUBJECT) @Transactional void validateTasksAfterTaskDataProviderUpdate(MotechEvent event); @Override @Transactional String exportTask(Long taskId); @Override @Transactional Task importTask(String json); @Override @Transactional List<Task> findTasksDependentOnModule(final String moduleName); @Autowired void setTasksDataService(TasksDataService tasksDataService); @Autowired void setChannelService(ChannelService channelService); @Autowired void setProviderService(TaskDataProviderService providerService); @Autowired void setEventRelay(EventRelay eventRelay); @Autowired void setBundleContext(BundleContext bundleContext); @Autowired void setTaskValidator(TaskValidator taskValidator); @Autowired void setTriggerEventService(TriggerEventService triggerEventService); @Autowired void setTaskMigrationManager(TaskMigrationManager taskMigrationManager); static final List<String> IGNORED_FIELDS; }