use of com.evolveum.midpoint.repo.sqale.qmodel.focus.QUserMapping in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test951ReindexAfterManualChangeOfFullObject.
@Test
public void test951ReindexAfterManualChangeOfFullObject() throws SchemaException, ObjectNotFoundException, ObjectAlreadyExistsException {
OperationResult result = createOperationResult();
UserType user = new UserType(prismContext).name("corrupted").beginAssignment().policySituation("kept").<UserType>end().beginAssignment().policySituation("removed").end();
String oid = repositoryService.addObject(user.asPrismObject(), null, result);
when("full object is modified in the database (indices are desynced from full object)");
user = repositoryService.getObject(UserType.class, oid, null, result).asObjectable();
// remove removed
user.getAssignment().remove(1);
user.beginAssignment().policySituation("added");
QUserMapping mapping = QUserMapping.getUserMapping();
byte[] fullObject = mapping.createFullObject(user);
try (JdbcSession session = mapping.repositoryContext().newJdbcSession().startTransaction()) {
session.newUpdate(mapping.defaultAlias()).set(mapping.defaultAlias().fullObject, fullObject).where(mapping.defaultAlias().oid.eq(SqaleUtils.oidToUUid(oid))).execute();
session.commit();
}
assertPolicySituationFound("kept", 1, result);
assertPolicySituationFound("removed", 1, result);
assertPolicySituationFound("added", 0, result);
given("object is reindexed");
RepoModifyOptions options = RepoModifyOptions.createForceReindex();
repositoryService.modifyObject(UserType.class, oid, Collections.emptyList(), options, result);
then("indices are updated according new full object");
assertPolicySituationFound("kept", 1, result);
assertPolicySituationFound("removed", 0, result);
assertPolicySituationFound("added", 1, result);
}
Aggregations