use of pro.taskana.WorkbasketService in project taskana by Taskana.
the class DistributionTargetsAccTest method testGetDistributionTargetsSucceeds.
@WithAccessId(userName = "user_1_1", groupNames = { "teamlead_1" })
@Test
public void testGetDistributionTargetsSucceeds() throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketSummary workbasketSummary = workbasketService.createWorkbasketQuery().keyIn("GPK_KSC").single();
List<WorkbasketSummary> retrievedDistributionTargets = workbasketService.getDistributionTargets(workbasketSummary.getKey(), workbasketSummary.getDomain());
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()));
}
}
use of pro.taskana.WorkbasketService in project taskana by Taskana.
the class DistributionTargetsAccTest method testDistributionTargetCallsFailWithNotAuthorizedException.
@WithAccessId(userName = "user_3_1", groupNames = { "group_1" })
@Test
public void testDistributionTargetCallsFailWithNotAuthorizedException() throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
String existingWb = "WBI:100000000000000000000000000000000001";
try {
workbasketService.getDistributionTargets(existingWb);
assertTrue("This line of code should not be reached", false);
} catch (NotAuthorizedException ex) {
// nothing to do
}
try {
List<String> distributionTargets = new ArrayList<>(Arrays.asList("WBI:100000000000000000000000000000000002"));
workbasketService.setDistributionTargets(existingWb, distributionTargets);
assertTrue("This line of code should not be reached", false);
} catch (NotAuthorizedException ex) {
// nothing to do
}
try {
workbasketService.addDistributionTarget(existingWb, "WBI:100000000000000000000000000000000002");
assertTrue("This line of code should not be reached", false);
} catch (NotAuthorizedException ex) {
// nothing to do
}
try {
workbasketService.removeDistributionTarget(existingWb, "WBI:100000000000000000000000000000000002");
assertTrue("This line of code should not be reached", false);
} catch (NotAuthorizedException ex) {
// nothing to do
}
}
use of pro.taskana.WorkbasketService in project taskana by Taskana.
the class DistributionTargetsAccTest method testAddAndRemoveDistributionTargets.
@WithAccessId(userName = "user_2_2", groupNames = { "group_1", "group_2", "businessadmin" })
@Test
public void testAddAndRemoveDistributionTargets() 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());
distributionTargets = workbasketService.getDistributionTargets(workbasket.getId());
assertEquals(5, distributionTargets.size());
// remove the new target
workbasketService.removeDistributionTarget(workbasket.getId(), newTarget.getId());
distributionTargets = workbasketService.getDistributionTargets(workbasket.getId());
assertEquals(4, distributionTargets.size());
// remove the new target again Question: should this throw an exception?
workbasketService.removeDistributionTarget(workbasket.getId(), newTarget.getId());
distributionTargets = workbasketService.getDistributionTargets(workbasket.getId());
assertEquals(4, distributionTargets.size());
}
use of pro.taskana.WorkbasketService 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);
}
use of pro.taskana.WorkbasketService 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()));
}
}
Aggregations