use of pro.taskana.TaskState in project taskana by Taskana.
the class TaskMonitorServiceImplTest method testGetTotalNumbersOfCatgoryReport.
@Test
public void testGetTotalNumbersOfCatgoryReport() throws InvalidArgumentException {
List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY);
List<String> categories = Collections.singletonList("EXTERN");
List<String> domains = Collections.singletonList("DOMAIN_A");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("EXTERN");
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfCategories(workbasketIds, states, categories, domains, customField, customFieldValues);
CategoryReport actualResult = cut.getCategoryReport(workbasketIds, states, categories, domains, customField, customFieldValues);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfCategories(any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(actualResult.getRow("EXTERN").getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
use of pro.taskana.TaskState in project taskana by Taskana.
the class TaskMonitorServiceImplTest method testGetTotalNumbersOfDetailedClassificationReport.
@Test
public void testGetTotalNumbersOfDetailedClassificationReport() throws InvalidArgumentException {
List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY);
List<String> categories = Collections.singletonList("EXTERN");
List<String> domains = Collections.singletonList("DOMAIN_A");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<DetailedMonitorQueryItem> expectedResult = new ArrayList<>();
DetailedMonitorQueryItem detailedMonitorQueryItem = new DetailedMonitorQueryItem();
detailedMonitorQueryItem.setKey("CLI:000000000000000000000000000000000001");
detailedMonitorQueryItem.setAttachmentKey("CLI:000000000000000000000000000000000006");
detailedMonitorQueryItem.setNumberOfTasks(1);
expectedResult.add(detailedMonitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfDetailedClassifications(workbasketIds, states, categories, domains, customField, customFieldValues);
DetailedClassificationReport actualResult = cut.getDetailedClassificationReport(workbasketIds, states, categories, domains, customField, customFieldValues);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfDetailedClassifications(any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
DetailedReportRow line = actualResult.getRow("CLI:000000000000000000000000000000000001");
assertNotNull(actualResult);
assertEquals(line.getTotalValue(), 1);
assertEquals(line.getDetailRows().get("CLI:000000000000000000000000000000000006").getTotalValue(), 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
use of pro.taskana.TaskState in project taskana by Taskana.
the class TaskMonitorServiceImplTest method testGetWorkbasketLevelReportWithReportLineItemDefinitions.
@Test
public void testGetWorkbasketLevelReportWithReportLineItemDefinitions() throws InvalidArgumentException {
List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY);
List<String> categories = Collections.singletonList("EXTERN");
List<String> domains = Collections.singletonList("DOMAIN_A");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("WBI:000000000000000000000000000000000001");
monitorQueryItem.setAgeInDays(0);
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfWorkbaskets(workbasketIds, states, categories, domains, customField, customFieldValues);
WorkbasketLevelReport actualResult = cut.getWorkbasketLevelReport(workbasketIds, states, categories, domains, customField, customFieldValues, reportLineItemDefinitions);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfWorkbaskets(any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(actualResult.getRow("WBI:000000000000000000000000000000000001").getTotalValue(), 1);
assertEquals(actualResult.getRow("WBI:000000000000000000000000000000000001").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
use of pro.taskana.TaskState in project taskana by Taskana.
the class TaskMonitorServiceImplTest method testGetCustomFieldValueReportWithReportLineItemDefinitions.
@Test
public void testGetCustomFieldValueReportWithReportLineItemDefinitions() throws InvalidArgumentException {
List<String> workbasketIds = Collections.singletonList("WBI:000000000000000000000000000000000001");
List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY);
List<String> categories = Collections.singletonList("EXTERN");
List<String> domains = Collections.singletonList("DOMAIN_A");
CustomField customField = CustomField.CUSTOM_1;
List<String> customFieldValues = Collections.singletonList("Geschaeftsstelle A");
List<TimeIntervalColumnHeader> reportLineItemDefinitions = Collections.singletonList(new TimeIntervalColumnHeader(0, 0));
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("Geschaeftsstelle A");
monitorQueryItem.setAgeInDays(0);
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountOfCustomFieldValues(workbasketIds, states, categories, domains, customField, customFieldValues);
CustomFieldValueReport actualResult = cut.getCustomFieldValueReport(workbasketIds, states, categories, domains, customField, customFieldValues, reportLineItemDefinitions);
verify(taskanaEngineImplMock, times(1)).openConnection();
verify(taskanaEngineImplMock, times(2)).getConfiguration();
verify(taskanaEngineConfiguration, times(1)).isGermanPublicHolidaysEnabled();
verify(taskanaEngineConfiguration, times(1)).getCustomHolidays();
verify(taskMonitorMapperMock, times(1)).getTaskCountOfCustomFieldValues(any(), any(), any(), any(), any(), any());
verify(taskanaEngineImplMock, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineImplMock, taskMonitorMapperMock, taskanaEngineConfiguration);
assertNotNull(actualResult);
assertEquals(actualResult.getRow("Geschaeftsstelle A").getTotalValue(), 1);
assertEquals(actualResult.getRow("Geschaeftsstelle A").getCells()[0], 1);
assertEquals(actualResult.getSumRow().getTotalValue(), 1);
}
use of pro.taskana.TaskState in project taskana by Taskana.
the class TaskServiceImpl method cancelClaim.
@Override
public Task cancelClaim(String taskId, boolean forceUnclaim) throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug("entry to cancelClaim(taskId = {}) with userId = {}, forceFlag = {}", taskId, userId, forceUnclaim);
TaskImpl task = null;
try {
taskanaEngine.openConnection();
task = (TaskImpl) getTask(taskId);
TaskState state = task.getState();
if (state == TaskState.COMPLETED) {
LOGGER.warn("Method cancelClaim() found that task {} is already completed. Throwing InvalidStateException", taskId);
throw new InvalidStateException("Task is already completed");
}
if (state == TaskState.CLAIMED && !forceUnclaim && !userId.equals(task.getOwner())) {
LOGGER.warn("Method cancelClaim() found that task {} is claimed by {} and forceClaim is false. Throwing InvalidOwnerException", taskId, task.getOwner());
throw new InvalidOwnerException("Task is already claimed by an other user = " + task.getOwner());
}
Instant now = Instant.now();
task.setOwner(null);
task.setModified(now);
task.setClaimed(null);
task.setRead(true);
task.setState(TaskState.READY);
taskMapper.update(task);
LOGGER.debug("Method cancelClaim() unclaimed task '{}' for user '{}'.", taskId, userId);
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from cancelClaim(taskId = {}) with userId = {}, forceFlag = {}", taskId, userId, forceUnclaim);
}
return task;
}
Aggregations