Search in sources :

Example 16 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TestFind method testFindString.

@Test
public void testFindString() throws SchemaException, SAXException, IOException {
    final String TEST_NAME = "testFindString";
    System.out.println("===[ " + TEST_NAME + " ]===");
    // GIVEN
    PrismObject<UserType> user = createUser();
    ItemPath path = new ItemPath(UserType.F_DESCRIPTION);
    // WHEN
    PrismProperty<String> nameProperty = findProperty(user, path);
    // THEN
    assertEquals("Wrong property value (path=" + path + ")", USER_JACK_DESCRIPTION, nameProperty.getRealValue());
    assertTrue("QName found something other", nameProperty == (PrismProperty) user.findProperty(UserType.F_DESCRIPTION));
}
Also used : 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 17 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TestFind method testFindExtensionBar.

@Test
public void testFindExtensionBar() throws SchemaException, SAXException, IOException {
    final String TEST_NAME = "testFindExtensionBar";
    System.out.println("===[ " + TEST_NAME + " ]===");
    // GIVEN
    ItemPath path = new ItemPath(UserType.F_EXTENSION, EXTENSION_BAR_ELEMENT);
    // WHEN
    PrismProperty<String> property = findUserProperty(path);
    // THEN
    assertEquals("Wrong property value (path=" + path + ")", "BAR", property.getAnyRealValue());
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 18 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TestFind method testFindAssignment.

@Test
public void testFindAssignment() throws SchemaException, SAXException, IOException {
    final String TEST_NAME = "testFindAssignment";
    System.out.println("===[ " + TEST_NAME + " ]===");
    // GIVEN
    ItemPath path = new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT));
    // WHEN
    PrismContainer<AssignmentType> container = findUserContainer(path);
    // THEN
    PrismContainerValue<AssignmentType> value2 = container.getValue(USER_ASSIGNMENT_2_ID);
    assertEquals("Wrong value2 description (path=" + path + ")", "Assignment 2", value2.findProperty(AssignmentType.F_DESCRIPTION).getRealValue());
}
Also used : AssignmentType(com.evolveum.midpoint.prism.foo.AssignmentType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 19 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath 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 20 with ItemPath

use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.

the class TestPath method testPathNormalize.

@Test
public void testPathNormalize() throws Exception {
    System.out.println("\n\n===[ testPathNormalize ]===\n");
    // GIVEN
    ItemPath path1 = new ItemPath(new QName(NS, "foo"), new QName(NS, "bar"));
    ItemPath path2 = new ItemPath(new NameItemPathSegment(new QName(NS, "foo")), new IdItemPathSegment(123L), new NameItemPathSegment(new QName(NS, "bar")));
    ItemPath path22 = new ItemPath(new NameItemPathSegment(new QName(NS, "foo")), new IdItemPathSegment(123L), new NameItemPathSegment(new QName(NS, "bar")), new IdItemPathSegment(null));
    ItemPath path3 = new ItemPath(new NameItemPathSegment(new QName(NS, "foo")), new IdItemPathSegment(123L), new NameItemPathSegment(new QName(NS, "bar")), new IdItemPathSegment(333L));
    ItemPath path4 = new ItemPath(new QName(NS, "x"));
    ItemPath path5 = new ItemPath(new NameItemPathSegment(new QName(NS, "foo")), new IdItemPathSegment(123L));
    ItemPath pathE = new ItemPath();
    // WHEN
    ItemPath normalized1 = path1.normalize();
    ItemPath normalized2 = path2.normalize();
    ItemPath normalized22 = path22.normalize();
    ItemPath normalized3 = path3.normalize();
    ItemPath normalized4 = path4.normalize();
    ItemPath normalized5 = path5.normalize();
    ItemPath normalizedE = pathE.normalize();
    // THEN
    System.out.println("Normalized path 1:" + normalized1);
    System.out.println("Normalized path 2:" + normalized2);
    System.out.println("Normalized path 22:" + normalized22);
    System.out.println("Normalized path 3:" + normalized3);
    System.out.println("Normalized path 4:" + normalized4);
    System.out.println("Normalized path 5:" + normalized5);
    System.out.println("Normalized path E:" + normalizedE);
    assertNormalizedPath(normalized1, "foo", null, "bar");
    assertNormalizedPath(normalized2, "foo", 123L, "bar");
    assertNormalizedPath(normalized22, "foo", 123L, "bar", null);
    assertNormalizedPath(normalized3, "foo", 123L, "bar", 333L);
    assertNormalizedPath(normalized4, "x");
    assertNormalizedPath(normalized5, "foo", 123L);
    assert normalizedE.isEmpty() : "normalizedE is not empty";
}
Also used : QName(javax.xml.namespace.QName) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Aggregations

ItemPath (com.evolveum.midpoint.prism.path.ItemPath)693 Test (org.testng.annotations.Test)184 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)143 QName (javax.xml.namespace.QName)137 Task (com.evolveum.midpoint.task.api.Task)104 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)84 ArrayList (java.util.ArrayList)79 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)71 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)68 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)61 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)48 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)46 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)41 NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)41 PrismObject (com.evolveum.midpoint.prism.PrismObject)38 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)38 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)38 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)33 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)31 NotNull (org.jetbrains.annotations.NotNull)30