Search in sources :

Example 31 with NameItemPathSegment

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

the class TestValidityRecomputeTask method test126JackAddAdministrativeStatusAssignmentJudge.

@Test
public void test126JackAddAdministrativeStatusAssignmentJudge() throws Exception {
    final String TEST_NAME = "test126JackAddAdministrativeStatusAssignmentJudge";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TestValidityRecomputeTask.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assertDummyAccount(null, USER_JACK_USERNAME);
    AssignmentType judgeAssignment = getJudgeAssignment(USER_JACK_OID);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modifyObjectAddProperty(UserType.class, USER_JACK_OID, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(judgeAssignment.getId()), new NameItemPathSegment(AssignmentType.F_ACTIVATION), new NameItemPathSegment(ActivationType.F_ADMINISTRATIVE_STATUS)), task, result, ActivationStatusType.ENABLED);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    PrismObject<UserType> user = getUser(USER_JACK_OID);
    display("User after", user);
    assertDummyAccount(null, USER_JACK_USERNAME);
    assert11xUserOk(user);
}
Also used : TestTriggerTask(com.evolveum.midpoint.model.intest.TestTriggerTask) Task(com.evolveum.midpoint.task.api.Task) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 32 with NameItemPathSegment

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

the class BaseEvent method containsItem.

// path starts with named item path segment
private boolean containsItem(PrismContainerValue prismContainerValue, ItemPath itemPath) {
    QName first = ((NameItemPathSegment) itemPath.first()).getName();
    Item item = prismContainerValue.findItem(first);
    if (item == null) {
        return false;
    }
    ItemPath pathTail = pathTail(itemPath);
    if (item instanceof PrismContainer) {
        return containsItem((PrismContainer) item, pathTail);
    } else if (item instanceof PrismReference) {
        // we do not want to look inside references
        return pathTail.isEmpty();
    } else if (item instanceof PrismProperty) {
        // ...neither inside atomic values
        return pathTail.isEmpty();
    } else {
        // should not occur anyway
        return false;
    }
}
Also used : QName(javax.xml.namespace.QName) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 33 with NameItemPathSegment

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

the class AbstractModelIntegrationTest method createReplaceAccountConstructionUserDelta.

protected ObjectDelta<UserType> createReplaceAccountConstructionUserDelta(String userOid, Long id, ConstructionType newValue) throws SchemaException {
    PrismContainerDefinition pcd = getAssignmentDefinition().findContainerDefinition(AssignmentType.F_CONSTRUCTION);
    ContainerDelta<ConstructionType> acDelta = new ContainerDelta<ConstructionType>(new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(id), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION)), pcd, prismContext);
    //                ContainerDelta.createDelta(prismContext, ConstructionType.class, AssignmentType.F_CONSTRUCTION);
    acDelta.setValueToReplace(newValue.asPrismContainerValue());
    //        PropertyDelta.createModificationReplaceProperty(
    //                        new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(id), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION)),
    //                        ppd,
    //                        newValue);
    Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
    modifications.add(acDelta);
    ObjectDelta<UserType> userDelta = ObjectDelta.createModifyDelta(userOid, modifications, UserType.class, prismContext);
    return userDelta;
}
Also used : ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType) ArrayList(java.util.ArrayList) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 34 with NameItemPathSegment

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

the class ConcurrencyTest method concurrency004_TwoWriters_TwoAttributesEach__OneReader.

@Test(enabled = true)
public void concurrency004_TwoWriters_TwoAttributesEach__OneReader() throws Exception {
    ModifierThread[] mts = new ModifierThread[] { new ModifierThread(1, new ItemPath(UserType.F_GIVEN_NAME), true, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(1L), new NameItemPathSegment(AssignmentType.F_DESCRIPTION)), true), new ModifierThread(2, new ItemPath(UserType.F_FAMILY_NAME), true, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(1L), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION)), true) };
    Checker checker = new Checker() {

        @Override
        public void check(int iteration, String oid) throws Exception {
            PrismObject<UserType> userRetrieved = repositoryService.getObject(UserType.class, oid, null, new OperationResult("dummy"));
            String givenName = userRetrieved.asObjectable().getGivenName().getOrig();
            String familyName = userRetrieved.asObjectable().getFamilyName().getOrig();
            String assignmentDescription = userRetrieved.asObjectable().getAssignment().get(0).getDescription();
            String referenceDescription = userRetrieved.asObjectable().getAssignment().get(0).getConstruction().getDescription();
            LOGGER.info("[" + iteration + "] givenName = " + givenName + ", assignment description = " + assignmentDescription + ", familyName = " + familyName + ", referenceDescription = " + referenceDescription);
            if (!givenName.equals(assignmentDescription)) {
                String msg = "Inconsistent object state: GivenName = " + givenName + ", assignment description = " + assignmentDescription;
                LOGGER.error(msg);
                throw new AssertionError(msg);
            }
            if (!familyName.equals(referenceDescription)) {
                String msg = "Inconsistent object state: FamilyName = " + familyName + ", account construction description = " + referenceDescription;
                LOGGER.error(msg);
                throw new AssertionError(msg);
            }
        }
    };
    concurrencyUniversal("Test4", 60000L, 0L, mts, checker);
}
Also used : IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 35 with NameItemPathSegment

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

the class ConcurrencyTest method concurrency003_OneWriter_TwoAttributes__OneReader.

@Test(enabled = true)
public void concurrency003_OneWriter_TwoAttributes__OneReader() throws Exception {
    ModifierThread[] mts = new ModifierThread[] { new ModifierThread(1, new ItemPath(UserType.F_GIVEN_NAME), true, new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(1L), new NameItemPathSegment(AssignmentType.F_DESCRIPTION)), true) };
    Checker checker = new Checker() {

        @Override
        public void check(int iteration, String oid) throws Exception {
            PrismObject<UserType> userRetrieved = repositoryService.getObject(UserType.class, oid, null, new OperationResult("dummy"));
            String givenName = userRetrieved.asObjectable().getGivenName().getOrig();
            String assignmentDescription = userRetrieved.asObjectable().getAssignment().get(0).getDescription();
            LOGGER.info("[" + iteration + "] givenName = " + givenName + ", assignment description = " + assignmentDescription);
            if (!givenName.equals(assignmentDescription)) {
                String msg = "Inconsistent object state: GivenName = " + givenName + ", assignment description = " + assignmentDescription;
                LOGGER.error(msg);
                throw new AssertionError(msg);
            }
        }
    };
    concurrencyUniversal("Test3", 60000L, 0L, mts, checker);
}
Also used : IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Aggregations

NameItemPathSegment (com.evolveum.midpoint.prism.path.NameItemPathSegment)69 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)61 IdItemPathSegment (com.evolveum.midpoint.prism.path.IdItemPathSegment)46 Test (org.testng.annotations.Test)35 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)22 QName (javax.xml.namespace.QName)20 Task (com.evolveum.midpoint.task.api.Task)19 ItemPathSegment (com.evolveum.midpoint.prism.path.ItemPathSegment)15 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)14 TestTriggerTask (com.evolveum.midpoint.model.intest.TestTriggerTask)11 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)10 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)10 UserType (com.evolveum.midpoint.prism.foo.UserType)7 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)7 AssignmentType (com.evolveum.midpoint.prism.foo.AssignmentType)6 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)6 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)6 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)5 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)4