use of pro.taskana.exceptions.ClassificationNotFoundException in project taskana by Taskana.
the class ClassificationServiceImplTest method testCreateClassificationParentNotExisting.
@Test(expected = ClassificationNotFoundException.class)
public void testCreateClassificationParentNotExisting() throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException, DomainNotFoundException, InvalidArgumentException {
Classification classification = createDummyClassification();
classification.setParentId("NOT EXISTING ID");
doReturn(null).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(), classification.getDomain());
doReturn(null).when(classificationMapperMock).findById(classification.getParentId());
doReturn(true).when(taskanaEngineImplMock).domainExists(any());
try {
cutSpy.createClassification(classification);
} catch (ClassificationNotFoundException e) {
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).openConnection();
verify(classificationMapperMock, times(1)).findByKeyAndDomain(classification.getKey(), classification.getDomain());
verify(cutSpy, times(1)).getClassification(classification.getParentId());
verify(classificationMapperMock, times(1)).findById(classification.getParentId());
verify(taskanaEngineImplMock, times(2)).returnConnection();
verify(taskanaEngineImplMock, times(1)).domainExists(any());
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
throw e;
}
}
use of pro.taskana.exceptions.ClassificationNotFoundException in project taskana by Taskana.
the class ClassificationServiceImplTest method testUpdateClassificationParentNotExisting.
@Test(expected = ClassificationNotFoundException.class)
public void testUpdateClassificationParentNotExisting() throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, InvalidArgumentException {
Instant now = Instant.now();
ClassificationImpl oldClassification = (ClassificationImpl) createDummyClassification();
oldClassification.setParentId("SOME ID");
oldClassification.setCreated(now);
oldClassification.setModified(now);
Classification classification = createDummyClassification();
classification.setParentId("DIFFERENT ID - FOR CHECKING PARENT");
((ClassificationImpl) classification).setCreated(oldClassification.getCreated());
((ClassificationImpl) classification).setModified(oldClassification.getModified());
doReturn(oldClassification).when(cutSpy).getClassification(classification.getKey(), classification.getDomain());
doReturn(null).when(classificationMapperMock).findById(classification.getParentId());
try {
cutSpy.updateClassification(classification);
} catch (ClassificationNotFoundException e) {
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
verify(taskanaEngineImplMock, times(2)).openConnection();
verify(cutSpy, times(1)).getClassification(classification.getKey(), classification.getDomain());
verify(cutSpy, times(1)).getClassification(classification.getParentId());
verify(classificationMapperMock, times(1)).findById(classification.getParentId());
verify(taskanaEngineImplMock, times(2)).returnConnection();
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
throw e;
}
}
use of pro.taskana.exceptions.ClassificationNotFoundException in project taskana by Taskana.
the class TaskServiceImpl method classificationChanged.
BulkOperationResults<String, Exception> classificationChanged(String taskId, String classificationId) throws TaskNotFoundException, NotAuthorizedException, ClassificationNotFoundException {
LOGGER.debug("entry to classificationChanged(taskId = {} , classificationId = {} )", taskId, classificationId);
TaskImpl task = null;
BulkOperationResults<String, Exception> bulkLog = new BulkOperationResults<>();
try {
taskanaEngine.openConnection();
if (taskId == null || taskId.isEmpty() || classificationId == null || classificationId.isEmpty()) {
return bulkLog;
}
task = taskMapper.findById(taskId);
List<AttachmentImpl> attachmentImpls = attachmentMapper.findAttachmentsByTaskId(task.getId());
if (attachmentImpls == null) {
attachmentImpls = new ArrayList<>();
}
List<Attachment> attachments = augmentAttachmentsByClassification(attachmentImpls, bulkLog);
task.setAttachments(attachments);
Classification classification = classificationService.getClassification(classificationId);
task.setClassificationSummary(classification.asSummary());
PrioDurationHolder prioDurationFromAttachments = handleAttachmentsOnClassificationUpdate(task);
updateClassificationRelatedProperties(task, task, prioDurationFromAttachments);
task.setModified(Instant.now());
taskMapper.update(task);
return bulkLog;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from deleteTask(). ");
}
}
use of pro.taskana.exceptions.ClassificationNotFoundException in project taskana by Taskana.
the class ClassificationServiceImpl method getClassification.
@Override
public Classification getClassification(String id) throws ClassificationNotFoundException {
if (id == null) {
throw new ClassificationNotFoundException(id, "Classification for id " + id + " was not found.");
}
LOGGER.debug("entry to getClassification(id = {})", id);
Classification result = null;
try {
taskanaEngine.openConnection();
result = classificationMapper.findById(id);
if (result == null) {
LOGGER.error("Classification for id {} was not found. Throwing ClassificationNotFoundException", id);
throw new ClassificationNotFoundException(id, "Classification for id " + id + " was not found");
}
return result;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from getClassification(). Returning result {} ", result);
}
}
use of pro.taskana.exceptions.ClassificationNotFoundException in project taskana by Taskana.
the class QueryClassificationAccTest method testGetClassificationsForKeyAndCategories.
@Test
public void testGetClassificationsForKeyAndCategories() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery().keyIn("T2100", "L10000").categoryIn("EXTERNAL", "MANUAL").list();
assertNotNull(classifications);
assertEquals(5, classifications.size());
List<ClassificationSummary> externCategory = classifications.stream().filter(c -> c.getCategory().equals("EXTERNAL")).collect(Collectors.toList());
assertEquals(2, externCategory.size());
List<ClassificationSummary> manualCategory = classifications.stream().filter(c -> c.getCategory().equals("MANUAL")).collect(Collectors.toList());
assertEquals(3, manualCategory.size());
}
Aggregations