Search in sources :

Example 16 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 17 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)

Example 18 with PrismPropertyValue

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

the class TestMappingDynamicSysVar method testEmployeeNumberPolyString.

@Test
public void testEmployeeNumberPolyString() throws Exception {
    final String TEST_NAME = "testEmployeeNumberPolyString";
    System.out.println("===[ " + TEST_NAME + "]===");
    // WHEN
    PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = evaluator.evaluateMappingDynamicReplace("mapping-script-system-variables-employee-number.xml", TEST_NAME, // target
    "additionalName", // changed property
    "employeeNumber", // changed values
    "666");
    // THEN
    PrismAsserts.assertTripleNoZero(outputTriple);
    PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("666"));
    PrismAsserts.assertTripleNoMinus(outputTriple);
    // Make sure it is recomputed
    PolyString plusval = outputTriple.getPlusSet().iterator().next().getValue();
    System.out.println("Plus polystring\n" + plusval.debugDump());
    assertEquals("Wrong norm value", "666", plusval.getNorm());
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 19 with PrismPropertyValue

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

the class TestMappingDynamicSysVar method testScriptSystemVariablesConditionAddObjectFalse.

public void testScriptSystemVariablesConditionAddObjectFalse(String filename) throws Exception {
    // GIVEN
    final String TEST_NAME = "testScriptSystemVariablesConditionAddObjectFalse";
    System.out.println("===[ " + TEST_NAME + "]===");
    PrismObject<UserType> user = evaluator.getUserOld();
    user.asObjectable().getEmployeeType().clear();
    user.asObjectable().getEmployeeType().add("SAILOR");
    ObjectDelta<UserType> delta = ObjectDelta.createAddDelta(user);
    Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping(filename, TEST_NAME, "title", delta);
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
    assertNull("Unexpected output triple: " + outputTriple, outputTriple);
}
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)

Example 20 with PrismPropertyValue

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

the class TestMappingDynamicSysVar method testEmployeeNumberDecimal.

@Test
public void testEmployeeNumberDecimal() throws Exception {
    // WHEN
    PrismValueDeltaSetTriple<PrismPropertyValue<Integer>> outputTriple = evaluator.evaluateMappingDynamicReplace("mapping-script-system-variables-employee-number.xml", "testEmployeeNumberString", // target
    new ItemPath(UserType.F_EXTENSION, SchemaTestConstants.EXTENSION_DECIMAL_TYPE_ELEMENT), // changed property
    "employeeNumber", // changed values
    "666.33");
    // THEN
    PrismAsserts.assertTripleNoZero(outputTriple);
    PrismAsserts.assertTriplePlus(outputTriple, new BigDecimal("666.33"));
    PrismAsserts.assertTripleNoMinus(outputTriple);
}
Also used : BigDecimal(java.math.BigDecimal) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

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