use of com.evolveum.midpoint.prism.ItemFactory in project midpoint by Evolveum.
the class TestUserTemplate method test160ModifyUserGivenNameAgain.
@Test
public void test160ModifyUserGivenNameAgain() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = getTestOperationResult();
dummyAuditService.clear();
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_GIVEN_NAME, new PolyString("JACKIE"));
deltas.add(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
assertSuccess(result);
PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
PrismAsserts.assertPropertyValue(userJack.findContainer(UserType.F_EXTENSION), PIRACY_BAD_LUCK, 123L);
displayDumpable("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(2);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertTarget(USER_JACK_OID);
dummyAuditService.assertExecutionSuccess();
ObjectDeltaOperation<?> objectDeltaOperation = dummyAuditService.getExecutionDelta(0, ChangeType.MODIFY, UserType.class);
assertEquals("unexpected number of modifications in audited delta", 10, // givenName + badLuck + modifyTimestamp
objectDeltaOperation.getObjectDelta().getModifications().size());
PropertyDelta badLuckDelta = objectDeltaOperation.getObjectDelta().findPropertyDelta(ItemPath.create(UserType.F_EXTENSION, PIRACY_BAD_LUCK));
assertNotNull("badLuck delta was not found", badLuckDelta);
// noinspection unchecked
List<PrismValue> oldValues = (List<PrismValue>) badLuckDelta.getEstimatedOldValues();
assertNotNull("badLuck delta has null estimatedOldValues field", oldValues);
ItemFactory factory = prismContext.itemFactory();
PrismAsserts.assertEqualsCollectionUnordered("badLuck delta has wrong estimatedOldValues", oldValues, factory.createPropertyValue(123L), factory.createPropertyValue(456L));
}
Aggregations