Search in sources :

Example 21 with PolyString

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)"));
}
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 22 with PolyString

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);
}
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 23 with PolyString

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"));
}
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 24 with PolyString

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);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) File(java.io.File) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 25 with PolyString

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"));
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) 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)

Aggregations

PolyString (com.evolveum.midpoint.prism.polystring.PolyString)168 Test (org.testng.annotations.Test)103 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)90 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)67 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)53 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)44 Task (com.evolveum.midpoint.task.api.Task)41 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)27 PrismObject (com.evolveum.midpoint.prism.PrismObject)21 QName (javax.xml.namespace.QName)18 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)16 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)15 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)12 ArrayList (java.util.ArrayList)12 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)10 File (java.io.File)10 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)9 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)8 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)8