use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class TestUserTemplate method test162ModifyUserGivenNameAgainPhantomChange.
@Test
public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception {
final String TEST_NAME = "test162ModifyUserGivenNameAgainPhantomChange";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<UserType> userBefore = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
display("User before", userBefore);
dummyAuditService.clear();
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
ObjectDelta<UserType> userDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_GIVEN_NAME, prismContext, // this is a phantom change
new PolyString("JACKIE"));
deltas.add(userDelta);
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
display("User after", userJack);
PrismAsserts.assertPropertyValue(userJack.findContainer(UserType.F_EXTENSION), PIRACY_BAD_LUCK, 123L);
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(1);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertTarget(USER_JACK_OID);
dummyAuditService.assertExecutionSuccess();
ObjectDeltaOperation<?> objectDeltaOperation = dummyAuditService.getExecutionDelta(0);
// givenName + modifyTimestamp
assertEquals("unexpected number of modifications in audited delta", 2, objectDeltaOperation.getObjectDelta().getModifications().size());
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class TestUserTemplate method test160ModifyUserGivenNameAgain.
@Test
public void test160ModifyUserGivenNameAgain() throws Exception {
TestUtil.displayTestTile(this, "test160ModifyUserGivenNameAgain");
// GIVEN
Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + ".test160ModifyUserGivenNameAgain");
OperationResult result = task.getResult();
dummyAuditService.clear();
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
ObjectDelta<UserType> userDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_GIVEN_NAME, prismContext, new PolyString("JACKIE"));
deltas.add(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismAsserts.assertPropertyValue(userJack.findContainer(UserType.F_EXTENSION), PIRACY_BAD_LUCK, 123L);
display("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);
// givenName + badLuck + modifyTimestamp
assertEquals("unexpected number of modifications in audited delta", 4, objectDeltaOperation.getObjectDelta().getModifications().size());
PropertyDelta badLuckDelta = objectDeltaOperation.getObjectDelta().findPropertyDelta(new ItemPath(UserType.F_EXTENSION, PIRACY_BAD_LUCK));
assertNotNull("badLuck delta was not found", badLuckDelta);
List<PrismValue> oldValues = (List<PrismValue>) badLuckDelta.getEstimatedOldValues();
assertNotNull("badLuck delta has null estimatedOldValues field", oldValues);
PrismAsserts.assertEqualsCollectionUnordered("badLuck delta has wrong estimatedOldValues", oldValues, new PrismPropertyValue<Long>(123L), new PrismPropertyValue<Long>(456L));
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class LookupTableHelper method setupLookupTableRowsQuery.
private Criteria setupLookupTableRowsQuery(Session session, RelationalValueSearchQuery queryDef, String oid) {
Criteria criteria = session.createCriteria(RLookupTableRow.class);
criteria.add(Restrictions.eq("ownerOid", oid));
if (queryDef != null && queryDef.getColumn() != null && queryDef.getSearchType() != null && StringUtils.isNotEmpty(queryDef.getSearchValue())) {
String param = queryDef.getColumn().getLocalPart();
String value = queryDef.getSearchValue();
if (LookupTableRowType.F_LABEL.equals(queryDef.getColumn())) {
param = "label.norm";
PolyString poly = new PolyString(value);
poly.recompute(new PrismDefaultPolyStringNormalizer());
value = poly.getNorm();
}
switch(queryDef.getSearchType()) {
case EXACT:
criteria.add(Restrictions.eq(param, value));
break;
case STARTS_WITH:
criteria.add(Restrictions.like(param, value + "%"));
break;
case SUBSTRING:
criteria.add(Restrictions.like(param, "%" + value + "%"));
}
}
return criteria;
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class EncodingTest method toPolyString.
private PolyString toPolyString(String orig) {
PolyString polyString = new PolyString(orig);
polyString.recompute(prismContext.getDefaultPolyStringNormalizer());
return polyString;
}
use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.
the class EncodingTest method checkUserPropertyPolyString.
private <O extends ObjectType> void checkUserPropertyPolyString(PrismObject<O> object, QName propQName, OperationResult parentResult, String... expectedValues) {
String propName = propQName.getLocalPart();
OperationResult result = parentResult.createSubresult(parentResult.getOperation() + "." + propName);
PrismProperty<PolyString> prop = object.findProperty(propQName);
Collection<PolyString> actualValues = prop.getRealValues();
result.addArbitraryCollectionAsParam("actualValues", actualValues);
assertMultivaluePolyString("User, property '" + propName + "'", expectedValues, actualValues, result);
result.recordSuccessIfUnknown();
}
Aggregations