use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class ClassificationQueryAccTest method testFindClassificationsByDomainAdmin.
@WithAccessId(userName = "admin")
@Test
public void testFindClassificationsByDomainAdmin() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery().domainIn("DOMAIN_A").list();
assertNotNull(classificationSummaryList);
assertEquals(17, classificationSummaryList.size());
}
use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class TaskServiceImplTest method testCreateSimpleTaskWithObjectReferenceIsNull.
@Test
public void testCreateSimpleTaskWithObjectReferenceIsNull() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
ObjectReference expectedObjectReference = JunitHelper.createDefaultObjRef();
WorkbasketImpl wb = new WorkbasketImpl();
wb.setId("1");
wb.setKey("key1");
wb.setName("workbasket");
wb.setDomain("dummy-domain");
doReturn(wb).when(workbasketServiceMock).getWorkbasket(wb.getKey(), wb.getDomain());
Classification dummyClassification = createDummyClassification();
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", "key1", dummyClassification);
expectedTask.setPrimaryObjRef(expectedObjectReference);
ClassificationSummary classification = expectedTask.getClassificationSummary();
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(expectedTask.getId());
doReturn(dummyClassification).when(classificationServiceImplMock).getClassification(classification.getKey(), classification.getDomain());
doNothing().when(taskMapperMock).insert(expectedTask);
doNothing().when(objectReferenceMapperMock).insert(expectedObjectReference);
doReturn(null).when(objectReferenceMapperMock).findByObjectReference(expectedTask.getPrimaryObjRef());
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
Task actualTask = cutSpy.createTask(expectedTask);
// get only new ID
expectedTask.getPrimaryObjRef().setId(actualTask.getPrimaryObjRef().getId());
verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).getWorkbasket(expectedTask.getWorkbasketKey(), expectedTask.getDomain());
verify(workbasketServiceMock, times(1)).checkAuthorization(expectedTask.getWorkbasketSummary().getId(), WorkbasketPermission.APPEND);
verify(classificationServiceImplMock, times(1)).getClassification(classification.getKey(), wb.getDomain());
verify(taskanaEngineMock, times(1)).getConfiguration();
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
verify(taskMapperMock, times(1)).insert(expectedTask);
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock, classificationServiceImplMock);
assertNull(actualTask.getOwner());
assertNotNull(actualTask.getCreated());
assertNotNull(actualTask.getModified());
assertNull(actualTask.getCompleted());
assertThat(actualTask.getWorkbasketKey(), equalTo(expectedTask.getWorkbasketKey()));
assertThat(actualTask.getName(), equalTo(expectedTask.getName()));
assertThat(actualTask.getState(), equalTo(TaskState.READY));
assertThat(actualTask.getPrimaryObjRef(), equalTo(expectedObjectReference));
}
use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class TaskServiceImplTest method testCreateSimpleTaskWithObjectReference.
@Test
public void testCreateSimpleTaskWithObjectReference() throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
ObjectReference expectedObjectReference = JunitHelper.createDefaultObjRef();
WorkbasketImpl wb = new WorkbasketImpl();
wb.setId("1");
wb.setName("workbasket");
wb.setKey("k33");
wb.setDomain("dummy-domain");
Classification dummyClassification = createDummyClassification();
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", wb.getKey(), dummyClassification);
expectedTask.setPrimaryObjRef(expectedObjectReference);
ClassificationSummary classification = expectedTask.getClassificationSummary();
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(expectedTask.getId());
doReturn(wb).when(workbasketServiceMock).getWorkbasket(expectedTask.getWorkbasketKey(), expectedTask.getDomain());
doReturn(expectedObjectReference).when(objectReferenceMapperMock).findByObjectReference(expectedObjectReference);
doReturn(dummyClassification).when(classificationServiceImplMock).getClassification(dummyClassification.getKey(), dummyClassification.getDomain());
doNothing().when(taskMapperMock).insert(expectedTask);
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineMock).getConfiguration();
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
Task actualTask = cutSpy.createTask(expectedTask);
verify(taskanaEngineMock, times(1)).openConnection();
verify(workbasketServiceMock, times(1)).getWorkbasket(wb.getKey(), wb.getDomain());
verify(workbasketServiceMock, times(1)).checkAuthorization(wb.getId(), WorkbasketPermission.APPEND);
verify(classificationServiceImplMock, times(1)).getClassification(classification.getKey(), classification.getDomain());
verify(taskanaEngineMock, times(1)).getConfiguration();
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
verify(taskMapperMock, times(1)).insert(expectedTask);
verify(taskanaEngineMock, times(1)).returnConnection();
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock, classificationServiceImplMock);
assertNull(actualTask.getOwner());
assertNotNull(actualTask.getCreated());
assertNotNull(actualTask.getModified());
assertNull(actualTask.getCompleted());
assertThat(actualTask.getWorkbasketKey(), equalTo(expectedTask.getWorkbasketKey()));
assertThat(actualTask.getName(), equalTo(expectedTask.getName()));
assertThat(actualTask.getState(), equalTo(TaskState.READY));
assertThat(actualTask.getPrimaryObjRef(), equalTo(expectedObjectReference));
}
use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class ClassificationServiceImplIntAutoCommitTest method testFindWithClassificationMapperPriorityTypeAndParent.
@Test
public void testFindWithClassificationMapperPriorityTypeAndParent() throws ClassificationAlreadyExistException, NumberFormatException, NotAuthorizedException, ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
Classification classification = this.createDummyClassificationWithUniqueKey("", "TASK");
classification.setPriority(Integer.decode("5"));
classificationService.createClassification(classification);
Classification classification1 = this.createDummyClassificationWithUniqueKey("", "TASK");
classification1.setPriority(Integer.decode("3"));
classification1.setParentId(classification.getId());
classificationService.createClassification(classification1);
Classification classification2 = this.createDummyClassificationWithUniqueKey("", "DOCUMENT");
classification2.setPriority(Integer.decode("5"));
classification2.setParentId(classification.getId());
classificationService.createClassification(classification2);
Classification classification3 = this.createDummyClassificationWithUniqueKey("", "TASK");
classification3.setPriority(Integer.decode("5"));
classification3.setParentId(classification1.getId());
classificationService.createClassification(classification3);
List<ClassificationSummary> list = classificationService.createClassificationQuery().parentIdIn(classification.getId()).list();
Assert.assertEquals(2, list.size());
list = classificationService.createClassificationQuery().typeIn("TASK").priorityIn(Integer.decode("5")).list();
Assert.assertEquals(2, list.size());
list = classificationService.createClassificationQuery().priorityIn(Integer.decode("5")).typeIn("TASK").parentIdIn(classification1.getId()).list();
Assert.assertEquals(1, list.size());
}
use of pro.taskana.ClassificationSummary in project taskana by Taskana.
the class ClassificationServiceImplIntAutoCommitTest method testInsertAndClassificationMapper.
@Test
public void testInsertAndClassificationMapper() throws NotAuthorizedException, ClassificationAlreadyExistException, ClassificationNotFoundException, InvalidArgumentException, DomainNotFoundException {
Classification classification = this.createDummyClassificationWithUniqueKey("DOMAIN_A", "TASK");
classification = classificationService.createClassification(classification);
List<ClassificationSummary> list = classificationService.createClassificationQuery().validInDomainEquals(Boolean.TRUE).createdWithin(today()).list();
Assert.assertEquals(1, list.size());
}
Aggregations