use of pro.taskana.exceptions.WorkbasketNotFoundException in project taskana by Taskana.
the class DeleteWorkbasketAccTest method testDeleteWorkbasketAlsoAsDistributionTarget.
@WithAccessId(userName = "user_1_1", groupNames = { "teamlead_1", "group_1", "businessadmin" })
@Test
public void testDeleteWorkbasketAlsoAsDistributionTarget() throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
Workbasket wb = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
int distTargets = workbasketService.getDistributionTargets("WBI:100000000000000000000000000000000001").size();
// WB deleted
workbasketService.deleteWorkbasket(wb.getId());
try {
workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
fail("There should be no result for a deleted Workbasket.");
} catch (WorkbasketNotFoundException e) {
// Workbasket is deleted
}
int newDistTargets = workbasketService.getDistributionTargets("WBI:100000000000000000000000000000000001").size();
assertThat(newDistTargets, equalTo(3));
assertTrue(newDistTargets < distTargets);
}
use of pro.taskana.exceptions.WorkbasketNotFoundException in project taskana by Taskana.
the class DeleteWorkbasketAccTest method testCreateAndDeleteWorkbasket.
@WithAccessId(userName = "user_1_2", groupNames = { "businessadmin" })
@Test
public void testCreateAndDeleteWorkbasket() 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("TheUltimate");
workbasket.setType(WorkbasketType.GROUP);
workbasket.setOrgLevel1("company");
workbasket = workbasketService.createWorkbasket(workbasket);
try {
workbasketService.deleteWorkbasket(workbasket.getId());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of pro.taskana.exceptions.WorkbasketNotFoundException 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.exceptions.WorkbasketNotFoundException 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.exceptions.WorkbasketNotFoundException in project taskana by Taskana.
the class WorkbasketServiceImpl method getWorkbasket.
@Override
public Workbasket getWorkbasket(String workbasketKey, String domain) throws WorkbasketNotFoundException, NotAuthorizedException {
LOGGER.debug("entry to getWorkbasketByKey(workbasketKey = {})", workbasketKey);
Workbasket result = null;
try {
taskanaEngine.openConnection();
result = workbasketMapper.findByKeyAndDomain(workbasketKey, domain);
if (result == null) {
LOGGER.error("Method getWorkbasketByKey() didn't find workbasket with key {}. Throwing WorkbasketNotFoundException", workbasketKey);
throw new WorkbasketNotFoundException(workbasketKey, domain, "Workbasket with key " + workbasketKey + " and domain " + domain + " was not found.");
}
if (!taskanaEngine.isUserInRole(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN)) {
this.checkAuthorization(workbasketKey, domain, WorkbasketPermission.READ);
}
return result;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from getWorkbasket(workbasketId). Returning result {} ", result);
}
}
Aggregations