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