Search in sources :

Example 51 with ObjectDeltaOperation

use of com.evolveum.midpoint.schema.ObjectDeltaOperation in project midpoint by Evolveum.

the class AuditCleanupTest method prepareAuditRecords.

/**
 * Prepares `count` audit records with timestamp starting with specified value
 * and going up by second for each item.
 * Removes any previous audit records for consistency.
 */
private void prepareAuditRecords(long startTimestamp, int count, OperationResult result) throws SchemaException {
    clearAudit();
    long timestamp = startTimestamp;
    for (int i = 1; i <= count; i++) {
        AuditEventRecord record = new AuditEventRecord();
        record.setParameter(String.valueOf(i));
        record.setTimestamp(timestamp);
        record.getCustomColumnProperty().put("foo", "foo-value");
        // to check that child tables (delta and refs) are also cleared
        ObjectDeltaOperation<UserType> delta = new ObjectDeltaOperation<>();
        delta.setObjectDelta(prismContext.deltaFor(UserType.class).item(UserType.F_FULL_NAME).replace(PolyString.fromOrig("newVal")).asObjectDelta(UUID.randomUUID().toString()));
        record.addDelta(delta);
        record.addReferenceValue("ref1", ObjectTypeUtil.createObjectRef(UUID.randomUUID().toString(), ObjectTypes.USER).asReferenceValue());
        auditService.audit(record, NullTaskImpl.INSTANCE, result);
        timestamp += 1000;
    }
}
Also used : ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) QAuditEventRecord(com.evolveum.midpoint.repo.sqale.audit.qmodel.QAuditEventRecord) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Aggregations

ObjectDeltaOperation (com.evolveum.midpoint.schema.ObjectDeltaOperation)51 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)24 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)15 Task (com.evolveum.midpoint.task.api.Task)12 AuditEventRecord (com.evolveum.midpoint.audit.api.AuditEventRecord)11 Test (org.testng.annotations.Test)11 ArrayList (java.util.ArrayList)9 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)6 ModelProjectionContext (com.evolveum.midpoint.model.api.context.ModelProjectionContext)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)4 ModelService (com.evolveum.midpoint.model.api.ModelService)3 TestValidityRecomputeTask (com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 CommonException (com.evolveum.midpoint.util.exception.CommonException)3 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)3 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)3 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)3 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)3 AuditEventType (com.evolveum.midpoint.audit.api.AuditEventType)2