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;
}
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);
}
Aggregations