use of com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test210ChangeDeeplyNestedFocusPasswordCreateTimestamp.
@Test
public void test210ChangeDeeplyNestedFocusPasswordCreateTimestamp() throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);
given("delta adding credential/password/metadata/createTimestamp value for user 1");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(FocusType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_METADATA, MetadataType.F_CREATE_TIMESTAMP).add(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);
and("externalized column is updated");
MUser row = selectObjectByOid(QUser.class, user1Oid);
assertThat(row.version).isEqualTo(originalRow.version + 1);
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 test185AddingAssignmentWithPolicySituations.
// this section tests two things: array in container, and integer[] requiring conversion (URIs)
@Test
public void test185AddingAssignmentWithPolicySituations() throws Exception {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);
// Container tests are in 3xx category, but let's focus on policy situations.
given("delta adding assignment with policy situations");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).add(new AssignmentType(prismContext).policySituation("policy-situation-1").policySituation("policy-situation-2")).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));
assertThat(userObject.getAssignment().get(0).getPolicySituation()).containsExactlyInAnyOrder("policy-situation-1", "policy-situation-2");
and("policySituation column is set in the assignment row");
MUser row = selectObjectByOid(QUser.class, user1Oid);
assertThat(row.version).isEqualTo(originalRow.version + 1);
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-1", "policy-situation-2");
}
use of com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test164DeletingAllProjectionRefsUsingReplace.
@Test
public void test164DeletingAllProjectionRefsUsingReplace() throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);
given("delta to replace projection refs with no value");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(UserType.F_LINK_REF).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 and has no projection refs now");
UserType userObject = repositoryService.getObject(UserType.class, user1Oid, null, result).asObjectable();
assertThat(userObject.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
assertThat(userObject.getLinkRef()).isEmpty();
and("user row version is incremented");
MUser row = selectObjectByOid(QUser.class, user1Oid);
assertThat(row.version).isEqualTo(originalRow.version + 1);
and("externalized refs are inserted and deleted accordingly");
QObjectReference<?> r = QObjectReferenceMapping.getForProjection().defaultAlias();
assertThat(count(r, r.ownerOid.eq(UUID.fromString(user1Oid)))).isZero();
}
use of com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test182DeletingAllSubtypesByValuesSetsColumnToNull.
@Test
public void test182DeletingAllSubtypesByValuesSetsColumnToNull() throws Exception {
OperationResult result = createOperationResult();
given("delta deleting all subtype values");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(UserType.F_SUBTYPE).delete("subtype-1", "subtype-3", "subtype-4").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 and has no subtypes now");
UserType userObject = repositoryService.getObject(UserType.class, user1Oid, null, result).asObjectable();
assertThat(userObject.getSubtype()).isNullOrEmpty();
and("column with subtypes is set to null");
MUser row = selectObjectByOid(QUser.class, user1Oid);
assertThat(row.subtypes).isNull();
}
use of com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test170AddingCreateApproverRefsUnderMetadata.
@Test
public void test170AddingCreateApproverRefsUnderMetadata() throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);
given("delta adding create approver refs for user 1");
UUID approverOid1 = UUID.randomUUID();
UUID approverOid2 = UUID.randomUUID();
QName refRelation = QName.valueOf("{https://random.org/ns}approver");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(UserType.F_METADATA, MetadataType.F_CREATE_APPROVER_REF).add(new ObjectReferenceType().oid(approverOid1.toString()).type(UserType.COMPLEX_TYPE).relation(refRelation), new ObjectReferenceType().oid(approverOid2.toString()).type(UserType.COMPLEX_TYPE).relation(refRelation)).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));
assertThat(userObject.getMetadata().getCreateApproverRef()).hasSize(2).anyMatch(refMatcher(approverOid1, refRelation)).anyMatch(refMatcher(approverOid2, refRelation));
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.getForCreateApprover().defaultAlias();
UUID ownerOid = UUID.fromString(user1Oid);
List<MReference> refs = select(r, r.ownerOid.eq(ownerOid));
assertThat(refs).hasSize(2).anyMatch(refRowMatcher(approverOid1, refRelation)).anyMatch(refRowMatcher(approverOid2, refRelation));
}
Aggregations