use of org.motechproject.tasks.domain.mds.task.TaskActivity in project motech by motech.
the class TaskActivityServiceImplTest method shouldAddTaskWarningActivityWithGivenException.
@Test
public void shouldAddTaskWarningActivityWithGivenException() {
TaskHandlerException exception = new TaskHandlerException(TRIGGER, "trigger.exception", new TaskHandlerException(TRIGGER, "task.exception"));
String messageKey = "warning.manipulation";
ArgumentCaptor<TaskActivity> captor = ArgumentCaptor.forClass(TaskActivity.class);
activityService.addWarningWithException(task, messageKey, ERROR_FIELD.get(0), exception);
verify(taskActivitiesDataService).create(captor.capture());
assertActivity(messageKey, ERROR_FIELD, TASK_ID, TaskActivityType.WARNING, getStackTrace(exception.getCause()), null, captor.getValue());
}
use of org.motechproject.tasks.domain.mds.task.TaskActivity in project motech by motech.
the class TaskActivityServiceImplTest method shouldReturnPaginatedActivitiesForGivenTask.
@Test
public void shouldReturnPaginatedActivitiesForGivenTask() {
Set<TaskActivityType> types = new HashSet<>();
types.addAll(Arrays.asList(TaskActivityType.values()));
Set<Long> activitiesIds = new HashSet<>();
QueryParams queryParams = new QueryParams((Order) null);
boolean lastExecution = false;
when(taskActivitiesDataService.byTaskAndActivityTypesAndIds(TASK_ID, types, activitiesIds, queryParams)).thenReturn(activities);
List<TaskActivity> actual = activityService.getTaskActivities(TASK_ID, types, queryParams, lastExecution);
assertNotNull(actual);
assertEquals(activities, actual);
}
use of org.motechproject.tasks.domain.mds.task.TaskActivity in project motech by motech.
the class TasksTestBase method setTaskActivities.
protected void setTaskActivities() {
taskActivities = new ArrayList<>(5);
taskActivities.add(new TaskActivity("Error1", task.getId(), ERROR));
taskActivities.add(new TaskActivity("Error2", task.getId(), ERROR));
taskActivities.add(new TaskActivity("Error3", task.getId(), ERROR));
taskActivities.add(new TaskActivity("Error4", task.getId(), ERROR));
}
use of org.motechproject.tasks.domain.mds.task.TaskActivity in project motech by motech.
the class ActionParametersBundleIT method hasTaskExecuted.
private boolean hasTaskExecuted(Long taskID) {
Set<TaskActivityType> activityTypes = new HashSet<>();
Set<Long> activityIds = new HashSet<>();
activityTypes.add(TaskActivityType.SUCCESS);
QueryParams queryParams = new QueryParams((Order) null);
List<TaskActivity> taskActivities = taskActivitiesDataService.byTaskAndActivityTypesAndIds(taskID, activityTypes, activityIds, queryParams);
return taskActivities.size() == 1;
}
use of org.motechproject.tasks.domain.mds.task.TaskActivity in project motech by motech.
the class TaskActivitiesDataServiceBundleIT method shouldFindTaskActivitiesByTaskId.
@Test
public void shouldFindTaskActivitiesByTaskId() {
TaskActivity errorMsg = new TaskActivity(ERROR.getValue(), FIELD, TASK_ID_1, ERROR, new TaskExecutionProgress(1));
TaskActivity successMsg = new TaskActivity(SUCCESS.getValue(), TASK_ID_1, SUCCESS);
TaskActivity warningMsg = new TaskActivity(WARNING.getValue(), TASK_ID_2, WARNING);
taskActivitiesDataService.create(errorMsg);
taskActivitiesDataService.create(warningMsg);
taskActivitiesDataService.create(successMsg);
assertEquals(asList(errorMsg, warningMsg, successMsg), taskActivitiesDataService.retrieveAll());
List<TaskActivity> messages = taskActivitiesDataService.byTask(TASK_ID_1);
assertEquals(asList(errorMsg, successMsg), messages);
assertEquals(ERROR, messages.get(0).getActivityType());
assertEquals(TASK_ID_1, messages.get(0).getTask());
assertEquals(ERROR.getValue(), messages.get(0).getMessage());
assertEquals(FIELD, messages.get(0).getFields());
assertEquals(SUCCESS, messages.get(1).getActivityType());
assertEquals(TASK_ID_1, messages.get(1).getTask());
assertEquals(SUCCESS.getValue(), messages.get(1).getMessage());
messages = taskActivitiesDataService.byTask(TASK_ID_2);
assertEquals(asList(warningMsg), messages);
assertEquals(WARNING, messages.get(0).getActivityType());
assertEquals(TASK_ID_2, messages.get(0).getTask());
assertEquals(WARNING.getValue(), messages.get(0).getMessage());
}
Aggregations