Search in sources :

Example 26 with WorkbasketService

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

the class DistributionTargetsAccTest method testQueryDistributionSourcesThrowsNotAuthorized.

@WithAccessId(userName = "henry", groupNames = { "undefinedgroup" })
@Test(expected = NotAuthorizedException.class)
public void testQueryDistributionSourcesThrowsNotAuthorized() throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    List<WorkbasketSummary> distributionSources = workbasketService.getDistributionSources("WBI:100000000000000000000000000000000004");
    assertEquals(2, distributionSources.size());
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) WorkbasketSummary(pro.taskana.WorkbasketSummary) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 27 with WorkbasketService

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

the class DistributionTargetsAccTest method testGetDistributionSourcesById.

@WithAccessId(userName = "user_2_2", groupNames = { "group_1", "group_2" })
@Test
public void testGetDistributionSourcesById() throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    List<WorkbasketSummary> distributionSources = workbasketService.getDistributionSources("WBI:100000000000000000000000000000000004");
    assertEquals(2, distributionSources.size());
    List<String> expectedIds = new ArrayList<>(Arrays.asList("WBI:100000000000000000000000000000000001", "WBI:100000000000000000000000000000000002"));
    for (WorkbasketSummary foundSummary : distributionSources) {
        assertTrue(expectedIds.contains(foundSummary.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 28 with WorkbasketService

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

the class DistributionTargetsAccTest method testDistributionTargetCallsWithNonExistingWorkbaskets.

@WithAccessId(userName = "user_1_1", groupNames = { "teamlead_1", "group_1", "group_2", "businessadmin" })
@Test
public void testDistributionTargetCallsWithNonExistingWorkbaskets() throws NotAuthorizedException, WorkbasketNotFoundException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    String existingWb = "WBI:100000000000000000000000000000000001";
    String nonExistingWb = "WBI:100000000000000000000000000000000xx1";
    try {
        workbasketService.getDistributionTargets("WBI:100000000000000000000000000000000xx1");
        assertTrue("This line of code should not be reached", false);
    } catch (WorkbasketNotFoundException ex) {
    // nothing to do
    }
    try {
        List<String> distributionTargets = new ArrayList<>(Arrays.asList(nonExistingWb));
        workbasketService.setDistributionTargets(existingWb, distributionTargets);
        assertTrue("This line of code should not be reached", false);
    } catch (WorkbasketNotFoundException ex) {
    // nothing to do
    }
    try {
        workbasketService.addDistributionTarget(existingWb, nonExistingWb);
        assertTrue("This line of code should not be reached", false);
    } catch (WorkbasketNotFoundException ex) {
    // nothing to do
    }
    int beforeCount = workbasketService.getDistributionTargets(existingWb).size();
    workbasketService.removeDistributionTarget(existingWb, nonExistingWb);
    int afterCount = workbasketService.getDistributionTargets(existingWb).size();
    assertEquals(afterCount, beforeCount);
}
Also used : WorkbasketService(pro.taskana.WorkbasketService) ArrayList(java.util.ArrayList) WorkbasketNotFoundException(pro.taskana.exceptions.WorkbasketNotFoundException) AbstractAccTest(acceptance.AbstractAccTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 29 with WorkbasketService

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

the class DistributionTargetsAccTest method testAddDistributionTargetsFailsNotAuthorized.

@WithAccessId(userName = "user_2_2", groupNames = { "group_1", "group_2" })
@Test(expected = NotAuthorizedException.class)
public void testAddDistributionTargetsFailsNotAuthorized() throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
    List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(workbasket.getId());
    assertEquals(4, distributionTargets.size());
    // add a new distribution target
    Workbasket newTarget = workbasketService.getWorkbasket("GPK_B_KSC_2", "DOMAIN_B");
    workbasketService.addDistributionTarget(workbasket.getId(), newTarget.getId());
    fail("NotAuthorizedException should have been thrown");
}
Also used : 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 30 with WorkbasketService

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

the class DistributionTargetsAccTest method testGetDistributionSourcesByKeyDomain.

@WithAccessId(userName = "user_2_2", groupNames = { "group_1", "group_2" })
@Test
public void testGetDistributionSourcesByKeyDomain() throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {
    WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
    List<WorkbasketSummary> distributionSources = workbasketService.getDistributionSources("TEAMLEAD_1", "DOMAIN_A");
    assertEquals(2, distributionSources.size());
    List<String> expectedIds = new ArrayList<>(Arrays.asList("WBI:100000000000000000000000000000000001", "WBI:100000000000000000000000000000000002"));
    for (WorkbasketSummary foundSummary : distributionSources) {
        assertTrue(expectedIds.contains(foundSummary.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)

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