Search in sources :

Example 16 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestPolyString method testCompareTo.

@Test
public void testCompareTo() throws Exception {
    System.out.println("===[ testCompareTo ]===");
    // GIVEN
    String orig = "Ľala ho papľuha";
    PolyString polyName = new PolyString(orig);
    // WHEN, THEN
    assertTrue(polyName.compareTo("Ľala ho papľuha") == 0);
    assertTrue(polyName.compareTo(new PolyString("Ľala ho papľuha")) == 0);
    assertTrue(polyName.compareTo("something different") != 0);
    assertTrue(polyName.compareTo(new PolyString("something different")) != 0);
    assertTrue(polyName.compareTo("") != 0);
    assertTrue(polyName.compareTo(null) != 0);
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 17 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestPolyString method testNormalization.

private void testNormalization(final String TEST_NAME, String orig, String expectedNorm) {
    System.out.println("===[ " + TEST_NAME + " ]===");
    PolyString polyString = new PolyString(orig);
    PolyStringNormalizer normalizer = new PrismDefaultPolyStringNormalizer();
    // WHEN
    polyString.recompute(normalizer);
    // THEN
    assertEquals("orig have changed", orig, polyString.getOrig());
    assertEquals("wrong norm", expectedNorm, polyString.getNorm());
    assertEquals("wrong toString", orig, polyString.toString());
}
Also used : PrismDefaultPolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PrismDefaultPolyStringNormalizer) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PolyStringNormalizer) PrismDefaultPolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PrismDefaultPolyStringNormalizer)

Example 18 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestFind method testFindPolyString.

@Test
public void testFindPolyString() throws SchemaException, SAXException, IOException {
    final String TEST_NAME = "testFindPolyString";
    System.out.println("===[ " + TEST_NAME + " ]===");
    // GIVEN
    PrismObject<UserType> user = createUser();
    ItemPath path = new ItemPath(UserType.F_POLY_NAME);
    // WHEN
    PrismProperty<PolyString> nameProperty = findProperty(user, path);
    // THEN
    assertEquals("Wrong property value (path=" + path + ")", PrismTestUtil.createPolyString(USER_JACK_POLYNAME_ORIG), nameProperty.getRealValue());
    assertTrue("QName found something other", nameProperty == (PrismProperty) user.findProperty(UserType.F_POLY_NAME));
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.prism.foo.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 19 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestMatchingRule method testPolyStringOrig.

@Test
public void testPolyStringOrig() throws Exception {
    // GIVEN
    MatchingRule<PolyString> rule = matchingRuleRegistry.getMatchingRule(PolyStringOrigMatchingRule.NAME, PolyStringType.COMPLEX_TYPE);
    // WHEN, THEN		
    assertMatch(rule, new PolyString("Bar", "bar"), new PolyString("Bar", "bar"));
    assertNoMatch(rule, new PolyString("BAR", "bar"), new PolyString("Foo", "bar"));
    assertNoMatch(rule, new PolyString("Bar", "bar"), new PolyString("bAR", "bar"));
    assertMatch(rule, new PolyString("Bar", "bar"), new PolyString("Bar", "barbar"));
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 20 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestMappingComplex method testModifyObjectSetAdditionalName.

@Test
public void testModifyObjectSetAdditionalName() throws Exception {
    final String TEST_NAME = "testModifyObjectSetAdditionalName";
    System.out.println("===[ " + TEST_NAME + "]===");
    // GIVEN
    ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_ADDITIONAL_NAME, evaluator.getPrismContext(), "Jackie");
    delta.addModificationReplaceProperty(UserType.F_EMPLOYEE_NUMBER, "321");
    Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = evaluator.createMapping(MAPPING_COMPLEX_FILENAME, TEST_NAME, "title", delta);
    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("Pirate Jackie (#321)"));
    PrismAsserts.assertTripleMinus(outputTriple, PrismTestUtil.createPolyString("Pirate null (#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)

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