use of pro.taskana.WorkbasketAccessItem 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.WorkbasketAccessItem 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.WorkbasketAccessItem 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.WorkbasketAccessItem in project taskana by Taskana.
the class WorkbasketAccessItemMapperTest method workBasketAccessItemToModelPropertiesEqual.
@Test
public void workBasketAccessItemToModelPropertiesEqual() {
// given
WorkbasketAccessItemResource resource = new WorkbasketAccessItemResource();
resource.setAccessId("10");
resource.setAccessItemId("120");
resource.setWorkbasketId("1");
resource.setPermRead(true);
resource.setPermAppend(false);
resource.setPermDistribute(false);
resource.setPermOpen(false);
resource.setPermTransfer(true);
resource.setPermCustom1(false);
resource.setPermCustom2(false);
resource.setPermCustom3(false);
resource.setPermCustom4(false);
resource.setPermCustom5(true);
resource.setPermCustom6(false);
resource.setPermCustom7(false);
resource.setPermCustom8(false);
resource.setPermCustom9(false);
resource.setPermCustom10(false);
resource.setPermCustom11(true);
resource.setPermCustom12(false);
// when
WorkbasketAccessItem accessItem = workbasketAccessItemMapper.toModel(resource);
// then
testEquality(accessItem, resource);
}
use of pro.taskana.WorkbasketAccessItem in project taskana by Taskana.
the class WorkbasketAccessItemMapperTest method workBasketAccessItemToResourcePropertiesEqual.
@Test
public void workBasketAccessItemToResourcePropertiesEqual() throws NotAuthorizedException, WorkbasketNotFoundException {
// given
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "2");
accessItem.setPermDistribute(false);
accessItem.setPermOpen(true);
accessItem.setPermAppend(false);
accessItem.setPermRead(false);
accessItem.setPermTransfer(true);
accessItem.setPermCustom1(false);
accessItem.setPermCustom2(false);
accessItem.setPermCustom3(true);
accessItem.setPermCustom4(true);
accessItem.setPermCustom5(true);
accessItem.setPermCustom6(true);
accessItem.setPermCustom7(true);
accessItem.setPermCustom8(true);
accessItem.setPermCustom9(true);
accessItem.setPermCustom10(true);
accessItem.setPermCustom11(true);
accessItem.setPermCustom12(true);
// when
WorkbasketAccessItemResource resource = workbasketAccessItemMapper.toResource(accessItem);
// then
testEquality(accessItem, resource);
}
Aggregations