Search in sources :

Example 81 with WorkbasketService

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

the class CreateWorkbasketAccTest method testCreateWorkbasketWithMissingRequiredField.

@WithAccessId(userName = "dummy", groupNames = { "businessadmin" })
@Test
public void testCreateWorkbasketWithMissingRequiredField() throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketAlreadyExistException, DomainNotFoundException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    Workbasket workbasket = workbasketService.newWorkbasket(null, "novatec");
    workbasket.setName("Megabasket");
    workbasket.setType(WorkbasketType.GROUP);
    workbasket.setOrgLevel1("company");
    try {
        // missing key
        workbasketService.createWorkbasket(workbasket);
        fail("InvalidWorkbasketException was expected");
    } catch (InvalidWorkbasketException e) {
    }
    workbasket = workbasketService.newWorkbasket("key", "novatec");
    workbasket.setType(WorkbasketType.GROUP);
    workbasket.setOrgLevel1("company");
    try {
        // missing name
        workbasketService.createWorkbasket(workbasket);
        fail("InvalidWorkbasketException was expected");
    } catch (InvalidWorkbasketException e) {
    }
    workbasket = workbasketService.newWorkbasket("key", "novatec");
    workbasket.setName("Megabasket");
    workbasket.setOrgLevel1("company");
    try {
        // missing type
        workbasketService.createWorkbasket(workbasket);
        fail("InvalidWorkbasketException was expected");
    } catch (InvalidWorkbasketException e) {
    }
    workbasket = workbasketService.newWorkbasket("key", null);
    workbasket.setName("Megabasket");
    workbasket.setType(WorkbasketType.GROUP);
    workbasket.setOrgLevel1("company");
    try {
        // missing domain
        workbasketService.createWorkbasket(workbasket);
        fail("InvalidWorkbasketException was expected");
    } catch (InvalidWorkbasketException e) {
    }
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) InvalidWorkbasketException(pro.taskana.exceptions.InvalidWorkbasketException) Workbasket(pro.taskana.Workbasket) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 82 with WorkbasketService

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

the class WorkbasketQueryAccTest method testQueryWorkbasketByBusinessAdmin.

@WithAccessId(userName = "unknown", groupNames = "businessadmin")
@Test
public void testQueryWorkbasketByBusinessAdmin() throws SQLException, NotAuthorizedException, InvalidArgumentException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery().nameLike("%").list();
    Assert.assertEquals(24L, results.size());
    results = workbasketService.createWorkbasketQuery().nameLike("%").accessIdsHavePermission(WorkbasketPermission.TRANSFER, "teamlead_1", "group_1", "group_2").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 83 with WorkbasketService

use of pro.taskana.WorkbasketService 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)

Example 84 with WorkbasketService

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

the class WorkbasketQueryAccTest 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("%").list();
    Assert.assertEquals(24L, results.size());
    results = workbasketService.createWorkbasketQuery().nameLike("%").accessIdsHavePermission(WorkbasketPermission.TRANSFER, "teamlead_1", "group_1", "group_2").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)

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