Search in sources :

Example 1 with NullTaskImpl

use of com.evolveum.midpoint.task.api.test.NullTaskImpl in project midpoint by Evolveum.

the class AuditTest method test110AuditSecond.

@Test
public void test110AuditSecond() throws QueryException {
    OperationResult result = createOperationResult();
    when();
    AuditEventRecord record = new AuditEventRecord();
    record.addPropertyValue("prop", "val");
    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(2, 1);
    System.out.println("Record loaded:\n" + loaded);
    assertThat(loaded.properties).describedAs("# of properties").hasSize(1);
    assertThat(loaded.properties.get("prop")).withFailMessage("Wrong prop values").containsExactlyInAnyOrder("val");
    // not initialized if nothing is there, so it's null (meaning empty)
    assertThat(loaded.refValues).describedAs("# of references").isNullOrEmpty();
}
Also used : MAuditEventRecord(com.evolveum.midpoint.repo.sql.audit.beans.MAuditEventRecord) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) 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)

Example 2 with NullTaskImpl

use of com.evolveum.midpoint.task.api.test.NullTaskImpl in project midpoint by Evolveum.

the class AuditTest method test200AuditDelta.

@Test
public void test200AuditDelta() {
    AuditEventRecord record = new AuditEventRecord();
    record.setChannel("http://midpoint.evolveum.com/xml/ns/public/common/channels-3#import");
    record.setEventIdentifier("1511974895961-0-1");
    record.setEventStage(AuditEventStage.EXECUTION);
    record.setEventType(AuditEventType.ADD_OBJECT);
    ObjectDeltaOperation<UserType> delta = new ObjectDeltaOperation<>();
    delta.setObjectDelta(prismContext.deltaFactory().object().createModificationAddReference(UserType.class, "1234", UserType.F_LINK_REF, "123"));
    record.addDelta(delta);
    delta = new ObjectDeltaOperation<>();
    delta.setObjectDelta(prismContext.deltaFactory().object().createModificationAddReference(UserType.class, "1234", UserType.F_LINK_REF, "124"));
    record.addDelta(delta);
    auditService.audit(record, new NullTaskImpl(), createOperationResult());
}
Also used : ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) 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) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) Test(org.testng.annotations.Test)

Example 3 with NullTaskImpl

use of com.evolveum.midpoint.task.api.test.NullTaskImpl in project midpoint by Evolveum.

the class MappingTestEvaluator method evaluateMapping.

public <T> PrismValueDeltaSetTriple<PrismPropertyValue<T>> evaluateMapping(String filename, String testName, String defaultTargetPropertyName) throws SchemaException, IOException, ExpressionEvaluationException, ObjectNotFoundException, EncryptionException, SecurityViolationException, ConfigurationException, CommunicationException {
    MappingImpl<PrismPropertyValue<T>, PrismPropertyDefinition<T>> mapping = createMapping(filename, testName, defaultTargetPropertyName, null);
    OperationResult opResult = new OperationResult(testName);
    mapping.evaluate(new NullTaskImpl(), opResult);
    assertResult(opResult);
    PrismValueDeltaSetTriple<PrismPropertyValue<T>> outputTriple = mapping.getOutputTriple();
    if (outputTriple != null) {
        outputTriple.checkConsistence();
    }
    return outputTriple;
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl)

Example 4 with NullTaskImpl

use of com.evolveum.midpoint.task.api.test.NullTaskImpl in project midpoint by Evolveum.

the class MappingTestEvaluator method evaluateMappingDynamicReplace.

public <T, I> PrismValueDeltaSetTriple<PrismPropertyValue<T>> evaluateMappingDynamicReplace(String filename, String testName, String defaultTargetPropertyName, String changedPropertyName, I... valuesToReplace) throws SchemaException, IOException, ExpressionEvaluationException, ObjectNotFoundException, EncryptionException, SecurityViolationException, ConfigurationException, CommunicationException {
    ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, USER_OLD_OID, toPath(changedPropertyName), valuesToReplace);
    MappingImpl<PrismPropertyValue<T>, PrismPropertyDefinition<T>> mapping = createMapping(filename, testName, defaultTargetPropertyName, userDelta);
    OperationResult opResult = new OperationResult(testName);
    mapping.evaluate(new NullTaskImpl(), opResult);
    assertResult(opResult);
    PrismValueDeltaSetTriple<PrismPropertyValue<T>> outputTriple = mapping.getOutputTriple();
    if (outputTriple != null) {
        outputTriple.checkConsistence();
    }
    return outputTriple;
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl)

Example 5 with NullTaskImpl

use of com.evolveum.midpoint.task.api.test.NullTaskImpl in project midpoint by Evolveum.

the class MappingTestEvaluator method evaluateMapping.

public <T> PrismValueDeltaSetTriple<PrismPropertyValue<T>> evaluateMapping(String filename, String testName, ItemPath defaultTargetPropertyPath) throws SchemaException, IOException, ExpressionEvaluationException, ObjectNotFoundException, EncryptionException, SecurityViolationException, ConfigurationException, CommunicationException {
    MappingImpl<PrismPropertyValue<T>, PrismPropertyDefinition<T>> mapping = createMapping(filename, testName, defaultTargetPropertyPath, null);
    OperationResult opResult = new OperationResult(testName);
    mapping.evaluate(new NullTaskImpl(), opResult);
    assertResult(opResult);
    PrismValueDeltaSetTriple<PrismPropertyValue<T>> outputTriple = mapping.getOutputTriple();
    if (outputTriple != null) {
        outputTriple.checkConsistence();
    }
    return outputTriple;
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl)

Aggregations

NullTaskImpl (com.evolveum.midpoint.task.api.test.NullTaskImpl)13 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)11 AuditEventRecord (com.evolveum.midpoint.audit.api.AuditEventRecord)5 MAuditEventRecord (com.evolveum.midpoint.repo.sql.audit.beans.MAuditEventRecord)4 QAuditEventRecord (com.evolveum.midpoint.repo.sql.audit.querymodel.QAuditEventRecord)3 Test (org.testng.annotations.Test)3 AuditReferenceValue (com.evolveum.midpoint.audit.api.AuditReferenceValue)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 UniformItemPath (com.evolveum.midpoint.prism.path.UniformItemPath)1 ObjectDeltaObject (com.evolveum.midpoint.prism.util.ObjectDeltaObject)1 DirectoryFileObjectResolver (com.evolveum.midpoint.repo.common.DirectoryFileObjectResolver)1 ObjectResolver (com.evolveum.midpoint.repo.common.ObjectResolver)1 ObjectDeltaOperation (com.evolveum.midpoint.schema.ObjectDeltaOperation)1 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1