Search in sources :

Example 26 with NotAuthorizedException

use of pro.taskana.exceptions.NotAuthorizedException in project taskana by Taskana.

the class QueryClassificationAccTest method testGetClassificationsForKeyAndCategories.

@Test
public void testGetClassificationsForKeyAndCategories() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
    ClassificationService classificationService = taskanaEngine.getClassificationService();
    List<ClassificationSummary> classifications = classificationService.createClassificationQuery().keyIn("T2100", "L10000").categoryIn("EXTERNAL", "MANUAL").list();
    assertNotNull(classifications);
    assertEquals(5, classifications.size());
    List<ClassificationSummary> externCategory = classifications.stream().filter(c -> c.getCategory().equals("EXTERNAL")).collect(Collectors.toList());
    assertEquals(2, externCategory.size());
    List<ClassificationSummary> manualCategory = classifications.stream().filter(c -> c.getCategory().equals("MANUAL")).collect(Collectors.toList());
    assertEquals(3, manualCategory.size());
}
Also used : SQLException(java.sql.SQLException) List(java.util.List) ClassificationNotFoundException(pro.taskana.exceptions.ClassificationNotFoundException) Assert.assertNotNull(org.junit.Assert.assertNotNull) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) Test(org.junit.Test) ClassificationSummary(pro.taskana.ClassificationSummary) Collectors(java.util.stream.Collectors) Assert.assertEquals(org.junit.Assert.assertEquals) InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) ClassificationSummary(pro.taskana.ClassificationSummary) ClassificationService(pro.taskana.ClassificationService) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test)

Example 27 with NotAuthorizedException

use of pro.taskana.exceptions.NotAuthorizedException in project taskana by Taskana.

the class WorkbasketQueryAccTest method testQueryWorkbasketByUnknownUser.

@WithAccessId(userName = "unknown")
@Test
public void testQueryWorkbasketByUnknownUser() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery().nameLike("%").list();
    Assert.assertEquals(0L, results.size());
    try {
        results = workbasketService.createWorkbasketQuery().nameLike("%").accessIdsHavePermission(WorkbasketPermission.TRANSFER, "teamlead_1", "group_1", "group_2").list();
        Assert.fail("NotAuthrorizedException was expected");
    } catch (NotAuthorizedException ex) {
    }
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) WorkbasketSummary(pro.taskana.WorkbasketSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)27 Test (org.junit.Test)15 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)12 ArrayList (java.util.ArrayList)11 AbstractAccTest (acceptance.AbstractAccTest)10 Workbasket (pro.taskana.Workbasket)9 WithAccessId (pro.taskana.security.WithAccessId)9 List (java.util.List)8 WorkbasketService (pro.taskana.WorkbasketService)8 WorkbasketNotFoundException (pro.taskana.exceptions.WorkbasketNotFoundException)8 TaskSummary (pro.taskana.TaskSummary)7 WorkbasketSummary (pro.taskana.WorkbasketSummary)7 ClassificationNotFoundException (pro.taskana.exceptions.ClassificationNotFoundException)7 InvalidWorkbasketException (pro.taskana.exceptions.InvalidWorkbasketException)7 SQLException (java.sql.SQLException)6 Collectors (java.util.stream.Collectors)5 ClassificationSummary (pro.taskana.ClassificationSummary)5 TaskService (pro.taskana.TaskService)5 TaskNotFoundException (pro.taskana.exceptions.TaskNotFoundException)5 Classification (pro.taskana.Classification)4