use of pro.taskana.Workbasket in project taskana by Taskana.
the class DeleteWorkbasketAccTest method testDeleteWorkbasket.
@WithAccessId(userName = "teamlead_2", groupNames = { "businessadmin" })
@Test
public void testDeleteWorkbasket() throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
Workbasket wb = workbasketService.getWorkbasket("TEAMLEAD_2", "DOMAIN_A");
workbasketService.deleteWorkbasket(wb.getId());
try {
workbasketService.getWorkbasket("TEAMLEAD_2", "DOMAIN_A");
fail("There should be no result for a deleted Workbasket.");
} catch (WorkbasketNotFoundException e) {
// Workbasket is deleted
}
}
use of pro.taskana.Workbasket in project taskana by Taskana.
the class GetWorkbasketAccTest method testGetWorkbasket.
@WithAccessId(userName = "user_1_1", groupNames = { "group_1" })
@Test
public void testGetWorkbasket() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("WBI:100000000000000000000000000000000007");
Assert.assertEquals("DOMAIN_A", workbasket.getDomain());
Assert.assertEquals("PPK User 2 KSC 1", workbasket.getDescription());
Assert.assertEquals("PPK User 2 KSC 1", workbasket.getName());
Assert.assertEquals("USER_1_2", workbasket.getKey());
Assert.assertEquals(WorkbasketType.PERSONAL, workbasket.getType());
Assert.assertEquals("Peter Maier", workbasket.getOwner());
Assert.assertEquals("Versicherung", workbasket.getOrgLevel1());
}
use of pro.taskana.Workbasket 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.Workbasket 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.Workbasket 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);
}
Aggregations