Search in sources :

Example 46 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class TestMappingTime method testAfterTimeTo.

@Test
public void testAfterTimeTo() throws Exception {
    final String TEST_NAME = "testAfterTimeTo";
    System.out.println("===[ " + TEST_NAME + "]===");
    // GIVEN
    ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), "CAPTAIN");
    Mapping.Builder<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> builder = evaluator.createMappingBuilder(MAPPING_TIME_FROM_TO_FILENAME, TEST_NAME, "title", delta);
    builder.setNow(TIME_FUTURE);
    Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = builder.build();
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
    assertNullTriple(outputTriple);
    assertNextRecompute(mapping, null);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 47 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class TestMappingTime method testSetReferenceTimeBefore.

@Test
public void testSetReferenceTimeBefore() throws Exception {
    final String TEST_NAME = "testSetReferenceTimeBefore";
    System.out.println("===[ " + TEST_NAME + "]===");
    // GIVEN
    PrismObject<UserType> userOld = evaluator.getUserOld();
    XMLGregorianCalendar disableTimestamp = userOld.asObjectable().getActivation().getDisableTimestamp();
    userOld.asObjectable().getActivation().setDisableTimestamp(null);
    ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, new ItemPath(UserType.F_ACTIVATION, ActivationType.F_DISABLE_TIMESTAMP), evaluator.getPrismContext(), disableTimestamp);
    Mapping.Builder<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> builder = evaluator.createMappingBuilder(MAPPING_TIME_ACTIVATION, TEST_NAME, "title", delta, userOld);
    builder.setNow(TIME_PAST);
    PrismPropertyDefinition<Boolean> existenceDef = new PrismPropertyDefinitionImpl<>(ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_BOOLEAN, evaluator.getPrismContext());
    builder.setDefaultTargetDefinition(existenceDef);
    Mapping<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> mapping = builder.build();
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = mapping.getOutputTriple();
    assertNullTriple(outputTriple);
    assertNextRecompute(mapping, TIME_MAPPING_DISABLED_PLUS_1M);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 48 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class TestMappingTime method testExistenceBefore.

@Test
public void testExistenceBefore() throws Exception {
    final String TEST_NAME = "testExistenceBefore";
    System.out.println("===[ " + TEST_NAME + "]===");
    // GIVEN
    Mapping.Builder<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> builder = evaluator.createMappingBuilder(MAPPING_TIME_ACTIVATION, TEST_NAME, "title", null);
    builder.setNow(TIME_PAST);
    PrismPropertyDefinition<Boolean> existenceDef = new PrismPropertyDefinitionImpl<>(ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_BOOLEAN, evaluator.getPrismContext());
    builder.setDefaultTargetDefinition(existenceDef);
    Mapping<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> mapping = builder.build();
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = mapping.getOutputTriple();
    assertNullTriple(outputTriple);
    assertNextRecompute(mapping, TIME_MAPPING_DISABLED_PLUS_1M);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 49 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class TestMappingDynamicSysVar method employeeTypeDeltaDelete.

public PrismValueDeltaSetTriple<PrismPropertyValue<String>> employeeTypeDeltaDelete(final String TEST_NAME, String delVal, String... oldVals) throws Exception {
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    ObjectDelta<UserType> delta = ObjectDelta.createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), delVal);
    Mapping<PrismPropertyValue<String>, PrismPropertyDefinition<String>> mapping = evaluator.createMapping("mapping-script-system-variables-employee-type.xml", TEST_NAME, "employeeType", delta);
    PrismObject<UserType> user = (PrismObject<UserType>) mapping.getSourceContext().getOldObject();
    setEmployeeType(user.asObjectable(), oldVals);
    mapping.getSourceContext().recompute();
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    evaluator.assertResult(opResult);
    return mapping.getOutputTriple();
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 50 with PrismPropertyValue

use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.

the class TestMappingDynamicSysVar method testScriptSystemVariablesConditionEmptyFalseToTrue.

public void testScriptSystemVariablesConditionEmptyFalseToTrue(final String TEST_NAME, String filename) throws Exception {
    System.out.println("===[ " + TEST_NAME + "]===");
    // GIVEN
    ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, evaluator.toPath("employeeNumber"), evaluator.getPrismContext());
    Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping(filename, TEST_NAME, "title", delta);
    PrismObject<UserType> user = (PrismObject<UserType>) mapping.getSourceContext().getOldObject();
    user.asObjectable().setEmployeeNumber("666");
    mapping.getSourceContext().recompute();
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
    PrismAsserts.assertTripleNoZero(outputTriple);
    PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Landlubber jack"));
    PrismAsserts.assertTripleNoMinus(outputTriple);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Aggregations

PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)176 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)93 Test (org.testng.annotations.Test)83 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)81 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)81 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)60 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)43 QName (javax.xml.namespace.QName)35 PrismObject (com.evolveum.midpoint.prism.PrismObject)29 PrismPropertyDefinitionImpl (com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl)19 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 ArrayList (java.util.ArrayList)16 Task (com.evolveum.midpoint.task.api.Task)12 ExpressionEvaluationContext (com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext)11 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)10 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)9 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)9 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)8 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)8 File (java.io.File)8