use of com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test213OverwritingParentOfDeeplyNestedEmbeddedContainer.
@Test
public void test213OverwritingParentOfDeeplyNestedEmbeddedContainer() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);
given("delta adding whole credential/password container user 1");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(FocusType.F_CREDENTIALS).replace(new CredentialsType(prismContext).password(new PasswordType(prismContext).metadata(new MetadataType(prismContext).createTimestamp(MiscUtil.asXMLGregorianCalendar(1L))))).asObjectDelta(user1Oid);
when("modifyObject is called");
repositoryService.modifyObject(UserType.class, user1Oid, delta.getModifications(), result);
then("operation is successful");
assertThatOperationResult(result).isSuccess();
and("serialized form (fullObject) is updated");
UserType user = repositoryService.getObject(UserType.class, user1Oid, null, result).asObjectable();
assertThat(user.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
assertThat(user.getCredentials().getPassword().getMetadata().getCreateTimestamp().getMillisecond()).isEqualTo(1);
assertThat(user.getCredentials().getPassword().getMetadata().getModifyTimestamp()).isNull();
and("externalized column is updated");
MUser row = selectObjectByOid(QUser.class, user1Oid);
assertThat(row.version).isEqualTo(originalRow.version + 1);
// cleared
assertThat(row.passwordModifyTimestamp).isNull();
assertThat(row.passwordCreateTimestamp).isEqualTo(Instant.ofEpochMilli(1));
}
use of com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test505SettingExtensionContainerToEmpty.
@Test
public void test505SettingExtensionContainerToEmpty() throws Exception {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);
given("delta setting extension container to empty");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(FocusType.F_EXTENSION).replace(new ExtensionType()).asObjectDelta(user1Oid);
when("modifyObject is called");
repositoryService.modifyObject(UserType.class, user1Oid, delta.getModifications(), result);
then("operation is successful");
assertThatOperationResult(result).isSuccess();
and("serialized form (fullObject) is updated");
UserType user = repositoryService.getObject(UserType.class, user1Oid, null, result).asObjectable();
assertThat(user.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
ExtensionType extensionContainer = user.getExtension();
assertThat(extensionContainer).isNotNull().matches(m -> m.asPrismContainerValue().isEmpty());
and("ext column is cleared");
MUser row = selectObjectByOid(QUser.class, user1Oid);
assertThat(row.version).isEqualTo(originalRow.version + 1);
assertThat(row.ext).isNull();
}
use of com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test188ReplacingAssignmentPolicySituationsWithNoValue.
@Test
public void test188ReplacingAssignmentPolicySituationsWithNoValue() throws Exception {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);
long assignmentId = originalRow.containerIdSeq - 1;
given("delta replacing assignment's policy situations with no value");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT, assignmentId, AssignmentType.F_POLICY_SITUATION).replace().asObjectDelta(user1Oid);
when("modifyObject is called");
repositoryService.modifyObject(UserType.class, user1Oid, delta.getModifications(), result);
then("operation is successful");
assertThatOperationResult(result).isSuccess();
and("serialized form (fullObject) is updated");
UserType userObject = repositoryService.getObject(UserType.class, user1Oid, null, result).asObjectable();
assertThat(userObject.getAssignment().get(0).getPolicySituation()).isNullOrEmpty();
and("column with policy situations is set to null");
QAssignment<?> a = QAssignmentMapping.getAssignmentMapping().defaultAlias();
MAssignment aRow = selectOne(a, a.ownerOid.eq(UUID.fromString(user1Oid)));
assertThat(aRow.policySituations).isNull();
}
use of com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test161AddingMoreProjectionRefsInsertsRowsToTable.
@Test
public void test161AddingMoreProjectionRefsInsertsRowsToTable() throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);
given("delta adding projection refs to the same target with different relation for user 1");
UUID refTargetOid = UUID.randomUUID();
QName refRelation1 = QName.valueOf("{https://random.org/ns}projection-rel1");
QName refRelation2 = QName.valueOf("{https://random.org/ns}projection-rel2");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(UserType.F_LINK_REF).add(new ObjectReferenceType().oid(refTargetOid.toString()).type(ShadowType.COMPLEX_TYPE).relation(refRelation1), new ObjectReferenceType().oid(refTargetOid.toString()).type(ShadowType.COMPLEX_TYPE).relation(refRelation2)).asObjectDelta(user1Oid);
when("modifyObject is called");
repositoryService.modifyObject(UserType.class, user1Oid, delta.getModifications(), result);
then("operation is successful");
assertThatOperationResult(result).isSuccess();
and("serialized form (fullObject) is updated");
UserType userObject = repositoryService.getObject(UserType.class, user1Oid, null, result).asObjectable();
assertThat(userObject.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
// no more checks, we believe in Prism
assertThat(userObject.getLinkRef()).hasSize(3);
and("user row version is incremented");
MUser row = selectObjectByOid(QUser.class, user1Oid);
assertThat(row.version).isEqualTo(originalRow.version + 1);
and("externalized refs are inserted to the dedicated table");
QObjectReference<?> r = QObjectReferenceMapping.getForProjection().defaultAlias();
List<MReference> refs = select(r, r.ownerOid.eq(UUID.fromString(user1Oid)));
assertThat(refs).hasSize(3).anyMatch(refRowMatcher(refTargetOid, refRelation1)).anyMatch(refRowMatcher(refTargetOid, refRelation2));
}
use of com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test187ReplacingAssignmentPolicySituationsValues.
@Test
public void test187ReplacingAssignmentPolicySituationsValues() throws Exception {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);
long assignmentId = originalRow.containerIdSeq - 1;
given("delta replacing assignment's policy situations");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT, assignmentId, AssignmentType.F_POLICY_SITUATION).replace("policy-situation-a", "policy-situation-z").asObjectDelta(user1Oid);
when("modifyObject is called");
repositoryService.modifyObject(UserType.class, user1Oid, delta.getModifications(), result);
then("operation is successful");
assertThatOperationResult(result).isSuccess();
and("serialized form (fullObject) is updated");
UserType userObject = repositoryService.getObject(UserType.class, user1Oid, null, result).asObjectable();
assertThat(userObject.getAssignment().get(0).getPolicySituation()).containsExactlyInAnyOrder("policy-situation-a", "policy-situation-z");
and("column with subtypes is updated accordingly");
QAssignment<?> a = QAssignmentMapping.getAssignmentMapping().defaultAlias();
MAssignment aRow = selectOne(a, a.ownerOid.eq(UUID.fromString(user1Oid)));
assertThat(aRow.policySituations).extracting(uriId -> cachedUriById(uriId)).containsExactlyInAnyOrder("policy-situation-a", "policy-situation-z");
}
Aggregations