use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType in project midpoint by Evolveum.
the class CertificationTest method test270ModifyWorkItem.
@Test
public void test270ModifyWorkItem() throws Exception {
OperationResult result = new OperationResult("test270ModifyWorkItem");
PrismObject<AccessCertificationCampaignType> campaign = getFullCampaign(campaign1Oid, result);
AccessCertificationCaseType case100 = campaign.asObjectable().getCase().stream().filter(c -> c.getId() == NEW_CASE_ID).findFirst().orElseThrow(() -> new AssertionError("No case 100"));
assertEquals("Wrong # of work items in case 100", 2, case100.getWorkItem().size());
AccessCertificationWorkItemType workItem = case100.getWorkItem().stream().filter(wi -> wi.getOriginalAssigneeRef() != null).findFirst().orElse(null);
assertNotNull("No new work item", workItem);
XMLGregorianCalendar closedTimestamp = XmlTypeConverter.createXMLGregorianCalendar(new Date());
List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, NEW_CASE_ID, F_WORK_ITEM, workItem.getId(), AccessCertificationWorkItemType.F_CLOSE_TIMESTAMP).replace(closedTimestamp).asItemDeltas();
// WHEN
executeAndCheckModification(modifications, result, 0);
// THEN
checkCasesForCampaign(campaign1Oid, 8, result);
checkCasesTotal(8, result);
checkWorkItemsForCampaign(campaign1Oid, 10, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, 1, 2, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, 2, 1, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, NEW_CASE_ID, 2, result);
checkWorkItemsTotal(10, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType in project midpoint by Evolveum.
the class CertificationTest method test330ReplaceWorkItemsExistingId.
@Test
public void test330ReplaceWorkItemsExistingId() throws Exception {
OperationResult result = new OperationResult("test330ReplaceWorkItemsExistingId");
AccessCertificationWorkItemType wi200 = new AccessCertificationWorkItemType(prismContext);
//dangerous
wi200.setId(200L);
wi200.setStageNumber(44);
wi200.assigneeRef(createObjectRef("999999", ObjectTypes.USER));
List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, 6, F_WORK_ITEM).replace(wi200).asItemDeltas();
executeAndCheckModification(modifications, result, 0);
checkCasesForCampaign(campaign1Oid, 9, result);
checkCasesTotal(9, result);
checkWorkItemsForCampaign(campaign1Oid, 8, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, 1, 2, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, 2, 1, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, SECOND_NEW_CASE_ID, 1, result);
checkWorkItemsTotal(8, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType in project midpoint by Evolveum.
the class RAccessCertificationCase method toRepo.
private static RAccessCertificationCase toRepo(RAccessCertificationCase rCase, AccessCertificationCaseType case1, RepositoryContext context) throws DtoTranslationException {
// we don't try to advise hibernate - let it do its work, even if it would cost some SELECTs
rCase.setTransient(null);
rCase.setId(RUtil.toInteger(case1.getId()));
rCase.setObjectRef(RUtil.jaxbRefToEmbeddedRepoRef(case1.getObjectRef(), context.prismContext));
rCase.setTargetRef(RUtil.jaxbRefToEmbeddedRepoRef(case1.getTargetRef(), context.prismContext));
rCase.setTenantRef(RUtil.jaxbRefToEmbeddedRepoRef(case1.getTenantRef(), context.prismContext));
rCase.setOrgRef(RUtil.jaxbRefToEmbeddedRepoRef(case1.getOrgRef(), context.prismContext));
if (case1.getActivation() != null) {
RActivation activation = new RActivation();
RActivation.copyFromJAXB(case1.getActivation(), activation, context);
rCase.setActivation(activation);
}
for (AccessCertificationWorkItemType workItem : case1.getWorkItem()) {
rCase.getWorkItems().add(RAccessCertificationWorkItem.toRepo(rCase, workItem, context));
}
rCase.setReviewRequestedTimestamp(case1.getCurrentStageCreateTimestamp());
rCase.setReviewDeadline(case1.getCurrentStageDeadline());
rCase.setRemediedTimestamp(case1.getRemediedTimestamp());
rCase.setCurrentStageOutcome(case1.getCurrentStageOutcome());
rCase.setStageNumber(case1.getStageNumber());
rCase.setOutcome(case1.getOutcome());
PrismContainerValue<AccessCertificationCaseType> cvalue = case1.asPrismContainerValue();
String xml;
try {
xml = context.prismContext.xmlSerializer().serialize(cvalue, SchemaConstantsGenerated.C_VALUE);
} catch (SchemaException e) {
throw new IllegalStateException("Couldn't serialize certification case to string", e);
}
LOGGER.trace("RAccessCertificationCase full object\n{}", xml);
byte[] fullObject = RUtil.getByteArrayFromXml(xml, false);
rCase.setFullObject(fullObject);
return rCase;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType in project midpoint by Evolveum.
the class CertificationTest method addUnansweredActiveCases.
private void addUnansweredActiveCases(List<AccessCertificationCaseType> expectedCases, List<AccessCertificationCaseType> caseList, AccessCertificationCampaignType campaign) {
for (AccessCertificationCaseType aCase : caseList) {
if (aCase.getStageNumber() != campaign.getStageNumber()) {
continue;
}
if (campaign.getState() != IN_REVIEW_STAGE) {
continue;
}
boolean emptyDecisionFound = false;
for (AccessCertificationWorkItemType workItem : aCase.getWorkItem()) {
if (WorkItemTypeUtil.getOutcome(workItem) == null) {
emptyDecisionFound = true;
break;
}
}
if (emptyDecisionFound) {
LOGGER.info("Expecting case of {}:{}", campaign.getOid(), aCase.getId());
expectedCases.add(aCase);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType in project midpoint by Evolveum.
the class CertificationTest method test340ReplaceWorkItemsNewId.
@Test
public void test340ReplaceWorkItemsNewId() throws Exception {
OperationResult result = new OperationResult("test340ReplaceWorkItemsNewId");
AccessCertificationWorkItemType wi250 = new AccessCertificationWorkItemType(prismContext);
//dangerous
wi250.setId(250L);
wi250.setStageNumber(440);
wi250.assigneeRef(createObjectRef("250-999999", ObjectTypes.USER));
AccessCertificationWorkItemType wi251 = new AccessCertificationWorkItemType(prismContext);
wi251.setId(251L);
wi251.setStageNumber(1);
List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, 6, F_WORK_ITEM).replace(wi250, wi251).asItemDeltas();
// TODO counts
executeAndCheckModification(modifications, result, 0);
checkCasesForCampaign(campaign1Oid, 9, result);
checkCasesTotal(9, result);
checkWorkItemsForCampaign(campaign1Oid, 9, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, 1, 2, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, 2, 1, result);
checkWorkItemsForCampaignAndCase(campaign1Oid, SECOND_NEW_CASE_ID, 1, result);
checkWorkItemsTotal(9, result);
}
Aggregations