Search in sources :

Example 1 with ClassificationSummary

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());
}
Also used : ClassificationSummary(pro.taskana.ClassificationSummary) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 2 with ClassificationSummary

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));
}
Also used : Task(pro.taskana.Task) ClassificationSummary(pro.taskana.ClassificationSummary) Classification(pro.taskana.Classification) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with ClassificationSummary

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));
}
Also used : Task(pro.taskana.Task) ClassificationSummary(pro.taskana.ClassificationSummary) Classification(pro.taskana.Classification) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with ClassificationSummary

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());
}
Also used : ClassificationSummary(pro.taskana.ClassificationSummary) Classification(pro.taskana.Classification) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Example 5 with ClassificationSummary

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());
}
Also used : ClassificationSummary(pro.taskana.ClassificationSummary) Classification(pro.taskana.Classification) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Aggregations

ClassificationSummary (pro.taskana.ClassificationSummary)51 Test (org.junit.Test)38 AbstractAccTest (acceptance.AbstractAccTest)21 Classification (pro.taskana.Classification)20 ClassificationService (pro.taskana.ClassificationService)20 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)14 Connection (java.sql.Connection)7 Attachment (pro.taskana.Attachment)7 Duration (java.time.Duration)5 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)5 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Task (pro.taskana.Task)4 ClassificationNotFoundException (pro.taskana.exceptions.ClassificationNotFoundException)4 SystemException (pro.taskana.exceptions.SystemException)4 WithAccessId (pro.taskana.security.WithAccessId)4 PersistenceException (org.apache.ibatis.exceptions.PersistenceException)3 SQLException (java.sql.SQLException)2