use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.
the class ManualResourceTest method test110CloseCaseAndRecomputeWill.
/**
* Case is closed. The operation is complete.
*/
@Test
public void test110CloseCaseAndRecomputeWill() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = getTestOperationResult();
dummyAuditService.clear();
dummyTransport.clearMessages();
// WHEN
when();
CaseType caseBefore = getCase(willLastCaseOid);
display("Case before work item completion", caseBefore);
List<CaseWorkItemType> workItems = caseBefore.getWorkItem();
assertEquals("Wrong # of work items", 2, workItems.size());
assertEquals("Wrong assignees", new HashSet<>(Arrays.asList(USER_ADMINISTRATOR_OID, userJackOid)), workItems.stream().map(wi -> wi.getOriginalAssigneeRef().getOid()).collect(Collectors.toSet()));
Optional<CaseWorkItemType> adminWorkItem = workItems.stream().filter(wi -> USER_ADMINISTRATOR_OID.equals(wi.getOriginalAssigneeRef().getOid())).findAny();
assertTrue("no admin work item", adminWorkItem.isPresent());
caseManager.completeWorkItem(WorkItemId.of(adminWorkItem.get()), new AbstractWorkItemOutputType(prismContext).outcome(OperationResultStatusType.SUCCESS.value()), null, task, result);
accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar();
// We need reconcile and not recompute here. We need to fetch the updated case status.
reconcileUser(userWillOid, task, result);
// THEN
then();
assertSuccess(result);
CaseType caseAfter = getCase(willLastCaseOid);
display("Case after work item completion", caseAfter);
accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar();
assertWillAfterCreateCaseClosed();
displayDumpable("dummy audit", dummyAuditService);
displayDumpable("dummy transport", dummyTransport);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.
the class TestSoD method test030AssignRoleRespectable.
/**
* Assign Respectable to jack. This should trigger an approval as well (because it implies a Thief).
*/
@Test
public void test030AssignRoleRespectable() throws Exception {
login(userAdministrator);
Task task = getTestTask();
OperationResult result = getTestOperationResult();
// GIVEN
unassignRole(userJackOid, rolePirateOid, task, result);
assertNotAssignedRole(userJackOid, rolePirateOid, result);
// WHEN+THEN
PrismObject<UserType> jack = getUser(userJackOid);
ObjectDelta<UserType> addRespectableDelta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).add(createAssignmentTo(roleRespectableOid, ObjectTypes.ROLE, prismContext)).asObjectDelta(userJackOid);
// WHEN+THEN
executeTest2(new TestDetails2<UserType>() {
@Override
protected PrismObject<UserType> getFocus(OperationResult result) {
return jack.clone();
}
@Override
protected ObjectDelta<UserType> getFocusDelta() {
return addRespectableDelta.clone();
}
@Override
protected int getNumberOfDeltasToApprove() {
return 1;
}
@Override
protected List<Boolean> getApprovals() {
return Collections.singletonList(true);
}
@Override
protected List<ObjectDelta<UserType>> getExpectedDeltasToApprove() {
return Arrays.asList(addRespectableDelta.clone());
}
@Override
protected ObjectDelta<UserType> getExpectedDelta0() {
// return ObjectDelta.createEmptyModifyDelta(UserType.class, jack.getOid(), prismContext);
return prismContext.deltaFactory().object().createModifyDelta(jack.getOid(), Collections.emptyList(), UserType.class);
}
@Override
protected String getObjectOid() {
return jack.getOid();
}
@Override
protected List<ExpectedTask> getExpectedTasks() {
return Collections.singletonList(new ExpectedTask(roleRespectableOid, "Role \"Thief\" (Respectable -> Thief) excludes role \"Judge\""));
}
@Override
protected List<ExpectedWorkItem> getExpectedWorkItems() {
List<ExpectedTask> etasks = getExpectedTasks();
return Collections.singletonList(new ExpectedWorkItem(userSodApproverOid, roleRespectableOid, etasks.get(0)));
}
@Override
protected void assertDeltaExecuted(int number, boolean yes, Task opTask, OperationResult result) throws Exception {
switch(number) {
case 1:
if (yes) {
assertAssignedRole(userJackOid, roleRespectableOid, result);
} else {
assertNotAssignedRole(userJackOid, roleRespectableOid, result);
}
break;
}
}
@Override
protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Exception {
login(getUser(userSodApproverOid));
return true;
}
}, 1, false);
// THEN
display("jack as a Judge + Respectable", getUser(userJackOid));
assertAssignedRole(userJackOid, roleJudgeOid, result);
assertAssignedRole(userJackOid, roleRespectableOid, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.
the class TestSoD method test020AssignRolePirate.
/**
* Assign Pirate to jack. This should trigger an approval.
*/
@Test
public void test020AssignRolePirate() throws Exception {
given();
login(userAdministrator);
OperationResult result = getTestOperationResult();
PrismObject<UserType> jack = getUser(userJackOid);
String originalDescription = jack.asObjectable().getDescription();
ObjectDelta<UserType> addPirateDelta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).add(createAssignmentTo(rolePirateOid, ObjectTypes.ROLE, prismContext)).asObjectDelta(userJackOid);
ObjectDelta<UserType> changeDescriptionDelta = prismContext.deltaFor(UserType.class).item(UserType.F_DESCRIPTION).replace("Pirate Judge").asObjectDelta(userJackOid);
ObjectDelta<UserType> primaryDelta = ObjectDeltaCollectionsUtil.summarize(addPirateDelta, changeDescriptionDelta);
when();
executeTest2(new TestDetails2<UserType>() {
@Override
protected PrismObject<UserType> getFocus(OperationResult result) {
return jack.clone();
}
@Override
protected ObjectDelta<UserType> getFocusDelta() {
return primaryDelta.clone();
}
@Override
protected int getNumberOfDeltasToApprove() {
return 1;
}
@Override
protected List<Boolean> getApprovals() {
return Collections.singletonList(true);
}
@Override
protected List<ObjectDelta<UserType>> getExpectedDeltasToApprove() {
return Collections.singletonList(addPirateDelta.clone());
}
@Override
protected ObjectDelta<UserType> getExpectedDelta0() {
return changeDescriptionDelta.clone();
}
@Override
protected String getObjectOid() {
return jack.getOid();
}
@Override
protected List<ExpectedTask> getExpectedTasks() {
return Collections.singletonList(new ExpectedTask(rolePirateOid, "Role \"Pirate\" excludes role \"Judge\""));
}
@Override
protected List<ExpectedWorkItem> getExpectedWorkItems() {
List<ExpectedTask> etasks = getExpectedTasks();
return Collections.singletonList(new ExpectedWorkItem(userSodApproverOid, rolePirateOid, etasks.get(0)));
}
@Override
protected void assertDeltaExecuted(int number, boolean yes, Task opTask, OperationResult result) throws Exception {
switch(number) {
case 0:
if (yes) {
assertUserProperty(userJackOid, UserType.F_DESCRIPTION, "Pirate Judge");
} else {
if (originalDescription != null) {
assertUserProperty(userJackOid, UserType.F_DESCRIPTION, originalDescription);
} else {
assertUserNoProperty(userJackOid, UserType.F_DESCRIPTION);
}
}
break;
case 1:
if (yes) {
assertAssignedRole(userJackOid, rolePirateOid, result);
} else {
assertNotAssignedRole(userJackOid, rolePirateOid, result);
}
break;
}
}
@Override
protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Exception {
login(getUser(userSodApproverOid));
return true;
}
}, 1, false);
then();
display("jack as a Pirate + Judge", getUser(userJackOid));
AssignmentType judgeAssignment = assertAssignedRole(userJackOid, roleJudgeOid, result);
assertExclusionViolationSituation(judgeAssignment);
AssignmentType pirateAssignment = assertAssignedRole(userJackOid, rolePirateOid, result);
assertExclusionViolationSituation(pirateAssignment);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.
the class RCase method copyFromJAXB.
// dynamically called
public static void copyFromJAXB(CaseType jaxb, RCase repo, RepositoryContext context, IdGeneratorResult generatorResult) throws DtoTranslationException {
copyAssignmentHolderInformationFromJAXB(jaxb, repo, context, generatorResult);
repo.setNameCopy(RPolyString.copyFromJAXB(jaxb.getName()));
repo.setParentRef(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getParentRef(), context.relationRegistry));
repo.setObjectRef(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getObjectRef(), context.relationRegistry));
repo.setTargetRef(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getTargetRef(), context.relationRegistry));
repo.setRequestorRef(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getRequestorRef(), context.relationRegistry));
repo.setCloseTimestamp(jaxb.getCloseTimestamp());
repo.setState(jaxb.getState());
for (CaseWorkItemType workItem : jaxb.getWorkItem()) {
repo.getWorkItems().add(RCaseWorkItem.toRepo(repo, workItem, context));
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.
the class AbstractManualResourceTest method test231CaseHasExpectedNumbersOfWorkItemsWithExpectedAssignees.
// This no longer works as the work item creation is now done in cases-impl module
@Test(enabled = false)
public void test231CaseHasExpectedNumbersOfWorkItemsWithExpectedAssignees() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
syncServiceMock.reset();
int expectedNumberOfWorkItems = 3;
List<String> expectedWorkItemsAssigneesOids = Stream.of(USER_OPERATOR_ROLE_MEMBER_OID, USER_OPERATOR_OID, USER_OPERATOR_ORG_MEMBER_OID).sorted(String::compareToIgnoreCase).collect(Collectors.toList());
CaseType caseType = repositoryService.getObject(CaseType.class, willLastCaseOid, null, result).asObjectable();
List<String> actualWorkItemsAssigneesOids = caseType.getWorkItem().stream().flatMap(caseWorkItemType -> caseWorkItemType.getAssigneeRef().stream()).map(ObjectReferenceType::getOid).sorted(String::compareToIgnoreCase).collect(Collectors.toList());
int actualNumberOfWorkItems = caseType.getWorkItem().size();
assertEquals(expectedNumberOfWorkItems, actualNumberOfWorkItems);
assertEquals(expectedWorkItemsAssigneesOids, actualWorkItemsAssigneesOids);
}
Aggregations