Search in sources :

Example 26 with ItemName

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
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ItemName(com.evolveum.midpoint.prism.path.ItemName) File(java.io.File) Test(org.testng.annotations.Test)

Example 27 with ItemName

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"));
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ItemName(com.evolveum.midpoint.prism.path.ItemName) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) File(java.io.File) Test(org.testng.annotations.Test)

Example 28 with ItemName

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

Example 29 with ItemName

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

Example 30 with ItemName

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

Aggregations

ItemName (com.evolveum.midpoint.prism.path.ItemName)89 Test (org.testng.annotations.Test)24 QName (javax.xml.namespace.QName)19 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)13 NotNull (org.jetbrains.annotations.NotNull)10 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 Task (com.evolveum.midpoint.task.api.Task)6 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)5 MUser (com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser)5 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)5 Element (org.w3c.dom.Element)5 JdbcSession (com.evolveum.midpoint.repo.sqlbase.JdbcSession)4 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)4 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)4 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)4 ArrayList (java.util.ArrayList)4 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)3