Search in sources :

Example 11 with WithAccessId

use of pro.taskana.security.WithAccessId 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 12 with WithAccessId

use of pro.taskana.security.WithAccessId 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 13 with WithAccessId

use of pro.taskana.security.WithAccessId 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 14 with WithAccessId

use of pro.taskana.security.WithAccessId 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 15 with WithAccessId

use of pro.taskana.security.WithAccessId in project taskana by Taskana.

the class DeleteTaskAccTest method testBulkDeleteTasksWithException.

@WithAccessId(userName = "user_1_2", groupNames = { "group_1" })
@Test(expected = TaskNotFoundException.class)
public void testBulkDeleteTasksWithException() throws TaskNotFoundException, InvalidArgumentException, NotAuthorizedException {
    TaskService taskService = taskanaEngine.getTaskService();
    ArrayList<String> taskIdList = new ArrayList<>();
    taskIdList.add("TKI:000000000000000000000000000000000039");
    taskIdList.add("TKI:000000000000000000000000000000000040");
    taskIdList.add("TKI:000000000000000000000000000000000028");
    BulkOperationResults<String, TaskanaException> results = taskService.deleteTasks(taskIdList);
    String expectedFailedId = "TKI:000000000000000000000000000000000028";
    assertTrue(results.containsErrors());
    List<String> failedTaskIds = results.getFailedIds();
    assertTrue(failedTaskIds.size() == 1);
    assertTrue(expectedFailedId.equals(failedTaskIds.get(0)));
    assertTrue(results.getErrorMap().get(expectedFailedId).getClass() == InvalidStateException.class);
    Task notDeletedTask = taskService.getTask("TKI:000000000000000000000000000000000028");
    assertTrue(notDeletedTask != null);
    taskService.getTask("TKI:000000000000000000000000000000000040");
}
Also used : Task(pro.taskana.Task) TaskService(pro.taskana.TaskService) ArrayList(java.util.ArrayList) InvalidStateException(pro.taskana.exceptions.InvalidStateException) TaskanaException(pro.taskana.exceptions.TaskanaException) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

Test (org.junit.Test)216 WithAccessId (pro.taskana.security.WithAccessId)216 AbstractAccTest (acceptance.AbstractAccTest)201 TaskService (pro.taskana.TaskService)100 WorkbasketService (pro.taskana.WorkbasketService)78 Task (pro.taskana.Task)57 WorkbasketSummary (pro.taskana.WorkbasketSummary)51 TaskSummary (pro.taskana.TaskSummary)47 TaskanaEngineProxyForTest (pro.taskana.impl.TaskanaEngineProxyForTest)34 Workbasket (pro.taskana.Workbasket)23 Classification (pro.taskana.Classification)21 KeyDomain (pro.taskana.KeyDomain)19 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)19 ArrayList (java.util.ArrayList)17 Instant (java.time.Instant)16 WorkbasketAccessItem (pro.taskana.WorkbasketAccessItem)16 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)15 Connection (java.sql.Connection)10 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)9 TimeInterval (pro.taskana.TimeInterval)8