Search in sources :

Example 51 with TaskService

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

the class TaskServiceImplTest method testClaimWithInvalidOwner.

@Test(expected = InvalidOwnerException.class)
public void testClaimWithInvalidOwner() throws Exception {
    TaskService cutSpy = Mockito.spy(cut);
    TaskImpl task = createUnitTestTask("1", "taskName", "wbKey", null);
    task.setState(TaskState.CLAIMED);
    task.setOwner("Max Mustermann");
    doReturn(task).when(cutSpy).getTask(task.getId());
    try {
        cutSpy.claim("1");
    } catch (Exception 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 : TaskService(pro.taskana.TaskService) 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 52 with TaskService

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

the class TaskServiceImplTest method testClaimWithInvalidState.

@Test(expected = InvalidStateException.class)
public void testClaimWithInvalidState() throws Exception {
    TaskService cutSpy = Mockito.spy(cut);
    TaskImpl task = createUnitTestTask("1", "taskName", "wbKey", null);
    task.setState(TaskState.COMPLETED);
    doReturn(task).when(cutSpy).getTask(task.getId());
    try {
        cutSpy.claim("1", true);
    } catch (Exception 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 : TaskService(pro.taskana.TaskService) 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 53 with TaskService

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

the class UpdateWorkbasketAuthorizationsAccTest method testUpdatedAccessItemLeadsToNotAuthorizedException.

@WithAccessId(userName = "user_1_1", groupNames = { "group_2", "businessadmin" })
@Test
public void testUpdatedAccessItemLeadsToNotAuthorizedException() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, ClassificationNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
    TaskService taskService = taskanaEngine.getTaskService();
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    String wbKey = "USER_2_1";
    String wbDomain = "DOMAIN_A";
    String groupName = "group_2";
    Task newTask = taskService.newTask(wbKey, wbDomain);
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    Task createdTask = taskService.createTask(newTask);
    List<TaskSummary> tasks = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain(wbKey, wbDomain)).list();
    Assert.assertEquals(1, tasks.size());
    assertThat(createdTask, not(equalTo(null)));
    List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems("WBI:100000000000000000000000000000000008");
    WorkbasketAccessItem theAccessItem = accessItems.stream().filter(x -> groupName.equals(x.getAccessId())).findFirst().orElse(null);
    Assert.assertTrue(theAccessItem != null);
    theAccessItem.setPermOpen(false);
    workbasketService.updateWorkbasketAccessItem(theAccessItem);
    try {
        taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain(wbKey, wbDomain)).list();
        fail("NotAuthorizedToQueryWorkbasketException was expected ");
    } catch (NotAuthorizedToQueryWorkbasketException ignored) {
    // nothing to do
    }
}
Also used : Task(pro.taskana.Task) WorkbasketService(pro.taskana.WorkbasketService) TaskService(pro.taskana.TaskService) WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) TaskSummary(pro.taskana.TaskSummary) NotAuthorizedToQueryWorkbasketException(pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException) KeyDomain(pro.taskana.KeyDomain) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 54 with TaskService

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

the class QueryTasksByObjectReferenceAccTest method testQueryTasksByValueLikeOfObjectReference.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testQueryTasksByValueLikeOfObjectReference() throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().primaryObjectReferenceValueLike("%567%").list();
    Assert.assertEquals(10L, results.size());
}
Also used : TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 55 with TaskService

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

the class QueryTasksByObjectReferenceAccTest method testQueryTasksByExcactValueAndTypeOfObjectReference.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "group_2" })
@Test
public void testQueryTasksByExcactValueAndTypeOfObjectReference() throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
    TaskService taskService = taskanaEngine.getTaskService();
    List<TaskSummary> results = taskService.createTaskQuery().primaryObjectReferenceTypeIn("SDNR").primaryObjectReferenceValueIn("11223344").list();
    Assert.assertEquals(10L, results.size());
}
Also used : TaskService(pro.taskana.TaskService) TaskSummary(pro.taskana.TaskSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

TaskService (pro.taskana.TaskService)102 Test (org.junit.Test)101 AbstractAccTest (acceptance.AbstractAccTest)99 WithAccessId (pro.taskana.security.WithAccessId)98 Task (pro.taskana.Task)48 TaskSummary (pro.taskana.TaskSummary)45 TaskanaEngineProxyForTest (pro.taskana.impl.TaskanaEngineProxyForTest)32 KeyDomain (pro.taskana.KeyDomain)16 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)16 Instant (java.time.Instant)13 TimeInterval (pro.taskana.TimeInterval)8 ArrayList (java.util.ArrayList)7 TaskanaException (pro.taskana.exceptions.TaskanaException)6 InvalidStateException (pro.taskana.exceptions.InvalidStateException)5 TaskNotFoundException (pro.taskana.exceptions.TaskNotFoundException)4 SqlSession (org.apache.ibatis.session.SqlSession)3 Ignore (org.junit.Ignore)3 Workbasket (pro.taskana.Workbasket)3 ConcurrencyException (pro.taskana.exceptions.ConcurrencyException)3 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)3