use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class TestMappingDomain method testReplaceMixedMultiValue.
@Test
public void testReplaceMixedMultiValue() throws Exception {
final String TEST_NAME = "testReplaceMixedMultiValue";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
PrismObject<UserType> userOld = evaluator.getUserOld();
List<String> employeeTypeOld = userOld.asObjectable().getEmployeeType();
employeeTypeOld.clear();
employeeTypeOld.add("001");
employeeTypeOld.add("A02");
employeeTypeOld.add("B03");
employeeTypeOld.add("004");
ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_ADDITIONAL_NAME, evaluator.getPrismContext(), "Jackie");
delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_TYPE, "X91", "992", "Y93", "994");
Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping(MAPPING_DOMAIN_FILENAME, TEST_NAME, "organization", delta, userOld);
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
TestUtil.displayWhen(TEST_NAME);
mapping.evaluate(null, opResult);
// THEN
TestUtil.displayThen(TEST_NAME);
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
display("Output triple", outputTriple);
outputTriple.checkConsistence();
PrismAsserts.assertTripleNoZero(outputTriple);
PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Pirate Jackie (992)"), PrismTestUtil.createPolyString("Pirate Jackie (994)"));
PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Pirate null (001)"), PrismTestUtil.createPolyString("Pirate null (004)"));
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class TestMappingDomain method testAddMixedMultiValue.
@Test
public void testAddMixedMultiValue() throws Exception {
final String TEST_NAME = "testAddMixedMultiValue";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
PrismObject<UserType> userOld = evaluator.getUserOld();
userOld.asObjectable().setAdditionalName(PrismTestUtil.createPolyStringType("Jackie"));
List<String> employeeTypeOld = userOld.asObjectable().getEmployeeType();
employeeTypeOld.clear();
employeeTypeOld.add("001");
employeeTypeOld.add("A02");
employeeTypeOld.add("B03");
employeeTypeOld.add("004");
ObjectDelta<UserType> delta = ObjectDelta.createModificationAddProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), "X91", "992", "Y93", "994");
Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping(MAPPING_DOMAIN_FILENAME, TEST_NAME, "organization", delta, userOld);
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
TestUtil.displayWhen(TEST_NAME);
mapping.evaluate(null, opResult);
// THEN
TestUtil.displayThen(TEST_NAME);
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
display("Output triple", outputTriple);
outputTriple.checkConsistence();
PrismAsserts.assertTripleZero(outputTriple, PrismTestUtil.createPolyString("Pirate Jackie (001)"), PrismTestUtil.createPolyString("Pirate Jackie (004)"));
PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Pirate Jackie (992)"), PrismTestUtil.createPolyString("Pirate Jackie (994)"));
PrismAsserts.assertTripleNoMinus(outputTriple);
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class TestMappingDynamicSimple method testScriptFullNameDeleteGivenNameFromNull.
@Test
public void testScriptFullNameDeleteGivenNameFromNull() throws Exception {
final String TEST_NAME = "testScriptFullNameDeleteGivenNameFromNull";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
ObjectDelta<UserType> delta = ObjectDelta.createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_GIVEN_NAME, evaluator.getPrismContext(), PrismTestUtil.createPolyString("Jack"));
PrismObject<UserType> userOld = evaluator.getUserOld();
userOld.asObjectable().setGivenName(null);
Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping("mapping-script-fullname.xml", TEST_NAME, // target
"fullName", delta, userOld);
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
outputTriple.checkConsistence();
PrismAsserts.assertTripleNoZero(outputTriple);
PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("Sparrow"));
PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Jack Sparrow"));
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class TestMappingDynamicSimple method testScriptRootNodeJaxb.
@Test
public void testScriptRootNodeJaxb() throws Exception {
// GIVEN
final String TEST_NAME = "testScriptRootNodeJaxb";
TestUtil.displayTestTile(TEST_NAME);
PrismObject<UserType> user = PrismTestUtil.parseObject(new File(MidPointTestConstants.OBJECTS_DIR, "c0c010c0-d34d-b33f-f00d-111111111111.xml"));
Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.<PolyString>createMappingBuilder("mapping-script-root-node.xml", TEST_NAME, "locality", null).rootNode(user.asObjectable()).build();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
outputTriple.checkConsistence();
PrismAsserts.assertTripleZero(outputTriple, new PolyString("Black Pearl", "black pearl"));
PrismAsserts.assertTripleNoPlus(outputTriple);
PrismAsserts.assertTripleNoMinus(outputTriple);
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class TestMappingDynamicSimple method testScriptTransformMultiReplace.
/**
* MID-3700
*/
@Test
public void testScriptTransformMultiReplace() throws Exception {
final String TEST_NAME = "testScriptTransformMultiReplace";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
ObjectDelta<UserType> delta = ObjectDelta.createEmptyModifyDelta(UserType.class, evaluator.USER_OLD_OID, evaluator.getPrismContext());
PropertyDelta<String> propDelta = delta.createPropertyModification(evaluator.toPath("employeeType"));
propDelta.addValueToReplace(new PrismPropertyValue<String>("CAPTAIN"));
delta.addModification(propDelta);
Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping("mapping-script-transform.xml", TEST_NAME, "organizationalUnit", delta);
PrismObject<UserType> user = (PrismObject<UserType>) mapping.getSourceContext().getOldObject();
display("user before", user);
display("delta", delta);
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
TestUtil.displayWhen(TEST_NAME);
mapping.evaluate(null, opResult);
// THEN
TestUtil.displayThen(TEST_NAME);
PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
display("output triple", outputTriple);
outputTriple.checkConsistence();
PrismAsserts.assertTripleNoZero(outputTriple);
PrismAsserts.assertTriplePlus(outputTriple, PrismTestUtil.createPolyString("The captain deck"));
PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("The pirate deck"));
}
Aggregations