use of com.evolveum.midpoint.task.api.test.NullTaskImpl in project midpoint by Evolveum.
the class CleanupTest method prepareAuditEventRecords.
private void prepareAuditEventRecords() throws Exception {
Calendar calendar = create_2013_07_12_12_00_Calendar();
for (int i = 0; i < 3; i++) {
long timestamp = calendar.getTimeInMillis();
AuditEventRecord record = new AuditEventRecord();
record.addDelta(createObjectDeltaOperation(i));
record.setTimestamp(timestamp);
record.addPropertyValue("prop1", "val1");
record.addReferenceValue("ref1", ObjectTypeUtil.createObjectRef("oid1", ObjectTypes.USER).asReferenceValue());
logger.info("Adding audit record with timestamp {}", new Date(timestamp));
auditService.audit(record, new NullTaskImpl(), createOperationResult());
calendar.add(Calendar.HOUR_OF_DAY, 1);
}
assertAndReturnAuditEventRecord(3);
}
use of com.evolveum.midpoint.task.api.test.NullTaskImpl in project midpoint by Evolveum.
the class AuditCleanupPerformanceTest method prepareAuditEventRecords.
private void prepareAuditEventRecords() throws Exception {
long start = System.currentTimeMillis();
for (int i = 0; i < RECORDS; ) {
AuditEventRecord record = new AuditEventRecord();
record.addDelta(createObjectDeltaOperation(i));
record.setTimestamp(System.currentTimeMillis());
record.addPropertyValue("prop1", "val1");
record.addReferenceValue("ref1", ObjectTypeUtil.createObjectRef("oid1", ObjectTypes.USER).asReferenceValue());
auditService.audit(record, new NullTaskImpl(), new OperationResult("dummy"));
i++;
if (i % 1000 == 0 || i == RECORDS) {
long duration = System.currentTimeMillis() - start;
System.out.println(i + " records created in " + duration + " ms (" + duration / i + " ms per record)");
}
}
assertThat(count(QAuditEventRecordMapping.get())).isEqualTo(RECORDS);
}
use of com.evolveum.midpoint.task.api.test.NullTaskImpl 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