Search in sources :

Example 6 with Classification

use of pro.taskana.Classification in project taskana by Taskana.

the class UpdateClassificationAccTest method testUpdateClassificationParentToInvalid.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test(expected = ClassificationNotFoundException.class)
public void testUpdateClassificationParentToInvalid() throws NotAuthorizedException, ClassificationNotFoundException, ConcurrencyException, InvalidArgumentException {
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
    classification.setParentId("ID WHICH CANT BE FOUND");
    classification = classificationService.updateClassification(classification);
}
Also used : Classification(pro.taskana.Classification) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 7 with Classification

use of pro.taskana.Classification in project taskana by Taskana.

the class UpdateClassificationAccTest method testUpdateClassification.

@WithAccessId(userName = "dummy", groupNames = { "businessadmin" })
@Test
public void testUpdateClassification() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, InvalidArgumentException {
    String newName = "updated Name";
    String newEntryPoint = "updated EntryPoint";
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
    Instant createdBefore = classification.getCreated();
    Instant modifiedBefore = classification.getModified();
    classification.setApplicationEntryPoint(newEntryPoint);
    classification.setCategory("PROCESS");
    classification.setCustom1("newCustom1");
    classification.setCustom2("newCustom2");
    classification.setCustom3("newCustom3");
    classification.setCustom4("newCustom4");
    classification.setCustom5("newCustom5");
    classification.setCustom6("newCustom6");
    classification.setCustom7("newCustom7");
    classification.setCustom8("newCustom8");
    classification.setDescription("newDescription");
    classification.setIsValidInDomain(false);
    classification.setName(newName);
    classification.setParentId("CLI:100000000000000000000000000000000004");
    classification.setPriority(1000);
    classification.setServiceLevel("P2DT3H4M");
    classificationService.updateClassification(classification);
    // Get and check the new value
    Classification updatedClassification = classificationService.getClassification("T2100", "DOMAIN_A");
    assertNotNull(updatedClassification);
    assertThat(updatedClassification.getName(), equalTo(newName));
    assertThat(updatedClassification.getApplicationEntryPoint(), equalTo(newEntryPoint));
    assertThat(updatedClassification.getCreated(), equalTo(createdBefore));
    assertTrue(modifiedBefore.isBefore(updatedClassification.getModified()));
}
Also used : Classification(pro.taskana.Classification) Instant(java.time.Instant) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 8 with Classification

use of pro.taskana.Classification in project taskana by Taskana.

the class UpdateClassificationAccTest method testUpdateClassificationNotLatestAnymore.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test(expected = ConcurrencyException.class)
public void testUpdateClassificationNotLatestAnymore() throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, InterruptedException, InvalidArgumentException {
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    Classification base = classificationService.getClassification("T2100", "DOMAIN_A");
    Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
    // UPDATE BASE
    base.setApplicationEntryPoint("SOME CHANGED POINT");
    base.setDescription("AN OTHER DESCRIPTION");
    base.setName("I AM UPDATED");
    // to avoid identity of modified timestamps between classification and base
    Thread.sleep(20);
    classificationService.updateClassification(base);
    classification.setName("NOW IT´S MY TURN");
    classification.setDescription("IT SHOULD BE TO LATE...");
    classificationService.updateClassification(classification);
    fail("The Classification should not be updated, because it was modified while editing.");
}
Also used : Classification(pro.taskana.Classification) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 9 with Classification

use of pro.taskana.Classification in project taskana by Taskana.

the class TaskServiceImplTest method testTransferDestinationWorkbasketDoesNotExist.

@Test(expected = WorkbasketNotFoundException.class)
public void testTransferDestinationWorkbasketDoesNotExist() throws Exception {
    String destinationWorkbasketId = "2";
    Classification dummyClassification = createDummyClassification();
    Task task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
    TaskServiceImpl cutSpy = Mockito.spy(cut);
    doThrow(WorkbasketNotFoundException.class).when(workbasketServiceMock).checkAuthorization(destinationWorkbasketId, WorkbasketPermission.APPEND);
    doReturn(task).when(cutSpy).getTask(task.getId());
    try {
        cutSpy.transfer(task.getId(), destinationWorkbasketId);
    } catch (Exception e) {
        verify(taskanaEngineMock, times(1)).openConnection();
        verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId, WorkbasketPermission.APPEND);
        verify(taskanaEngineMock, times(1)).returnConnection();
        verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
        throw e;
    }
}
Also used : Task(pro.taskana.Task) Classification(pro.taskana.Classification) ClassificationAlreadyExistException(pro.taskana.exceptions.ClassificationAlreadyExistException) SystemException(pro.taskana.exceptions.SystemException) InvalidStateException(pro.taskana.exceptions.InvalidStateException) TaskAlreadyExistException(pro.taskana.exceptions.TaskAlreadyExistException) ClassificationNotFoundException(pro.taskana.exceptions.ClassificationNotFoundException) ConcurrencyException(pro.taskana.exceptions.ConcurrencyException) InvalidOwnerException(pro.taskana.exceptions.InvalidOwnerException) AttachmentPersistenceException(pro.taskana.exceptions.AttachmentPersistenceException) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) PersistenceException(org.apache.ibatis.exceptions.PersistenceException) WorkbasketNotFoundException(pro.taskana.exceptions.WorkbasketNotFoundException) TaskNotFoundException(pro.taskana.exceptions.TaskNotFoundException) InvalidWorkbasketException(pro.taskana.exceptions.InvalidWorkbasketException) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 10 with Classification

use of pro.taskana.Classification in project taskana by Taskana.

the class TaskServiceImplTest method testCompleteTaskNotForcedNotClaimedBefore.

@Test(expected = InvalidStateException.class)
public void testCompleteTaskNotForcedNotClaimedBefore() throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, ClassificationNotFoundException, NotAuthorizedException {
    final boolean isForced = false;
    TaskServiceImpl cutSpy = Mockito.spy(cut);
    Classification dummyClassification = createDummyClassification();
    TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
    task.setState(TaskState.READY);
    task.setClaimed(null);
    doReturn(task).when(cutSpy).getTask(task.getId());
    try {
        cutSpy.completeTask(task.getId(), isForced);
    } catch (InvalidStateException e) {
        verify(taskanaEngineMock, times(1)).openConnection();
        verify(cutSpy, times(1)).getTask(task.getId());
        verify(taskanaEngineMock, times(1)).returnConnection();
        verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock, classificationQueryImplMock);
        throw e;
    }
}
Also used : Classification(pro.taskana.Classification) InvalidStateException(pro.taskana.exceptions.InvalidStateException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Classification (pro.taskana.Classification)102 Test (org.junit.Test)88 Task (pro.taskana.Task)32 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)29 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)28 AbstractAccTest (acceptance.AbstractAccTest)23 WithAccessId (pro.taskana.security.WithAccessId)21 ClassificationSummary (pro.taskana.ClassificationSummary)20 Workbasket (pro.taskana.Workbasket)18 Connection (java.sql.Connection)14 ClassificationNotFoundException (pro.taskana.exceptions.ClassificationNotFoundException)14 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)13 TaskAlreadyExistException (pro.taskana.exceptions.TaskAlreadyExistException)11 ClassificationService (pro.taskana.ClassificationService)10 AttachmentPersistenceException (pro.taskana.exceptions.AttachmentPersistenceException)10 ConcurrencyException (pro.taskana.exceptions.ConcurrencyException)10 InvalidOwnerException (pro.taskana.exceptions.InvalidOwnerException)10 InvalidStateException (pro.taskana.exceptions.InvalidStateException)10 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)10 SystemException (pro.taskana.exceptions.SystemException)10