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();
}
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);
}
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());
}
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);
}
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);
}
Aggregations