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