Search in sources :

Example 16 with TaskActivity

use of org.motechproject.tasks.domain.mds.task.TaskActivity in project motech by motech.

the class TaskActivityServiceImplTest method shouldAddErrorActivityWithTaskException.

@Test
public void shouldAddErrorActivityWithTaskException() {
    when(taskActivitiesDataService.findById(TASK_ACTIVITY_ID)).thenReturn(createInProgress());
    String messageKey = "error.notFoundTrigger";
    TaskHandlerException exception = new TaskHandlerException(TRIGGER, messageKey, ERROR_FIELD.get(0));
    ArgumentCaptor<TaskActivity> captor = ArgumentCaptor.forClass(TaskActivity.class);
    activityService.addFailedExecution(TASK_ACTIVITY_ID, exception);
    verify(taskActivitiesDataService).update(captor.capture());
    assertActivity(messageKey, ERROR_FIELD, TASK_ID, TaskActivityType.ERROR, getStackTrace(exception), null, captor.getValue());
}
Also used : TaskHandlerException(org.motechproject.tasks.exception.TaskHandlerException) TaskActivity(org.motechproject.tasks.domain.mds.task.TaskActivity) Test(org.junit.Test)

Aggregations

TaskActivity (org.motechproject.tasks.domain.mds.task.TaskActivity)16 Test (org.junit.Test)6 Transactional (org.springframework.transaction.annotation.Transactional)6 TaskExecutionProgress (org.motechproject.tasks.domain.mds.task.TaskExecutionProgress)4 QueryParams (org.motechproject.mds.query.QueryParams)3 TaskHandlerException (org.motechproject.tasks.exception.TaskHandlerException)3 HashSet (java.util.HashSet)2 DateTime (org.joda.time.DateTime)2 TaskActivityType (org.motechproject.tasks.domain.enums.TaskActivityType)2 Order (org.motechproject.mds.util.Order)1