use of pro.taskana.WorkbasketService in project taskana by Taskana.
the class UpdateWorkbasketAuthorizationsAccTest method testUpdateWorkbasketAccessItemRejected.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testUpdateWorkbasketAccessItemRejected() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1000000000000000000000000000000000000000", "user1");
accessItem.setPermAppend(true);
accessItem.setPermCustom11(true);
accessItem.setPermRead(true);
accessItem = workbasketService.createWorkbasketAccessItem(accessItem);
accessItem.setPermCustom1(true);
accessItem.setPermAppend(false);
((WorkbasketAccessItemImpl) accessItem).setAccessId("willi");
try {
workbasketService.updateWorkbasketAccessItem(accessItem);
fail("InvalidArgumentException was expected because access id was changed");
} catch (InvalidArgumentException ex) {
// nothing to do
}
((WorkbasketAccessItemImpl) accessItem).setAccessId("user1");
accessItem = workbasketService.updateWorkbasketAccessItem(accessItem);
Assert.assertEquals(false, accessItem.isPermAppend());
Assert.assertEquals(true, accessItem.isPermRead());
Assert.assertEquals(true, accessItem.isPermCustom11());
Assert.assertEquals(true, accessItem.isPermCustom1());
Assert.assertEquals(false, accessItem.isPermCustom2());
((WorkbasketAccessItemImpl) accessItem).setWorkbasketId("2");
try {
workbasketService.updateWorkbasketAccessItem(accessItem);
fail("InvalidArgumentException was expected because key was changed");
} catch (InvalidArgumentException ex) {
// nothing to do
}
}
use of pro.taskana.WorkbasketService in project taskana by Taskana.
the class UpdateWorkbasketAuthorizationsAccTest method testUpdatedAccessItemLeadsToNotAuthorizedException.
@WithAccessId(userName = "user_1_1", groupNames = { "group_2", "businessadmin" })
@Test
public void testUpdatedAccessItemLeadsToNotAuthorizedException() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, ClassificationNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
TaskService taskService = taskanaEngine.getTaskService();
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
String wbKey = "USER_2_1";
String wbDomain = "DOMAIN_A";
String groupName = "group_2";
Task newTask = taskService.newTask(wbKey, wbDomain);
newTask.setClassificationKey("T2100");
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
Task createdTask = taskService.createTask(newTask);
List<TaskSummary> tasks = taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain(wbKey, wbDomain)).list();
Assert.assertEquals(1, tasks.size());
assertThat(createdTask, not(equalTo(null)));
List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems("WBI:100000000000000000000000000000000008");
WorkbasketAccessItem theAccessItem = accessItems.stream().filter(x -> groupName.equals(x.getAccessId())).findFirst().orElse(null);
Assert.assertTrue(theAccessItem != null);
theAccessItem.setPermOpen(false);
workbasketService.updateWorkbasketAccessItem(theAccessItem);
try {
taskService.createTaskQuery().workbasketKeyDomainIn(new KeyDomain(wbKey, wbDomain)).list();
fail("NotAuthorizedToQueryWorkbasketException was expected ");
} catch (NotAuthorizedToQueryWorkbasketException ignored) {
// nothing to do
}
}
use of pro.taskana.WorkbasketService in project taskana by Taskana.
the class UpdateWorkbasketAuthorizationsAccTest method testUpdatedAccessItemList.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testUpdatedAccessItemList() throws InvalidArgumentException, NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
final String wbId = "WBI:100000000000000000000000000000000004";
List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems(wbId);
int countBefore = accessItems.size();
// update some values
WorkbasketAccessItem item0 = accessItems.get(0);
item0.setPermAppend(false);
item0.setPermOpen(false);
item0.setPermTransfer(false);
final String updateId0 = item0.getId();
WorkbasketAccessItem item1 = accessItems.get(1);
item1.setPermAppend(false);
item1.setPermOpen(false);
item1.setPermTransfer(false);
final String updateId1 = item1.getId();
workbasketService.setWorkbasketAccessItems(wbId, accessItems);
List<WorkbasketAccessItem> updatedAccessItems = workbasketService.getWorkbasketAccessItems(wbId);
int countAfter = updatedAccessItems.size();
assertThat(countAfter, equalTo(countBefore));
item0 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId0)).findFirst().get();
assertFalse(item0.isPermAppend());
assertFalse(item0.isPermOpen());
assertFalse(item0.isPermTransfer());
item1 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId1)).findFirst().get();
assertFalse(item1.isPermAppend());
assertFalse(item1.isPermOpen());
assertFalse(item1.isPermTransfer());
}
use of pro.taskana.WorkbasketService 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.WorkbasketService 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());
}
Aggregations