Search in sources :

Example 41 with ActivationType

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

the class QAssignmentMapping method insert.

// about duplication see the comment in QObjectMapping.toRowObjectWithoutFullObject
@SuppressWarnings("DuplicatedCode")
@Override
public MAssignment insert(AssignmentType assignment, OR ownerRow, JdbcSession jdbcSession) {
    MAssignment row = initRowObject(assignment, ownerRow);
    row.lifecycleState = assignment.getLifecycleState();
    row.orderValue = assignment.getOrder();
    setReference(assignment.getOrgRef(), o -> row.orgRefTargetOid = o, t -> row.orgRefTargetType = t, r -> row.orgRefRelationId = r);
    setReference(assignment.getTargetRef(), o -> row.targetRefTargetOid = o, t -> row.targetRefTargetType = t, r -> row.targetRefRelationId = r);
    setReference(assignment.getTenantRef(), o -> row.tenantRefTargetOid = o, t -> row.tenantRefTargetType = t, r -> row.tenantRefRelationId = r);
    row.policySituations = processCacheableUris(assignment.getPolicySituation());
    row.subtypes = stringsToArray(assignment.getSubtype());
    row.ext = processExtensions(assignment.getExtension(), MExtItemHolderType.EXTENSION);
    ConstructionType construction = assignment.getConstruction();
    if (construction != null) {
        setReference(construction.getResourceRef(), o -> row.resourceRefTargetOid = o, t -> row.resourceRefTargetType = t, r -> row.resourceRefRelationId = r);
    }
    ActivationType activation = assignment.getActivation();
    if (activation != null) {
        row.administrativeStatus = activation.getAdministrativeStatus();
        row.effectiveStatus = activation.getEffectiveStatus();
        row.enableTimestamp = MiscUtil.asInstant(activation.getEnableTimestamp());
        row.disableTimestamp = MiscUtil.asInstant(activation.getDisableTimestamp());
        row.disableReason = activation.getDisableReason();
        row.validityStatus = activation.getValidityStatus();
        row.validFrom = MiscUtil.asInstant(activation.getValidFrom());
        row.validTo = MiscUtil.asInstant(activation.getValidTo());
        row.validityChangeTimestamp = MiscUtil.asInstant(activation.getValidityChangeTimestamp());
        row.archiveTimestamp = MiscUtil.asInstant(activation.getArchiveTimestamp());
    }
    MetadataType metadata = assignment.getMetadata();
    if (metadata != null) {
        setReference(metadata.getCreatorRef(), o -> row.creatorRefTargetOid = o, t -> row.creatorRefTargetType = t, r -> row.creatorRefRelationId = r);
        row.createChannelId = processCacheableUri(metadata.getCreateChannel());
        row.createTimestamp = MiscUtil.asInstant(metadata.getCreateTimestamp());
        setReference(metadata.getModifierRef(), o -> row.modifierRefTargetOid = o, t -> row.modifierRefTargetType = t, r -> row.modifierRefRelationId = r);
        row.modifyChannelId = processCacheableUri(metadata.getModifyChannel());
        row.modifyTimestamp = MiscUtil.asInstant(metadata.getModifyTimestamp());
    }
    // insert before treating sub-entities
    insert(row, jdbcSession);
    if (metadata != null) {
        storeRefs(row, metadata.getCreateApproverRef(), QAssignmentReferenceMapping.getForAssignmentCreateApprover(), jdbcSession);
        storeRefs(row, metadata.getModifyApproverRef(), QAssignmentReferenceMapping.getForAssignmentModifyApprover(), jdbcSession);
    }
    return row;
}
Also used : ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)

Example 42 with ActivationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType 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 43 with ActivationType

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

the class SqaleRepoSmokeTest method test500ExecuteQueryDiagnostics.

@Test
public void test500ExecuteQueryDiagnostics() throws Exception {
    // also known as "Query Playground"
    OperationResult result = createOperationResult();
    given("some objects are in the repository");
    String name = "user" + getTestNumber();
    repositoryService.addObject(new UserType(prismContext).name(name).activation(new ActivationType(prismContext).administrativeStatus(ActivationStatusType.ENABLED)).asPrismObject(), null, result);
    queryRecorder.clearBufferAndStartRecording();
    when("executeQueryDiagnostics is called with query");
    RepositoryQueryDiagRequest request = new RepositoryQueryDiagRequest();
    request.setType(UserType.class);
    request.setQuery(prismContext.queryFor(UserType.class).item(UserType.F_NAME).eqPoly(name).and().item(UserType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS).eq(ActivationStatusType.ENABLED).build());
    RepositoryQueryDiagResponse response = repositoryService.executeQueryDiagnostics(request, result);
    then("query is executed and low-level info returned");
    assertThat(response).isNotNull();
    assertThat(response.getQueryResult()).hasSize(1).extracting(o -> ((PrismObject<?>) o).asObjectable().getName().getOrig()).containsExactly(name);
    assertThat(response.getImplementationLevelQuery()).asString().isEqualToIgnoringWhitespace("select u.oid, u.fullObject from m_user u" + " where u.nameNorm = ? and u.nameOrig = ? and u.administrativeStatus = ?" + " limit ?");
    assertThat(queryRecorder.getQueryBuffer()).hasSize(1);
}
Also used : SkipException(org.testng.SkipException) FlexibleRelationalPathBase(com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase) com.evolveum.midpoint.schema(com.evolveum.midpoint.schema) DEFAULT_SCHEMA_NAME(com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase.DEFAULT_SCHEMA_NAME) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Jsonb(com.evolveum.midpoint.repo.sqale.jsonb.Jsonb) QOrgClosure(com.evolveum.midpoint.repo.sqale.qmodel.org.QOrgClosure) JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) 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) AfterMethod(org.testng.annotations.AfterMethod) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) AuditEventStage(com.evolveum.midpoint.audit.api.AuditEventStage) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) SQLException(java.sql.SQLException) SqlRecorder(com.evolveum.midpoint.repo.sqlbase.querydsl.SqlRecorder) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Assert(org.testng.Assert) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) DeleteObjectResult(com.evolveum.midpoint.repo.api.DeleteObjectResult) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) QObject(com.evolveum.midpoint.repo.sqale.qmodel.object.QObject) QContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UUID(java.util.UUID) PrismObject(com.evolveum.midpoint.prism.PrismObject) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) AuditEventTypeType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventTypeType) QReference(com.evolveum.midpoint.repo.sqale.qmodel.ref.QReference) AuditEventType(com.evolveum.midpoint.audit.api.AuditEventType) AuditEventStageType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventStageType) SystemException(com.evolveum.midpoint.util.exception.SystemException) Queue(java.util.Queue) PrismObject(com.evolveum.midpoint.prism.PrismObject) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 44 with ActivationType

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

the class AbstractActivationComputerTest method testGetLimboAdministrativeEnabled.

@Test
public void testGetLimboAdministrativeEnabled() {
    // GIVEN
    Clock clock = createClock(YEAR_START);
    ActivationComputer activationComputer = createActivationComputer(clock);
    ActivationType activationType = createActivationType(ActivationStatusType.ENABLED, SPRING_EQUINOX, AUTUMN_EQUINOX);
    // WHEN
    ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(LIFECYCLE_STATE_LIMBO, activationType, null);
    // THEN
    assertEquals("Unexpected effective status", ActivationStatusType.DISABLED, effectiveStatus);
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) AbstractUnitTest(com.evolveum.midpoint.tools.testng.AbstractUnitTest) Test(org.testng.annotations.Test)

Example 45 with ActivationType

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

the class AbstractActivationComputerTest method testGetActiveAdministrativeArchived.

@Test
public void testGetActiveAdministrativeArchived() throws Exception {
    // GIVEN
    Clock clock = createClock(SUMMER_SOLSTICE);
    ActivationComputer activationComputer = createActivationComputer(clock);
    ActivationType activationType = createActivationType(ActivationStatusType.ARCHIVED, SPRING_EQUINOX, AUTUMN_EQUINOX);
    // WHEN
    ActivationStatusType effectiveStatus = activationComputer.getEffectiveStatus(SchemaConstants.LIFECYCLE_ACTIVE, activationType, createLifecycleModel());
    // THEN
    assertEquals("Unexpected effective status", ActivationStatusType.ARCHIVED, effectiveStatus);
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) ActivationStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType) AbstractUnitTest(com.evolveum.midpoint.tools.testng.AbstractUnitTest) Test(org.testng.annotations.Test)

Aggregations

ActivationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType)76 Test (org.testng.annotations.Test)48 ActivationStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType)40 AbstractUnitTest (com.evolveum.midpoint.tools.testng.AbstractUnitTest)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)11 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)10 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Task (com.evolveum.midpoint.task.api.Task)9 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)7 MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)7 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)7 LockoutStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType)6 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)6 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)6 ActivationStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType)5 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)4 TimeIntervalStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType)4 ActivationLockoutStatusCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType)4 QName (javax.xml.namespace.QName)4