Search in sources :

Example 1 with AbstractWorkItemOutputType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractWorkItemOutputType 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);
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) AssertJUnit(org.testng.AssertJUnit) Arrays(java.util.Arrays) Listeners(org.testng.annotations.Listeners) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) ShadowAsserter(com.evolveum.midpoint.test.asserter.ShadowAsserter) InternalsConfig(com.evolveum.midpoint.schema.internals.InternalsConfig) AbstractWfTest(com.evolveum.midpoint.wf.impl.AbstractWfTest) HashSet(java.util.HashSet) IntegrationTestTools(com.evolveum.midpoint.test.IntegrationTestTools) TestUtil(com.evolveum.midpoint.test.util.TestUtil) ClassMode(org.springframework.test.annotation.DirtiesContext.ClassMode) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) PrismObject(com.evolveum.midpoint.prism.PrismObject) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Task(com.evolveum.midpoint.task.api.Task) Collectors(java.util.stream.Collectors) File(java.io.File) WorkItemId(com.evolveum.midpoint.schema.util.WorkItemId) List(java.util.List) MidPointConstants(com.evolveum.midpoint.schema.constants.MidPointConstants) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Optional(java.util.Optional) QName(javax.xml.namespace.QName) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractWfTest(com.evolveum.midpoint.wf.impl.AbstractWfTest)

Example 2 with AbstractWorkItemOutputType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractWorkItemOutputType in project midpoint by Evolveum.

the class CaseWorkItemAsserter method assertOutcome.

public CaseWorkItemAsserter<RA> assertOutcome(String expected) {
    AbstractWorkItemOutputType output = getWorkItem().getOutput();
    assertThat(output).as("output").isNotNull();
    MidPointAsserts.assertUriMatches(output.getOutcome(), "outcome", expected);
    return this;
}
Also used : AbstractWorkItemOutputType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractWorkItemOutputType)

Example 3 with AbstractWorkItemOutputType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractWorkItemOutputType in project midpoint by Evolveum.

the class QCaseWorkItemMapping method insert.

// about duplication see the comment in QObjectMapping.toRowObjectWithoutFullObject
@SuppressWarnings("DuplicatedCode")
@Override
public MCaseWorkItem insert(CaseWorkItemType workItem, MCase ownerRow, JdbcSession jdbcSession) {
    MCaseWorkItem row = initRowObject(workItem, ownerRow);
    row.closeTimestamp = MiscUtil.asInstant(workItem.getCloseTimestamp());
    row.createTimestamp = MiscUtil.asInstant(workItem.getCreateTimestamp());
    row.deadline = MiscUtil.asInstant(workItem.getDeadline());
    setReference(workItem.getOriginalAssigneeRef(), o -> row.originalAssigneeRefTargetOid = o, t -> row.originalAssigneeRefTargetType = t, r -> row.originalAssigneeRefRelationId = r);
    AbstractWorkItemOutputType output = workItem.getOutput();
    if (output != null) {
        row.outcome = output.getOutcome();
    }
    setReference(workItem.getPerformerRef(), o -> row.performerRefTargetOid = o, t -> row.performerRefTargetType = t, r -> row.performerRefRelationId = r);
    row.stageNumber = workItem.getStageNumber();
    insert(row, jdbcSession);
    storeRefs(row, workItem.getAssigneeRef(), QCaseWorkItemReferenceMapping.getForCaseWorkItemAssignee(), jdbcSession);
    storeRefs(row, workItem.getCandidateRef(), QCaseWorkItemReferenceMapping.getForCaseWorkItemCandidate(), jdbcSession);
    return row;
}
Also used : AbstractWorkItemOutputType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractWorkItemOutputType)

Example 4 with AbstractWorkItemOutputType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractWorkItemOutputType in project midpoint by Evolveum.

the class SqaleRepoAddDeleteObjectTest method test842AccessCertificationCampaign.

@Test
public void test842AccessCertificationCampaign() throws Exception {
    OperationResult result = createOperationResult();
    given("access certification campaign");
    String objectName = "acc" + getTestNumber();
    UUID definitionRefOid = UUID.randomUUID();
    QName definitionRefRelationUri = QName.valueOf("{https://some.uri}definition-relation");
    UUID ownerRefOid = UUID.randomUUID();
    QName ownerRefRelationUri = QName.valueOf("{https://strange.uri}owner-relation");
    Instant startTimestamp = Instant.ofEpochMilli(1234);
    Instant validFrom = Instant.ofEpochMilli(444000);
    Instant validityChangeTimestamp = Instant.ofEpochMilli(444001);
    Instant case1CurrentStageCreateTimestamp = Instant.ofEpochMilli(444333);
    Instant case2CurrentStageCreateTimestamp = Instant.ofEpochMilli(2444333);
    Instant remediedTimestamp = Instant.ofEpochMilli(444555);
    Instant currentStageDeadline = Instant.ofEpochMilli(444666);
    Instant validTo = Instant.ofEpochMilli(999000);
    Instant enableTimestamp = Instant.ofEpochMilli(555000);
    Instant disableTimestamp = Instant.ofEpochMilli(555111);
    Instant archiveTimestamp = Instant.ofEpochMilli(555123);
    Instant endTimestamp = Instant.ofEpochMilli(System.currentTimeMillis());
    String disableReason = "Whatever!";
    String case1CurrentStageOutcome = "Bada BOOM";
    String case2CurrentStageOutcome = "Big bada BOOM";
    Integer case1Iteration = 5;
    Integer case2Iteration = 15;
    UUID caseObjectRefOid = UUID.randomUUID();
    QName caseObjectRefRelationUri = QName.valueOf("{https://other.uri}case-object-ref-relation");
    UUID caseOrgRefOid = UUID.randomUUID();
    QName caseOrgRefRelationUri = QName.valueOf("{https://other.uri}case-org-ref-relation");
    String caseOutcome = "... for ever and ever";
    int caseStageNumber = 8;
    UUID caseTargetRefOid = UUID.randomUUID();
    QName caseTargetRefRelationUri = QName.valueOf("{https://some.uri}case-target-ref-relation");
    UUID caseTenantRefOid = UUID.randomUUID();
    QName caseTenantRefRelationUri = QName.valueOf("{https://some.uri}case-tenant-ref-relation");
    Instant wi1CloseTimestamp = Instant.ofEpochMilli(999123);
    Instant wi2CloseTimestamp = Instant.ofEpochMilli(2999123);
    Instant wi3CloseTimestamp = Instant.ofEpochMilli(3999123);
    Instant wi1OutputChangeTimestamp = Instant.ofEpochMilli(999001);
    Instant wi2OutputChangeTimestamp = Instant.ofEpochMilli(2999001);
    Instant wi3OutputChangeTimestamp = Instant.ofEpochMilli(3999001);
    UUID performer1Oid = UUID.randomUUID();
    QName performer1Relation = QName.valueOf("{https://random.org/ns}wi-performer1-rel");
    UUID performer2Oid = UUID.randomUUID();
    QName performer2Relation = QName.valueOf("{https://random.org/ns}wi-performer2-rel");
    UUID performer3Oid = UUID.randomUUID();
    QName performer3Relation = QName.valueOf("{https://random.org/ns}wi-performer3-rel");
    // explicit UUID, to ensure ordering
    UUID wi1AssigneeRef1Oid = UUID.fromString("7508a482-d8d1-11eb-9435-9b077bcc684b");
    QName wi1AssigneeRef1Relation = QName.valueOf("{https://random.org/ns}acwi-1-assignee-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi1AssigneeRef2Oid = UUID.fromString("77267d0c-d8d1-11eb-9ae9-8fb4530e4e64");
    QName wi1AssigneeRef2Relation = QName.valueOf("{https://random.org/ns}acwi-1-assignee-2-rel");
    // explicit UUID, to ensure ordering
    UUID wi1CandidateRef1Oid = UUID.fromString("754f391a-d8d1-11eb-b269-9b322a63128e");
    QName wi1CandidateRef1Relation = QName.valueOf("{https://random.org/ns}acwi-1-candidate-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi2AssigneeRef1Oid = UUID.fromString("75cde882-d8d1-11eb-841f-6b8c0f5075f8");
    QName wi2AssigneeRef1Relation = QName.valueOf("{https://random.org/ns}acwi-2-assignee-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi2CandidateRef1Oid = UUID.fromString("765709aa-d8d1-11eb-9340-33ef5ec6b0e2");
    QName wi2CandidateRef1Relation = QName.valueOf("{https://random.org/ns}acwi-2-candidate-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi2CandidateRef2Oid = UUID.fromString("7576bd0a-d8d1-11eb-9171-bf2238c132b7");
    QName wi2CandidateRef2Relation = QName.valueOf("{https://random.org/ns}acwi-2-candidate-2-rel");
    // explicit UUID, to ensure ordering
    UUID wi3AssigneeRef1Oid = UUID.fromString("b9f969b0-d8e4-11eb-aa14-6f0a7aff9550");
    QName wi3AssigneeRef1Relation = QName.valueOf("{https://random.org/ns}acwi-3-assignee-1-rel");
    // explicit UUID, to ensure ordering
    UUID wi3CandidateRef1Oid = UUID.fromString("bb23b638-d8e4-11eb-9601-872386b50ce3");
    QName wi3CandidateRef1Relation = QName.valueOf("{https://random.org/ns}acwi-3-candidate-1-rel");
    var accessCertificationCampaign = new AccessCertificationCampaignType(prismContext).name(objectName).definitionRef(definitionRefOid.toString(), UserType.COMPLEX_TYPE, definitionRefRelationUri).endTimestamp(MiscUtil.asXMLGregorianCalendar(endTimestamp)).handlerUri("c-handler-uri").iteration(3).ownerRef(ownerRefOid.toString(), UserType.COMPLEX_TYPE, ownerRefRelationUri).stageNumber(2).startTimestamp(MiscUtil.asXMLGregorianCalendar(startTimestamp)).state(AccessCertificationCampaignStateType.IN_REVIEW_STAGE)._case(new AccessCertificationCaseType(prismContext).id(48L).activation(new ActivationType(prismContext).administrativeStatus(ActivationStatusType.ARCHIVED).archiveTimestamp(MiscUtil.asXMLGregorianCalendar(archiveTimestamp)).disableReason(disableReason).disableTimestamp(MiscUtil.asXMLGregorianCalendar(disableTimestamp)).effectiveStatus(ActivationStatusType.DISABLED).enableTimestamp(MiscUtil.asXMLGregorianCalendar(enableTimestamp)).validFrom(MiscUtil.asXMLGregorianCalendar(validFrom)).validTo(MiscUtil.asXMLGregorianCalendar(validTo)).validityChangeTimestamp(MiscUtil.asXMLGregorianCalendar(validityChangeTimestamp)).validityStatus(TimeIntervalStatusType.IN)).currentStageOutcome(case1CurrentStageOutcome).iteration(case1Iteration).objectRef(caseObjectRefOid.toString(), ServiceType.COMPLEX_TYPE, caseObjectRefRelationUri).orgRef(caseOrgRefOid.toString(), OrgType.COMPLEX_TYPE, caseOrgRefRelationUri).outcome(caseOutcome).remediedTimestamp(MiscUtil.asXMLGregorianCalendar(remediedTimestamp)).currentStageDeadline(MiscUtil.asXMLGregorianCalendar(currentStageDeadline)).currentStageCreateTimestamp(MiscUtil.asXMLGregorianCalendar(case1CurrentStageCreateTimestamp)).stageNumber(caseStageNumber).targetRef(caseTargetRefOid.toString(), RoleType.COMPLEX_TYPE, caseTargetRefRelationUri).tenantRef(caseTenantRefOid.toString(), OrgType.COMPLEX_TYPE, caseTenantRefRelationUri).workItem(new AccessCertificationWorkItemType(prismContext).id(55L).closeTimestamp(MiscUtil.asXMLGregorianCalendar(wi1CloseTimestamp)).iteration(81).output(new AbstractWorkItemOutputType().outcome("almost, but not quite, entirely done")).outputChangeTimestamp(MiscUtil.asXMLGregorianCalendar(wi1OutputChangeTimestamp)).performerRef(performer1Oid.toString(), UserType.COMPLEX_TYPE, performer1Relation).stageNumber(21).assigneeRef(wi1AssigneeRef1Oid.toString(), UserType.COMPLEX_TYPE, wi1AssigneeRef1Relation).assigneeRef(wi1AssigneeRef2Oid.toString(), UserType.COMPLEX_TYPE, wi1AssigneeRef2Relation).candidateRef(wi1CandidateRef1Oid.toString(), UserType.COMPLEX_TYPE, wi1CandidateRef1Relation)).workItem(new AccessCertificationWorkItemType(prismContext).id(56L).closeTimestamp(MiscUtil.asXMLGregorianCalendar(wi2CloseTimestamp)).iteration(82).output(new AbstractWorkItemOutputType().outcome("A tad more than almost, but not quite, entirely done")).outputChangeTimestamp(MiscUtil.asXMLGregorianCalendar(wi2OutputChangeTimestamp)).performerRef(performer2Oid.toString(), UserType.COMPLEX_TYPE, performer2Relation).stageNumber(22).assigneeRef(wi2AssigneeRef1Oid.toString(), UserType.COMPLEX_TYPE, wi2AssigneeRef1Relation).candidateRef(wi2CandidateRef1Oid.toString(), UserType.COMPLEX_TYPE, wi2CandidateRef1Relation).candidateRef(wi2CandidateRef2Oid.toString(), OrgType.COMPLEX_TYPE, wi2CandidateRef2Relation)))._case(new AccessCertificationCaseType(prismContext).id(49L).currentStageOutcome(case2CurrentStageOutcome).iteration(case2Iteration).outcome("whatever").currentStageCreateTimestamp(MiscUtil.asXMLGregorianCalendar(case2CurrentStageCreateTimestamp)).stageNumber(25).targetRef(caseTargetRefOid.toString(), RoleType.COMPLEX_TYPE, caseTargetRefRelationUri).workItem(new AccessCertificationWorkItemType(prismContext).id(59L).closeTimestamp(MiscUtil.asXMLGregorianCalendar(wi3CloseTimestamp)).iteration(83).output(new AbstractWorkItemOutputType().outcome("certainly not quite done")).outputChangeTimestamp(MiscUtil.asXMLGregorianCalendar(wi3OutputChangeTimestamp)).performerRef(performer3Oid.toString(), UserType.COMPLEX_TYPE, performer3Relation).stageNumber(21).assigneeRef(wi3AssigneeRef1Oid.toString(), UserType.COMPLEX_TYPE, wi3AssigneeRef1Relation).candidateRef(wi3CandidateRef1Oid.toString(), OrgType.COMPLEX_TYPE, wi3CandidateRef1Relation)));
    when("adding it to the repository");
    repositoryService.addObject(accessCertificationCampaign.asPrismObject(), null, result);
    then("it is stored and relevant attributes are in columns");
    assertThatOperationResult(result).isSuccess();
    MAccessCertificationCampaign row = selectObjectByOid(QAccessCertificationCampaign.class, accessCertificationCampaign.getOid());
    assertThat(row.definitionRefTargetOid).isEqualTo(definitionRefOid);
    assertThat(row.definitionRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(row.definitionRefRelationId, definitionRefRelationUri);
    assertThat(row.endTimestamp).isEqualTo(endTimestamp);
    assertCachedUri(row.handlerUriId, "c-handler-uri");
    assertThat(row.campaignIteration).isEqualTo(3);
    assertThat(row.ownerRefTargetOid).isEqualTo(ownerRefOid);
    assertThat(row.ownerRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(row.ownerRefRelationId, ownerRefRelationUri);
    assertThat(row.stageNumber).isEqualTo(2);
    assertThat(row.startTimestamp).isEqualTo(startTimestamp);
    assertThat(row.state).isEqualTo(AccessCertificationCampaignStateType.IN_REVIEW_STAGE);
    QAccessCertificationCase caseAlias = aliasFor(QAccessCertificationCase.class);
    List<MAccessCertificationCase> caseRows = select(caseAlias, caseAlias.ownerOid.eq(UUID.fromString(accessCertificationCampaign.getOid())));
    assertThat(caseRows).hasSize(2);
    caseRows.sort(comparing(tr -> tr.cid));
    MAccessCertificationCase caseRow = caseRows.get(0);
    // assigned in advance
    assertThat(caseRow.cid).isEqualTo(48);
    assertThat(caseRow.containerType).isEqualTo(MContainerType.ACCESS_CERTIFICATION_CASE);
    assertThat(caseRow.administrativeStatus).isEqualTo(ActivationStatusType.ARCHIVED);
    assertThat(caseRow.archiveTimestamp).isEqualTo(archiveTimestamp);
    assertThat(caseRow.disableReason).isEqualTo(disableReason);
    assertThat(caseRow.disableTimestamp).isEqualTo(disableTimestamp);
    assertThat(caseRow.effectiveStatus).isEqualTo(ActivationStatusType.DISABLED);
    assertThat(caseRow.enableTimestamp).isEqualTo(enableTimestamp);
    assertThat(caseRow.validFrom).isEqualTo(validFrom);
    assertThat(caseRow.validTo).isEqualTo(validTo);
    assertThat(caseRow.validityChangeTimestamp).isEqualTo(validityChangeTimestamp);
    assertThat(caseRow.validityStatus).isEqualTo(TimeIntervalStatusType.IN);
    assertThat(caseRow.currentStageOutcome).isEqualTo(case1CurrentStageOutcome);
    assertContainerFullObject(caseRow.fullObject, accessCertificationCampaign.getCase().get(0));
    assertThat(caseRow.campaignIteration).isEqualTo(case1Iteration);
    assertThat(caseRow.objectRefTargetOid).isEqualTo(caseObjectRefOid);
    assertThat(caseRow.objectRefTargetType).isEqualTo(MObjectType.SERVICE);
    assertCachedUri(caseRow.objectRefRelationId, caseObjectRefRelationUri);
    assertThat(caseRow.orgRefTargetOid).isEqualTo(caseOrgRefOid);
    assertThat(caseRow.orgRefTargetType).isEqualTo(MObjectType.ORG);
    assertCachedUri(caseRow.orgRefRelationId, caseOrgRefRelationUri);
    assertThat(caseRow.outcome).isEqualTo(caseOutcome);
    assertThat(caseRow.remediedTimestamp).isEqualTo(remediedTimestamp);
    assertThat(caseRow.currentStageDeadline).isEqualTo(currentStageDeadline);
    assertThat(caseRow.currentStageCreateTimestamp).isEqualTo(case1CurrentStageCreateTimestamp);
    assertThat(caseRow.stageNumber).isEqualTo(caseStageNumber);
    assertThat(caseRow.targetRefTargetOid).isEqualTo(caseTargetRefOid);
    assertThat(caseRow.targetRefTargetType).isEqualTo(MObjectType.ROLE);
    assertCachedUri(caseRow.targetRefRelationId, caseTargetRefRelationUri);
    assertThat(caseRow.tenantRefTargetOid).isEqualTo(caseTenantRefOid);
    assertThat(caseRow.tenantRefTargetType).isEqualTo(MObjectType.ORG);
    assertCachedUri(caseRow.tenantRefRelationId, caseTenantRefRelationUri);
    caseRow = caseRows.get(1);
    // assigned in advance
    assertThat(caseRow.cid).isEqualTo(49);
    assertThat(caseRow.containerType).isEqualTo(MContainerType.ACCESS_CERTIFICATION_CASE);
    assertThat(caseRow.administrativeStatus).isNull();
    assertThat(caseRow.archiveTimestamp).isNull();
    assertThat(caseRow.disableReason).isNull();
    assertThat(caseRow.disableTimestamp).isNull();
    assertThat(caseRow.effectiveStatus).isNull();
    assertThat(caseRow.enableTimestamp).isNull();
    assertThat(caseRow.validFrom).isNull();
    assertThat(caseRow.validTo).isNull();
    assertThat(caseRow.validityChangeTimestamp).isNull();
    assertThat(caseRow.validityStatus).isNull();
    assertThat(caseRow.currentStageOutcome).isEqualTo(case2CurrentStageOutcome);
    assertContainerFullObject(caseRow.fullObject, accessCertificationCampaign.getCase().get(1));
    assertThat(caseRow.campaignIteration).isEqualTo(case2Iteration);
    assertThat(caseRow.objectRefTargetOid).isNull();
    assertThat(caseRow.objectRefTargetType).isNull();
    assertThat(caseRow.objectRefRelationId).isNull();
    assertThat(caseRow.orgRefTargetOid).isNull();
    assertThat(caseRow.orgRefTargetType).isNull();
    assertThat(caseRow.orgRefRelationId).isNull();
    assertThat(caseRow.outcome).isEqualTo("whatever");
    assertThat(caseRow.remediedTimestamp).isNull();
    assertThat(caseRow.currentStageDeadline).isNull();
    assertThat(caseRow.currentStageCreateTimestamp).isEqualTo(case2CurrentStageCreateTimestamp);
    assertThat(caseRow.stageNumber).isEqualTo(25);
    assertThat(caseRow.targetRefTargetOid).isEqualTo(caseTargetRefOid);
    assertThat(caseRow.targetRefTargetType).isEqualTo(MObjectType.ROLE);
    assertCachedUri(caseRow.targetRefRelationId, caseTargetRefRelationUri);
    assertThat(caseRow.tenantRefTargetOid).isNull();
    assertThat(caseRow.tenantRefTargetType).isNull();
    assertThat(caseRow.tenantRefRelationId).isNull();
    QAccessCertificationWorkItem wiAlias = aliasFor(QAccessCertificationWorkItem.class);
    List<MAccessCertificationWorkItem> wiRows = select(wiAlias, wiAlias.ownerOid.eq(UUID.fromString(accessCertificationCampaign.getOid())));
    assertThat(wiRows).hasSize(3);
    wiRows.sort(comparing(tr -> tr.cid));
    MAccessCertificationWorkItem wiRow = wiRows.get(0);
    // assigned in advance
    assertThat(wiRow.cid).isEqualTo(55);
    assertThat(wiRow.accessCertCaseCid).isEqualTo(48);
    assertThat(wiRow.containerType).isEqualTo(MContainerType.ACCESS_CERTIFICATION_WORK_ITEM);
    assertThat(wiRow.closeTimestamp).isEqualTo(wi1CloseTimestamp);
    assertThat(wiRow.campaignIteration).isEqualTo(81);
    assertThat(wiRow.outcome).isEqualTo("almost, but not quite, entirely done");
    assertThat(wiRow.outputChangeTimestamp).isEqualTo(wi1OutputChangeTimestamp);
    assertThat(wiRow.performerRefTargetOid).isEqualTo(performer1Oid);
    assertThat(wiRow.performerRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(wiRow.performerRefRelationId, performer1Relation);
    assertThat(wiRow.stageNumber).isEqualTo(21);
    wiRow = wiRows.get(1);
    // assigned in advance
    assertThat(wiRow.cid).isEqualTo(56);
    assertThat(wiRow.accessCertCaseCid).isEqualTo(48);
    assertThat(wiRow.containerType).isEqualTo(MContainerType.ACCESS_CERTIFICATION_WORK_ITEM);
    assertThat(wiRow.closeTimestamp).isEqualTo(wi2CloseTimestamp);
    assertThat(wiRow.campaignIteration).isEqualTo(82);
    assertThat(wiRow.outcome).isEqualTo("A tad more than almost, but not quite, entirely done");
    assertThat(wiRow.outputChangeTimestamp).isEqualTo(wi2OutputChangeTimestamp);
    assertThat(wiRow.performerRefTargetOid).isEqualTo(performer2Oid);
    assertThat(wiRow.performerRefTargetType).isEqualTo(MObjectType.USER);
    assertCachedUri(wiRow.performerRefRelationId, performer2Relation);
    assertThat(wiRow.stageNumber).isEqualTo(22);
    // Assignee refs
    QAccessCertificationWorkItemReference assigneeRefAlias = QAccessCertificationWorkItemReferenceMapping.getForCaseWorkItemAssignee().defaultAlias();
    List<MAccessCertificationWorkItemReference> assigneeRefRows = select(assigneeRefAlias, assigneeRefAlias.ownerOid.eq(UUID.fromString(accessCertificationCampaign.getOid())));
    assertThat(assigneeRefRows).hasSize(4);
    assigneeRefRows.sort(comparing(tr -> tr.targetOid));
    MAccessCertificationWorkItemReference assigneeRefRow = assigneeRefRows.get(0);
    assertThat(assigneeRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(assigneeRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(assigneeRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_ASSIGNEE);
    assertThat(assigneeRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(assigneeRefRow.targetOid).isEqualTo(wi3AssigneeRef1Oid);
    assertCachedUri(assigneeRefRow.relationId, wi3AssigneeRef1Relation);
    assertThat(assigneeRefRow.accessCertCaseCid).isEqualTo(49);
    assertThat(assigneeRefRow.accessCertWorkItemCid).isEqualTo(59);
    assigneeRefRow = assigneeRefRows.get(1);
    assertThat(assigneeRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(assigneeRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(assigneeRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_ASSIGNEE);
    assertThat(assigneeRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(assigneeRefRow.targetOid).isEqualTo(wi1AssigneeRef1Oid);
    assertCachedUri(assigneeRefRow.relationId, wi1AssigneeRef1Relation);
    assertThat(assigneeRefRow.accessCertCaseCid).isEqualTo(48);
    assertThat(assigneeRefRow.accessCertWorkItemCid).isEqualTo(55);
    assigneeRefRow = assigneeRefRows.get(2);
    assertThat(assigneeRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(assigneeRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(assigneeRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_ASSIGNEE);
    assertThat(assigneeRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(assigneeRefRow.targetOid).isEqualTo(wi2AssigneeRef1Oid);
    assertCachedUri(assigneeRefRow.relationId, wi2AssigneeRef1Relation);
    assertThat(assigneeRefRow.accessCertCaseCid).isEqualTo(48);
    assertThat(assigneeRefRow.accessCertWorkItemCid).isEqualTo(56);
    assigneeRefRow = assigneeRefRows.get(3);
    assertThat(assigneeRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(assigneeRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(assigneeRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_ASSIGNEE);
    assertThat(assigneeRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(assigneeRefRow.targetOid).isEqualTo(wi1AssigneeRef2Oid);
    assertCachedUri(assigneeRefRow.relationId, wi1AssigneeRef2Relation);
    assertThat(assigneeRefRow.accessCertCaseCid).isEqualTo(48);
    assertThat(assigneeRefRow.accessCertWorkItemCid).isEqualTo(55);
    // Candidate refs
    QAccessCertificationWorkItemReference candidateRefAlias = QAccessCertificationWorkItemReferenceMapping.getForCaseWorkItemCandidate().defaultAlias();
    List<MAccessCertificationWorkItemReference> candidateRefRows = select(candidateRefAlias, candidateRefAlias.ownerOid.eq(UUID.fromString(accessCertificationCampaign.getOid())));
    assertThat(candidateRefRows).hasSize(4);
    candidateRefRows.sort(comparing(tr -> tr.targetOid));
    MAccessCertificationWorkItemReference candidateRefRow = candidateRefRows.get(0);
    assertThat(candidateRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(candidateRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(candidateRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_CANDIDATE);
    assertThat(candidateRefRow.targetType).isEqualTo(MObjectType.ORG);
    assertThat(candidateRefRow.targetOid).isEqualTo(wi3CandidateRef1Oid);
    assertCachedUri(candidateRefRow.relationId, wi3CandidateRef1Relation);
    assertThat(candidateRefRow.accessCertCaseCid).isEqualTo(49);
    assertThat(candidateRefRow.accessCertWorkItemCid).isEqualTo(59);
    candidateRefRow = candidateRefRows.get(1);
    assertThat(candidateRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(candidateRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(candidateRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_CANDIDATE);
    assertThat(candidateRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(candidateRefRow.targetOid).isEqualTo(wi1CandidateRef1Oid);
    assertCachedUri(candidateRefRow.relationId, wi1CandidateRef1Relation);
    assertThat(candidateRefRow.accessCertCaseCid).isEqualTo(48);
    assertThat(candidateRefRow.accessCertWorkItemCid).isEqualTo(55);
    candidateRefRow = candidateRefRows.get(2);
    assertThat(candidateRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(candidateRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(candidateRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_CANDIDATE);
    assertThat(candidateRefRow.targetType).isEqualTo(MObjectType.ORG);
    assertThat(candidateRefRow.targetOid).isEqualTo(wi2CandidateRef2Oid);
    assertCachedUri(candidateRefRow.relationId, wi2CandidateRef2Relation);
    assertThat(candidateRefRow.accessCertCaseCid).isEqualTo(48);
    assertThat(candidateRefRow.accessCertWorkItemCid).isEqualTo(56);
    candidateRefRow = candidateRefRows.get(3);
    assertThat(candidateRefRow.ownerOid).isEqualTo(UUID.fromString(accessCertificationCampaign.getOid()));
    assertThat(candidateRefRow.ownerType).isEqualTo(MObjectType.ACCESS_CERTIFICATION_CAMPAIGN);
    assertThat(candidateRefRow.referenceType).isEqualTo(MReferenceType.ACCESS_CERT_WI_CANDIDATE);
    assertThat(candidateRefRow.targetType).isEqualTo(MObjectType.USER);
    assertThat(candidateRefRow.targetOid).isEqualTo(wi2CandidateRef1Oid);
    assertCachedUri(candidateRefRow.relationId, wi2CandidateRef1Relation);
    assertThat(candidateRefRow.accessCertCaseCid).isEqualTo(48);
    assertThat(candidateRefRow.accessCertWorkItemCid).isEqualTo(56);
}
Also used : MArchetype(com.evolveum.midpoint.repo.sqale.qmodel.role.MArchetype) MReportData(com.evolveum.midpoint.repo.sqale.qmodel.report.MReportData) com.evolveum.midpoint.repo.sqale.qmodel.object(com.evolveum.midpoint.repo.sqale.qmodel.object) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) com.evolveum.midpoint.repo.sqale.qmodel.ref(com.evolveum.midpoint.repo.sqale.qmodel.ref) QSystemConfiguration(com.evolveum.midpoint.repo.sqale.qmodel.system.QSystemConfiguration) BigDecimal(java.math.BigDecimal) DOMUtil(com.evolveum.midpoint.util.DOMUtil) Map(java.util.Map) QNode(com.evolveum.midpoint.repo.sqale.qmodel.node.QNode) BigInteger(java.math.BigInteger) MContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer) MConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnector) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) RepoAddOptions.createOverwrite(com.evolveum.midpoint.repo.api.RepoAddOptions.createOverwrite) QContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) MContainerType(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType) MFocus(com.evolveum.midpoint.repo.sqale.qmodel.focus.MFocus) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UUID(java.util.UUID) Instant(java.time.Instant) QLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.QLookupTableRow) StandardCharsets(java.nio.charset.StandardCharsets) QMessageTemplate(com.evolveum.midpoint.repo.sqale.qmodel.notification.QMessageTemplate) com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem(com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem) QGenericObject(com.evolveum.midpoint.repo.sqale.qmodel.focus.QGenericObject) MTask(com.evolveum.midpoint.repo.sqale.qmodel.task.MTask) List(java.util.List) QConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnector) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) QName(javax.xml.namespace.QName) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Jsonb(com.evolveum.midpoint.repo.sqale.jsonb.Jsonb) QResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.QResource) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.MResource) QCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.QCase) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) QConnectorHost(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnectorHost) MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) MConnectorHost(com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnectorHost) QReport(com.evolveum.midpoint.repo.sqale.qmodel.report.QReport) Comparator.comparing(java.util.Comparator.comparing) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) Containerable(com.evolveum.midpoint.prism.Containerable) MLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.MLookupTableRow) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) DeleteObjectResult(com.evolveum.midpoint.repo.api.DeleteObjectResult) MNode(com.evolveum.midpoint.repo.sqale.qmodel.node.MNode) com.evolveum.midpoint.repo.sqale.qmodel.assignment(com.evolveum.midpoint.repo.sqale.qmodel.assignment) PrismObject(com.evolveum.midpoint.prism.PrismObject) QShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.QShadow) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) SimpleExpressionUtil.velocityExpression(com.evolveum.midpoint.schema.util.SimpleExpressionUtil.velocityExpression) ChronoUnit(java.time.temporal.ChronoUnit) ItemName(com.evolveum.midpoint.prism.path.ItemName) QReportData(com.evolveum.midpoint.repo.sqale.qmodel.report.QReportData) MCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.MCase) QArchetype(com.evolveum.midpoint.repo.sqale.qmodel.role.QArchetype) SqaleRepositoryService(com.evolveum.midpoint.repo.sqale.SqaleRepositoryService) QTask(com.evolveum.midpoint.repo.sqale.qmodel.task.QTask) com.evolveum.midpoint.repo.sqale.qmodel.accesscert(com.evolveum.midpoint.repo.sqale.qmodel.accesscert) QName(javax.xml.namespace.QName) Instant(java.time.Instant) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) BigInteger(java.math.BigInteger) UUID(java.util.UUID) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 5 with AbstractWorkItemOutputType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractWorkItemOutputType in project midpoint by Evolveum.

the class AccCertCaseOperationsHelper method recordDecision.

/**
 * Records a decision. Updates necessary items like the outcomes.
 */
void recordDecision(String campaignOid, long caseId, long workItemId, AccessCertificationResponseType response, String comment, Task task, OperationResult result) throws SecurityViolationException, ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
    AccessCertificationCaseType acase = queryHelper.getCase(campaignOid, caseId, task, result);
    if (acase == null) {
        throw new ObjectNotFoundException("Case " + caseId + " was not found in campaign " + campaignOid);
    }
    AccessCertificationCampaignType campaign = CertCampaignTypeUtil.getCampaign(acase);
    if (campaign == null) {
        throw new IllegalStateException("No owning campaign present in case " + acase);
    }
    AccessCertificationWorkItemType workItem = CertCampaignTypeUtil.findWorkItem(acase, workItemId);
    if (workItem == null) {
        throw new ObjectNotFoundException("Work item " + workItemId + " was not found in campaign " + toShortString(campaign) + ", case " + caseId);
    }
    ObjectReferenceType responderRef = ObjectTypeUtil.createObjectRef(securityContextManager.getPrincipal().getFocus(), prismContext);
    XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar();
    ItemPath workItemPath = ItemPath.create(F_CASE, caseId, F_WORK_ITEM, workItemId);
    Collection<ItemDelta<?, ?>> deltaList = prismContext.deltaFor(AccessCertificationCampaignType.class).item(workItemPath.append(AccessCertificationWorkItemType.F_OUTPUT)).replace(new AbstractWorkItemOutputType().outcome(toUri(normalizeToNull(response))).comment(comment)).item(workItemPath.append(AccessCertificationWorkItemType.F_OUTPUT_CHANGE_TIMESTAMP)).replace(now).item(workItemPath.append(AccessCertificationWorkItemType.F_PERFORMER_REF)).replace(responderRef).asItemDeltas();
    // to have data for outcome computation
    ItemDeltaCollectionsUtil.applyTo(deltaList, campaign.asPrismContainerValue());
    AccessCertificationResponseType newCurrentOutcome = computationHelper.computeOutcomeForStage(acase, campaign, campaign.getStageNumber());
    AccessCertificationResponseType newOverallOutcome = computationHelper.computeOverallOutcome(acase, campaign, campaign.getStageNumber(), newCurrentOutcome);
    deltaList.addAll(prismContext.deltaFor(AccessCertificationCampaignType.class).item(F_CASE, caseId, F_CURRENT_STAGE_OUTCOME).replace(toUri(newCurrentOutcome)).item(F_CASE, caseId, F_OUTCOME).replace(toUri(newOverallOutcome)).asItemDeltas());
    updateHelper.modifyObjectPreAuthorized(AccessCertificationCampaignType.class, campaignOid, deltaList, task, result);
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 Containerable (com.evolveum.midpoint.prism.Containerable)2 ItemName (com.evolveum.midpoint.prism.path.ItemName)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 DeleteObjectResult (com.evolveum.midpoint.repo.api.DeleteObjectResult)2 RepoAddOptions.createOverwrite (com.evolveum.midpoint.repo.api.RepoAddOptions.createOverwrite)2 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)2 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)2 SqaleRepositoryService (com.evolveum.midpoint.repo.sqale.SqaleRepositoryService)2 Jsonb (com.evolveum.midpoint.repo.sqale.jsonb.Jsonb)2 com.evolveum.midpoint.repo.sqale.qmodel.accesscert (com.evolveum.midpoint.repo.sqale.qmodel.accesscert)2 com.evolveum.midpoint.repo.sqale.qmodel.assignment (com.evolveum.midpoint.repo.sqale.qmodel.assignment)2 MCase (com.evolveum.midpoint.repo.sqale.qmodel.cases.MCase)2 QCase (com.evolveum.midpoint.repo.sqale.qmodel.cases.QCase)2 com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem (com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem)2 MContainer (com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer)2 MContainerType (com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType)2 QContainer (com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer)2