Search in sources :

Example 56 with WorkbasketSummary

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

the class DistributionTargetsAccTest method testSetDistributionTargets.

@WithAccessId(userName = "user_2_2", groupNames = { "group_1", "group_2", "businessadmin" })
@Test
public void testSetDistributionTargets() throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    Workbasket sourceWorkbasket = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
    List<WorkbasketSummary> initialDistributionTargets = workbasketService.getDistributionTargets(sourceWorkbasket.getId());
    assertEquals(4, initialDistributionTargets.size());
    List<WorkbasketSummary> newDistributionTargets = workbasketService.createWorkbasketQuery().keyIn("USER_1_1", "GPK_B_KSC_1").list();
    assertEquals(2, newDistributionTargets.size());
    List<String> newDistributionTargetIds = newDistributionTargets.stream().map(t -> t.getId()).collect(Collectors.toList());
    workbasketService.setDistributionTargets(sourceWorkbasket.getId(), newDistributionTargetIds);
    List<WorkbasketSummary> changedTargets = workbasketService.getDistributionTargets(sourceWorkbasket.getId());
    assertEquals(2, changedTargets.size());
    // reset DB to original state
    resetDb(false);
}
Also used : Arrays(java.util.Arrays) WithAccessId(pro.taskana.security.WithAccessId) RunWith(org.junit.runner.RunWith) AbstractAccTest(acceptance.AbstractAccTest) Assert.assertTrue(org.junit.Assert.assertTrue) InvalidWorkbasketException(pro.taskana.exceptions.InvalidWorkbasketException) Test(org.junit.Test) WorkbasketService(pro.taskana.WorkbasketService) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) WorkbasketNotFoundException(pro.taskana.exceptions.WorkbasketNotFoundException) SQLException(java.sql.SQLException) List(java.util.List) Workbasket(pro.taskana.Workbasket) JAASRunner(pro.taskana.security.JAASRunner) WorkbasketSummary(pro.taskana.WorkbasketSummary) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) Assert.fail(org.junit.Assert.fail) Assert.assertEquals(org.junit.Assert.assertEquals) WorkbasketService(pro.taskana.WorkbasketService) Workbasket(pro.taskana.Workbasket) WorkbasketSummary(pro.taskana.WorkbasketSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 57 with WorkbasketSummary

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

the class DistributionTargetsAccTest method testGetDistributionTargetsSucceedsById.

@WithAccessId(userName = "user_1_1", groupNames = { "teamlead_1" })
@Test
public void testGetDistributionTargetsSucceedsById() throws NotAuthorizedException, WorkbasketNotFoundException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    WorkbasketSummary workbasketSummary = workbasketService.createWorkbasketQuery().keyIn("GPK_KSC").single();
    List<WorkbasketSummary> retrievedDistributionTargets = workbasketService.getDistributionTargets(workbasketSummary.getId());
    assertEquals(4, retrievedDistributionTargets.size());
    List<String> expectedTargetIds = new ArrayList<>(Arrays.asList("WBI:100000000000000000000000000000000002", "WBI:100000000000000000000000000000000003", "WBI:100000000000000000000000000000000004", "WBI:100000000000000000000000000000000005"));
    for (WorkbasketSummary wbSummary : retrievedDistributionTargets) {
        assertTrue(expectedTargetIds.contains(wbSummary.getId()));
    }
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) ArrayList(java.util.ArrayList) WorkbasketSummary(pro.taskana.WorkbasketSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 58 with WorkbasketSummary

use of pro.taskana.WorkbasketSummary 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 59 with WorkbasketSummary

use of pro.taskana.WorkbasketSummary 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 60 with WorkbasketSummary

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

Aggregations

WorkbasketSummary (pro.taskana.WorkbasketSummary)66 Test (org.junit.Test)56 WorkbasketService (pro.taskana.WorkbasketService)53 AbstractAccTest (acceptance.AbstractAccTest)52 WithAccessId (pro.taskana.security.WithAccessId)51 ArrayList (java.util.ArrayList)15 Workbasket (pro.taskana.Workbasket)9 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)7 WorkbasketQuery (pro.taskana.WorkbasketQuery)5 Classification (pro.taskana.Classification)3 Task (pro.taskana.Task)3 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)3 WorkbasketNotFoundException (pro.taskana.exceptions.WorkbasketNotFoundException)3 Instant (java.time.Instant)2 Arrays (java.util.Arrays)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 PersistenceException (org.apache.ibatis.exceptions.PersistenceException)2 Ignore (org.junit.Ignore)2