Search in sources :

Example 6 with AuditReferenceValue

use of com.evolveum.midpoint.audit.api.AuditReferenceValue in project midpoint by Evolveum.

the class AuditTest method toAuditReferenceValue.

/**
 * Creates {@link AuditReferenceValue} equivalent of {@link MAuditRefValue} for comparison.
 */
private AuditReferenceValue toAuditReferenceValue(MAuditRefValue refValue) {
    AuditReferenceValue arv = new AuditReferenceValue();
    arv.setOid(refValue.oid);
    arv.setType(RUtil.stringToQName(refValue.type));
    if (refValue.targetNameOrig != null || refValue.targetNameNorm != null) {
        arv.setTargetName(new PolyString(refValue.targetNameOrig, refValue.targetNameNorm));
    }
    return arv;
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) AuditReferenceValue(com.evolveum.midpoint.audit.api.AuditReferenceValue)

Example 7 with AuditReferenceValue

use of com.evolveum.midpoint.audit.api.AuditReferenceValue in project midpoint by Evolveum.

the class AuditTest method test100AuditSimple.

@Test
public void test100AuditSimple() throws QueryException {
    OperationResult result = createOperationResult();
    when();
    AuditEventRecord record = new AuditEventRecord();
    record.addPropertyValue("prop1", "val1.1");
    record.addPropertyValue("prop1", "val1.2");
    record.addPropertyValue("prop2", "val2");
    record.addPropertyValue("prop3", null);
    AuditReferenceValue refVal1_1 = new AuditReferenceValue("oid1.1", UserType.COMPLEX_TYPE, poly("user1.1"));
    AuditReferenceValue refVal1_2 = new AuditReferenceValue("oid1.2", RoleType.COMPLEX_TYPE, poly("role1.2"));
    AuditReferenceValue refVal2 = new AuditReferenceValue("oid2", null, poly("object2"));
    AuditReferenceValue refVal3 = new AuditReferenceValue();
    record.addReferenceValue("ref1", refVal1_1);
    record.addReferenceValue("ref1", refVal1_2);
    record.addReferenceValue("ref2", refVal2);
    record.addReferenceValue("ref3", refVal3);
    logger.info("Adding audit record {}", record);
    auditService.audit(record, new NullTaskImpl(), result);
    then();
    System.out.println("Record written:\n" + record.debugDump());
    System.out.println("Repo ID: " + record.getRepoId());
    MAuditEventRecord loaded = getAuditEventRecord(1, 0);
    System.out.println("Record loaded:\n" + loaded);
    assertThat(loaded.properties).withFailMessage("Wrong # of properties").hasSize(3);
    assertThat(loaded.properties.get("prop1")).describedAs("prop1 values").containsExactlyInAnyOrder("val1.1", "val1.2");
    assertThat(loaded.properties.get("prop2")).describedAs("prop2 values").containsExactlyInAnyOrder("val2");
    assertThat(loaded.properties.get("prop3")).describedAs("prop3 values").containsExactlyInAnyOrder((String) null);
    assertThat(loaded.refValues).withFailMessage("Wrong # of references").hasSize(3);
    assertThat(loaded.refValues.get("ref1")).describedAs("ref1 values").flatExtracting(this::toAuditReferenceValue).containsExactlyInAnyOrder(refVal1_1, refVal1_2);
    assertThat(loaded.refValues.get("ref2")).describedAs("ref2 values").flatExtracting(this::toAuditReferenceValue).containsExactlyInAnyOrder(refVal2);
    assertThat(loaded.refValues.get("ref3")).describedAs("ref3 values").flatExtracting(this::toAuditReferenceValue).containsExactlyInAnyOrder(refVal3);
}
Also used : MAuditEventRecord(com.evolveum.midpoint.repo.sql.audit.beans.MAuditEventRecord) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AuditReferenceValue(com.evolveum.midpoint.audit.api.AuditReferenceValue) QAuditEventRecord(com.evolveum.midpoint.repo.sql.audit.querymodel.QAuditEventRecord) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) MAuditEventRecord(com.evolveum.midpoint.repo.sql.audit.beans.MAuditEventRecord) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) Test(org.testng.annotations.Test)

Aggregations

AuditReferenceValue (com.evolveum.midpoint.audit.api.AuditReferenceValue)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 AuditEventRecord (com.evolveum.midpoint.audit.api.AuditEventRecord)2 SQLInsertClause (com.querydsl.sql.dml.SQLInsertClause)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)1 CanonicalItemPath (com.evolveum.midpoint.prism.path.CanonicalItemPath)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 MAuditEventRecord (com.evolveum.midpoint.repo.sql.audit.beans.MAuditEventRecord)1 QAuditEventRecord (com.evolveum.midpoint.repo.sql.audit.querymodel.QAuditEventRecord)1 ROperationResultStatus (com.evolveum.midpoint.repo.sql.data.common.enums.ROperationResultStatus)1 DtoTranslationException (com.evolveum.midpoint.repo.sql.util.DtoTranslationException)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 NullTaskImpl (com.evolveum.midpoint.task.api.test.NullTaskImpl)1 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1 Timestamp (java.sql.Timestamp)1 Test (org.testng.annotations.Test)1