Search in sources :

Example 76 with WorkbasketService

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

the class QueryWorkbasketAccTest method testQueryAllForAdminMultipleTimes.

@WithAccessId(userName = "teamlead_1", groupNames = { "admin" })
@Test
public void testQueryAllForAdminMultipleTimes() {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    WorkbasketQuery query = workbasketService.createWorkbasketQuery();
    long count = query.count();
    assertTrue(count == 24);
    List<WorkbasketSummary> workbaskets = query.list();
    assertNotNull(workbaskets);
    assertEquals(count, workbaskets.size());
    workbaskets = query.list();
    assertNotNull(workbaskets);
    assertEquals(count, workbaskets.size());
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) WorkbasketQuery(pro.taskana.WorkbasketQuery) WorkbasketSummary(pro.taskana.WorkbasketSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 77 with WorkbasketService

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

the class QueryWorkbasketAccTest method testQueryAllForUserMultipleTimes.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1_1" })
@Test
public void testQueryAllForUserMultipleTimes() {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    WorkbasketQuery query = workbasketService.createWorkbasketQuery();
    long count = query.count();
    assertEquals(3, count);
    List<WorkbasketSummary> workbaskets = query.list();
    assertNotNull(workbaskets);
    assertEquals(count, workbaskets.size());
    workbaskets = query.list();
    assertNotNull(workbaskets);
    assertEquals(count, workbaskets.size());
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) WorkbasketQuery(pro.taskana.WorkbasketQuery) WorkbasketSummary(pro.taskana.WorkbasketSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 78 with WorkbasketService

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

the class QueryWorkbasketAccTest method testQueryWorkbasketByDomain.

@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryWorkbasketByDomain() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_B").list();
    Assert.assertEquals(1L, results.size());
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) WorkbasketSummary(pro.taskana.WorkbasketSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 79 with WorkbasketService

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

the class QueryWorkbasketAccTest method testQueryWorkbasketByAdmin.

@WithAccessId(userName = "unknown", groupNames = "admin")
@Test
public void testQueryWorkbasketByAdmin() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery().nameLike("%").orderByName(desc).list();
    Assert.assertEquals(24L, results.size());
    // check sort order is correct
    WorkbasketSummary previousSummary = null;
    for (WorkbasketSummary wbSummary : results) {
        if (previousSummary != null) {
            Assert.assertTrue(wbSummary.getName().compareToIgnoreCase(previousSummary.getName()) <= 0);
        }
        previousSummary = wbSummary;
    }
    results = workbasketService.createWorkbasketQuery().nameLike("%").accessIdsHavePermission(WorkbasketPermission.TRANSFER, "teamlead_1", "group_1", "group_2").orderByName(desc).list();
    Assert.assertEquals(13L, results.size());
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) WorkbasketSummary(pro.taskana.WorkbasketSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 80 with WorkbasketService

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

the class CreateWorkbasketAccTest method testCreateWorkbasket.

@WithAccessId(userName = "user_1_2", groupNames = { "businessadmin" })
@Test
public void testCreateWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
    Workbasket workbasket = workbasketService.newWorkbasket("NT1234", "DOMAIN_A");
    workbasket.setName("Megabasket");
    workbasket.setType(WorkbasketType.GROUP);
    workbasket.setOrgLevel1("company");
    workbasket = workbasketService.createWorkbasket(workbasket);
    WorkbasketAccessItem wbai = workbasketService.newWorkbasketAccessItem(workbasket.getId(), "user_1_2");
    wbai.setPermRead(true);
    workbasketService.createWorkbasketAccessItem(wbai);
    int after = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
    assertEquals(before + 1, after);
    Workbasket createdWorkbasket = workbasketService.getWorkbasket("NT1234", "DOMAIN_A");
    assertNotNull(createdWorkbasket);
    assertNotNull(createdWorkbasket.getId());
    Workbasket createdWorkbasket2 = workbasketService.getWorkbasket(createdWorkbasket.getId());
    assertNotNull(createdWorkbasket);
    assertEquals(createdWorkbasket, createdWorkbasket2);
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) WorkbasketAccessItem(pro.taskana.WorkbasketAccessItem) Workbasket(pro.taskana.Workbasket) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

AbstractAccTest (acceptance.AbstractAccTest)84 Test (org.junit.Test)84 WorkbasketService (pro.taskana.WorkbasketService)84 WithAccessId (pro.taskana.security.WithAccessId)78 WorkbasketSummary (pro.taskana.WorkbasketSummary)52 Workbasket (pro.taskana.Workbasket)12 WorkbasketAccessItem (pro.taskana.WorkbasketAccessItem)11 ArrayList (java.util.ArrayList)8 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)7 InvalidWorkbasketException (pro.taskana.exceptions.InvalidWorkbasketException)5 WorkbasketNotFoundException (pro.taskana.exceptions.WorkbasketNotFoundException)5 SQLException (java.sql.SQLException)4 Task (pro.taskana.Task)4 TaskService (pro.taskana.TaskService)4 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)4 List (java.util.List)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 Assert.fail (org.junit.Assert.fail)3 Ignore (org.junit.Ignore)3 RunWith (org.junit.runner.RunWith)3