use of com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer in project midpoint by Evolveum.
the class SqaleRepoAddDeleteObjectTest method test200AddObjectWithMultivalueContainers.
@Test
public void test200AddObjectWithMultivalueContainers() throws ObjectAlreadyExistsException, SchemaException {
OperationResult result = createOperationResult();
given("user with assignment and ref");
String userName = "user" + getTestNumber();
String targetRef1 = UUID.randomUUID().toString();
String targetRef2 = UUID.randomUUID().toString();
UserType user = new UserType(prismContext).name(userName).assignment(new AssignmentType(prismContext).targetRef(targetRef1, RoleType.COMPLEX_TYPE)).assignment(new AssignmentType(prismContext).targetRef(targetRef2, RoleType.COMPLEX_TYPE));
when("adding it to the repository");
repositoryService.addObject(user.asPrismObject(), null, result);
then("object and its container rows are created and container IDs are assigned");
assertThatOperationResult(result).isSuccess();
QUser u = aliasFor(QUser.class);
List<MUser> users = select(u, u.nameOrig.eq(userName));
assertThat(users).hasSize(1);
MUser userRow = users.get(0);
assertThat(userRow.oid).isNotNull();
// next free container number
assertThat(userRow.containerIdSeq).isEqualTo(3);
QContainer<MContainer, ?> c = aliasFor(QContainer.CLASS);
List<MContainer> containers = select(c, c.ownerOid.eq(userRow.oid));
assertThat(containers).hasSize(2).allMatch(cRow -> cRow.ownerOid.equals(userRow.oid) && cRow.containerType == MContainerType.ASSIGNMENT).extracting(cRow -> cRow.cid).containsExactlyInAnyOrder(1L, 2L);
}
use of com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer in project midpoint by Evolveum.
the class SqaleRepoAddDeleteObjectTest method test201AddObjectWithOidAndMultivalueContainers.
@Test
public void test201AddObjectWithOidAndMultivalueContainers() throws ObjectAlreadyExistsException, SchemaException {
OperationResult result = createOperationResult();
given("user with assignment and ref");
UUID providedOid = UUID.randomUUID();
String userName = "user" + getTestNumber();
String targetRef1 = UUID.randomUUID().toString();
String targetRef2 = UUID.randomUUID().toString();
UserType user = new UserType(prismContext).oid(providedOid.toString()).name(userName).assignment(new AssignmentType(prismContext).targetRef(targetRef1, RoleType.COMPLEX_TYPE)).assignment(new AssignmentType(prismContext).targetRef(targetRef2, RoleType.COMPLEX_TYPE));
when("adding it to the repository");
repositoryService.addObject(user.asPrismObject(), null, result);
then("object and its container rows are created and container IDs are assigned");
assertThatOperationResult(result).isSuccess();
QUser u = aliasFor(QUser.class);
List<MUser> users = select(u, u.nameOrig.eq(userName));
assertThat(users).hasSize(1);
MUser userRow = users.get(0);
assertThat(userRow.oid).isNotNull();
// next free container number
assertThat(userRow.containerIdSeq).isEqualTo(3);
QContainer<MContainer, ?> c = aliasFor(QContainer.CLASS);
List<MContainer> containers = select(c, c.ownerOid.eq(userRow.oid));
assertThat(containers).hasSize(2).allMatch(cRow -> cRow.ownerOid.equals(userRow.oid) && cRow.containerType == MContainerType.ASSIGNMENT).extracting(cRow -> cRow.cid).containsExactlyInAnyOrder(1L, 2L);
}
Aggregations