Search in sources :

Example 76 with TaskService

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

the class CreateTaskAccTest method testGetExceptionIfAppendIsNotPermitted.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test(expected = NotAuthorizedException.class)
public void testGetExceptionIfAppendIsNotPermitted() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = taskService.newTask("GPK_KSC", "DOMAIN_A");
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    taskService.createTask(newTask);
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 77 with TaskService

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

the class CreateTaskAccTest method testCreateSimpleTaskWithCustomAttributes.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testCreateSimpleTaskWithCustomAttributes() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    Map<String, String> customAttributesForCreate = createSimpleCustomProperties(13);
    newTask.setCustomAttributes(customAttributesForCreate);
    Task createdTask = taskService.createTask(newTask);
    assertNotNull(createdTask);
    assertEquals("T-Vertragstermin VERA", createdTask.getName());
    assertEquals("1234567", createdTask.getPrimaryObjRef().getValue());
    assertNotNull(createdTask.getCreated());
    assertNotNull(createdTask.getModified());
    assertNotNull(createdTask.getBusinessProcessId());
    assertEquals(null, createdTask.getClaimed());
    assertEquals(null, createdTask.getCompleted());
    assertEquals(createdTask.getCreated(), createdTask.getModified());
    assertEquals(createdTask.getCreated(), createdTask.getPlanned());
    assertEquals(TaskState.READY, createdTask.getState());
    assertEquals(null, createdTask.getParentBusinessProcessId());
    assertEquals(2, createdTask.getPriority());
    assertEquals(false, createdTask.isRead());
    assertEquals(false, createdTask.isTransferred());
    // verify that the database content is as expected
    TaskanaEngineProxyForTest engineProxy = new TaskanaEngineProxyForTest((TaskanaEngineImpl) taskanaEngine);
    try {
        SqlSession session = engineProxy.getSqlSession();
        Configuration config = session.getConfiguration();
        if (!config.hasMapper(TaskTestMapper.class)) {
            config.addMapper(TaskTestMapper.class);
        }
        TaskTestMapper mapper = session.getMapper(TaskTestMapper.class);
        engineProxy.openConnection();
        String customProperties = mapper.getCustomAttributesAsString(createdTask.getId());
        assertTrue(customProperties.contains("\"Property_13\":\"Property Value of Property_13\""));
        assertTrue(customProperties.contains("\"Property_12\":\"Property Value of Property_12\""));
        assertTrue(customProperties.contains("\"Property_11\":\"Property Value of Property_11\""));
        assertTrue(customProperties.contains("\"Property_10\":\"Property Value of Property_10\""));
        assertTrue(customProperties.contains("\"Property_9\":\"Property Value of Property_9\""));
        assertTrue(customProperties.contains("\"Property_8\":\"Property Value of Property_8\""));
        assertTrue(customProperties.contains("\"Property_7\":\"Property Value of Property_7\""));
        assertTrue(customProperties.contains("\"Property_6\":\"Property Value of Property_6\""));
        assertTrue(customProperties.contains("\"Property_5\":\"Property Value of Property_5\""));
        assertTrue(customProperties.contains("\"Property_4\":\"Property Value of Property_4\""));
        assertTrue(customProperties.contains("\"Property_3\":\"Property Value of Property_3\""));
        assertTrue(customProperties.contains("\"Property_2\":\"Property Value of Property_2\""));
        assertTrue(customProperties.contains("\"Property_1\":\"Property Value of Property_1\""));
    } finally {
        engineProxy.returnConnection();
    }
    // verify that the map is correctly retrieved from the database
    Task retrievedTask = taskService.getTask(createdTask.getId());
    Map<String, String> customAttributesFromDb = retrievedTask.getCustomAttributes();
    assertNotNull(customAttributesFromDb);
    assertTrue(customAttributesFromDb.equals(customAttributesForCreate));
}
Also used : Task(pro.taskana.Task) SqlSession(org.apache.ibatis.session.SqlSession) Configuration(org.apache.ibatis.session.Configuration) TaskService(pro.taskana.TaskService) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) TaskTestMapper(pro.taskana.mappings.TaskTestMapper) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 78 with TaskService

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

the class CreateTaskAccTest method testThrowsExceptionIfAttachmentIsInvalid.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testThrowsExceptionIfAttachmentIsInvalid() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = makeNewTask(taskService);
    newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", null, "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
    try {
        taskService.createTask(newTask);
        fail("Should have thrown an InvalidArgumentException, becasue Attachment-ObjRef is null.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    newTask = makeNewTask(taskService);
    newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", "ArchiveId", null), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
    try {
        taskService.createTask(newTask);
        fail("Should have thrown an InvalidArgumentException, becasue ObjRef-Value is null.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    newTask = makeNewTask(taskService);
    newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", "INSTANCE_B", null, "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
    try {
        taskService.createTask(newTask);
        fail("Should have thrown an InvalidArgumentException, becasue ObjRef-Type is null.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    newTask = makeNewTask(taskService);
    newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", "SYSTEM_B", null, "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
    try {
        taskService.createTask(newTask);
        fail("Should have thrown an InvalidArgumentException, becasue ObjRef-SystemInstance is null.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    newTask = makeNewTask(taskService);
    newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference("COMPANY_A", null, "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
    try {
        taskService.createTask(newTask);
        fail("Should have thrown an InvalidArgumentException, becasue ObjRef-System is null.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
    newTask = makeNewTask(taskService);
    newTask.addAttachment(createAttachment("DOCTYPE_DEFAULT", createObjectReference(null, "SYSTEM_B", "INSTANCE_B", "ArchiveId", "12345678901234567890123456789012345678901234567890"), "E-MAIL", "2018-01-15", createSimpleCustomProperties(3)));
    try {
        taskService.createTask(newTask);
        fail("Should have thrown an InvalidArgumentException, becasue ObjRef-Company is null.");
    } catch (InvalidArgumentException ex) {
    // nothing to do
    }
}
Also used : Task(pro.taskana.Task) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) TaskService(pro.taskana.TaskService) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 79 with TaskService

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

the class CreateTaskAccTest method testUseCustomNameIfSetForNewTask.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testUseCustomNameIfSetForNewTask() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    newTask.setName("Test Name");
    Task createdTask = taskService.createTask(newTask);
    assertNotNull(createdTask);
    assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
    assertEquals("Test Name", createdTask.getName());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 80 with TaskService

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

the class CreateTaskAccTest method testCreateSimpleManualTask.

@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testCreateSimpleManualTask() throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
    TaskService taskService = taskanaEngine.getTaskService();
    Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
    newTask.setClassificationKey("T2100");
    newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
    Task createdTask = taskService.createTask(newTask);
    assertNotNull(createdTask);
    assertThat(createdTask.getCreator(), equalTo(CurrentUserContext.getUserid()));
    assertEquals("T-Vertragstermin VERA", createdTask.getName());
    assertEquals("1234567", createdTask.getPrimaryObjRef().getValue());
    assertNotNull(createdTask.getCreated());
    assertNotNull(createdTask.getModified());
    assertNotNull(createdTask.getBusinessProcessId());
    assertEquals(null, createdTask.getClaimed());
    assertEquals(null, createdTask.getCompleted());
    assertEquals(createdTask.getCreated(), createdTask.getModified());
    assertEquals(createdTask.getCreated(), createdTask.getPlanned());
    assertEquals(TaskState.READY, createdTask.getState());
    assertEquals(null, createdTask.getParentBusinessProcessId());
    assertEquals(2, createdTask.getPriority());
    assertEquals(false, createdTask.isRead());
    assertEquals(false, createdTask.isTransferred());
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) 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