use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class TestJaxbParsing method testParseUserFromJaxb.
@Test
public void testParseUserFromJaxb() throws SchemaException, IOException {
PrismContext prismContext = PrismTestUtil.getPrismContext();
// Try to use the schema to validate Jack
UserType userType = PrismTestUtil.parseObjectable(new File(TestConstants.COMMON_DIR, "user-jack.xml"), UserType.class);
// WHEN
PrismObject<UserType> user = userType.asPrismObject();
user.revive(prismContext);
// THEN
System.out.println("Parsed user:");
System.out.println(user.debugDump());
user.checkConsistence();
assertPropertyValue(user, UserType.F_NAME, PrismTestUtil.createPolyString("jack"));
assertPropertyValue(user, new ItemName(SchemaConstants.NS_C, "fullName"), new PolyString("Jack Sparrow", "jack sparrow"));
assertPropertyValue(user, new ItemName(SchemaConstants.NS_C, "givenName"), new PolyString("Jack", "jack"));
assertPropertyValue(user, new ItemName(SchemaConstants.NS_C, "familyName"), new PolyString("Sparrow", "sparrow"));
assertPropertyValue(user, new ItemName(SchemaConstants.NS_C, "honorificPrefix"), new PolyString("Cpt.", "cpt"));
assertPropertyValue(user.findContainer(UserType.F_EXTENSION), new ItemName(NS_FOO, "bar"), "BAR");
PrismProperty<ProtectedStringType> password = user.findOrCreateContainer(UserType.F_EXTENSION).findProperty(new ItemName(NS_FOO, "password"));
assertNotNull(password);
// TODO: check inside
assertPropertyValue(user.findOrCreateContainer(UserType.F_EXTENSION), new ItemName(NS_FOO, "num"), 42);
PrismProperty<?> multi = user.findOrCreateContainer(UserType.F_EXTENSION).findProperty(new ItemName(NS_FOO, "multi"));
assertEquals(3, multi.getValues().size());
// TODO: more asserts
}
use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class TestParseDiffPatch method testUserReal.
@Test
public void testUserReal() throws SchemaException, IOException {
String userBeforeXml = MiscUtil.readFile(new File(TEST_DIR, "user-real-before.xml"));
String userAfterXml = MiscUtil.readFile(new File(TEST_DIR, "user-real-after.xml"));
// WHEN
ObjectDelta<UserType> userDelta = DiffUtil.diff(userBeforeXml, userAfterXml, UserType.class, getPrismContext());
// THEN
System.out.println("DELTA:");
System.out.println(userDelta.debugDump());
userDelta.checkConsistence();
assertEquals("Wrong delta OID", "2f9b9299-6f45-498f-bc8e-8d17c6b93b20", userDelta.getOid());
assertEquals("Wrong change type", ChangeType.MODIFY, userDelta.getChangeType());
Collection<? extends ItemDelta> modifications = userDelta.getModifications();
assertEquals("Unexpected number of modifications", 4, modifications.size());
PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C, "emailAddress"), "jack@blackpearl.com");
PrismAsserts.assertPropertyReplace(userDelta, new ItemName(SchemaConstants.NS_C, "locality"), new PolyString("World's End", "worlds end"));
PrismAsserts.assertPropertyReplace(userDelta, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.DISABLED);
PrismAsserts.assertPropertyAdd(userDelta, new ItemName(SchemaConstants.NS_C, "organizationalUnit"), new PolyString("Brethren of the Coast", "brethren of the coast"));
}
use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class TestParseMisc method assertPropertyValue.
public static void assertPropertyValue(PrismContainer<?> container, String propName, Object propValue) {
ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName);
PrismAsserts.assertPropertyValue(container, propQName, propValue);
}
use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class TestParseTaskBulkAction method assertPropertyDefinition.
private void assertPropertyDefinition(PrismContainer<?> container, String propName, QName xsdType, int minOccurs, int maxOccurs) {
ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName);
PrismAsserts.assertPropertyDefinition(container, propQName, xsdType, minOccurs, maxOccurs);
}
use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class TestParseTaskBulkAction method assertPropertyValue.
public static void assertPropertyValue(PrismContainer<?> container, String propName, Object propValue) {
ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName);
PrismAsserts.assertPropertyValue(container, propQName, propValue);
}
Aggregations