Search in sources :

Example 1 with MContainer

use of com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer 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);
}
Also used : MArchetype(com.evolveum.midpoint.repo.sqale.qmodel.role.MArchetype) MReportData(com.evolveum.midpoint.repo.sqale.qmodel.report.MReportData) com.evolveum.midpoint.repo.sqale.qmodel.object(com.evolveum.midpoint.repo.sqale.qmodel.object) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) com.evolveum.midpoint.repo.sqale.qmodel.ref(com.evolveum.midpoint.repo.sqale.qmodel.ref) QSystemConfiguration(com.evolveum.midpoint.repo.sqale.qmodel.system.QSystemConfiguration) BigDecimal(java.math.BigDecimal) DOMUtil(com.evolveum.midpoint.util.DOMUtil) Map(java.util.Map) QNode(com.evolveum.midpoint.repo.sqale.qmodel.node.QNode) BigInteger(java.math.BigInteger) MContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer) MConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnector) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) RepoAddOptions.createOverwrite(com.evolveum.midpoint.repo.api.RepoAddOptions.createOverwrite) QContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) MContainerType(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType) MFocus(com.evolveum.midpoint.repo.sqale.qmodel.focus.MFocus) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UUID(java.util.UUID) Instant(java.time.Instant) QLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.QLookupTableRow) StandardCharsets(java.nio.charset.StandardCharsets) QMessageTemplate(com.evolveum.midpoint.repo.sqale.qmodel.notification.QMessageTemplate) com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem(com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem) QGenericObject(com.evolveum.midpoint.repo.sqale.qmodel.focus.QGenericObject) MTask(com.evolveum.midpoint.repo.sqale.qmodel.task.MTask) List(java.util.List) QConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnector) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) QName(javax.xml.namespace.QName) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Jsonb(com.evolveum.midpoint.repo.sqale.jsonb.Jsonb) QResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.QResource) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.MResource) QCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.QCase) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) QConnectorHost(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnectorHost) MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) MConnectorHost(com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnectorHost) QReport(com.evolveum.midpoint.repo.sqale.qmodel.report.QReport) Comparator.comparing(java.util.Comparator.comparing) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) Containerable(com.evolveum.midpoint.prism.Containerable) MLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.MLookupTableRow) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) DeleteObjectResult(com.evolveum.midpoint.repo.api.DeleteObjectResult) MNode(com.evolveum.midpoint.repo.sqale.qmodel.node.MNode) com.evolveum.midpoint.repo.sqale.qmodel.assignment(com.evolveum.midpoint.repo.sqale.qmodel.assignment) PrismObject(com.evolveum.midpoint.prism.PrismObject) QShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.QShadow) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) SimpleExpressionUtil.velocityExpression(com.evolveum.midpoint.schema.util.SimpleExpressionUtil.velocityExpression) ChronoUnit(java.time.temporal.ChronoUnit) ItemName(com.evolveum.midpoint.prism.path.ItemName) QReportData(com.evolveum.midpoint.repo.sqale.qmodel.report.QReportData) MCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.MCase) QArchetype(com.evolveum.midpoint.repo.sqale.qmodel.role.QArchetype) SqaleRepositoryService(com.evolveum.midpoint.repo.sqale.SqaleRepositoryService) QTask(com.evolveum.midpoint.repo.sqale.qmodel.task.QTask) com.evolveum.midpoint.repo.sqale.qmodel.accesscert(com.evolveum.midpoint.repo.sqale.qmodel.accesscert) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) MContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 2 with MContainer

use of com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer 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);
}
Also used : MArchetype(com.evolveum.midpoint.repo.sqale.qmodel.role.MArchetype) MReportData(com.evolveum.midpoint.repo.sqale.qmodel.report.MReportData) com.evolveum.midpoint.repo.sqale.qmodel.object(com.evolveum.midpoint.repo.sqale.qmodel.object) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) com.evolveum.midpoint.repo.sqale.qmodel.ref(com.evolveum.midpoint.repo.sqale.qmodel.ref) QSystemConfiguration(com.evolveum.midpoint.repo.sqale.qmodel.system.QSystemConfiguration) BigDecimal(java.math.BigDecimal) DOMUtil(com.evolveum.midpoint.util.DOMUtil) Map(java.util.Map) QNode(com.evolveum.midpoint.repo.sqale.qmodel.node.QNode) BigInteger(java.math.BigInteger) MContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer) MConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnector) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) RepoAddOptions.createOverwrite(com.evolveum.midpoint.repo.api.RepoAddOptions.createOverwrite) QContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) MContainerType(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType) MFocus(com.evolveum.midpoint.repo.sqale.qmodel.focus.MFocus) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UUID(java.util.UUID) Instant(java.time.Instant) QLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.QLookupTableRow) StandardCharsets(java.nio.charset.StandardCharsets) QMessageTemplate(com.evolveum.midpoint.repo.sqale.qmodel.notification.QMessageTemplate) com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem(com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem) QGenericObject(com.evolveum.midpoint.repo.sqale.qmodel.focus.QGenericObject) MTask(com.evolveum.midpoint.repo.sqale.qmodel.task.MTask) List(java.util.List) QConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnector) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) QName(javax.xml.namespace.QName) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Jsonb(com.evolveum.midpoint.repo.sqale.jsonb.Jsonb) QResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.QResource) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.MResource) QCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.QCase) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) QConnectorHost(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnectorHost) MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) MConnectorHost(com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnectorHost) QReport(com.evolveum.midpoint.repo.sqale.qmodel.report.QReport) Comparator.comparing(java.util.Comparator.comparing) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) Containerable(com.evolveum.midpoint.prism.Containerable) MLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.MLookupTableRow) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) DeleteObjectResult(com.evolveum.midpoint.repo.api.DeleteObjectResult) MNode(com.evolveum.midpoint.repo.sqale.qmodel.node.MNode) com.evolveum.midpoint.repo.sqale.qmodel.assignment(com.evolveum.midpoint.repo.sqale.qmodel.assignment) PrismObject(com.evolveum.midpoint.prism.PrismObject) QShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.QShadow) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) SimpleExpressionUtil.velocityExpression(com.evolveum.midpoint.schema.util.SimpleExpressionUtil.velocityExpression) ChronoUnit(java.time.temporal.ChronoUnit) ItemName(com.evolveum.midpoint.prism.path.ItemName) QReportData(com.evolveum.midpoint.repo.sqale.qmodel.report.QReportData) MCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.MCase) QArchetype(com.evolveum.midpoint.repo.sqale.qmodel.role.QArchetype) SqaleRepositoryService(com.evolveum.midpoint.repo.sqale.SqaleRepositoryService) QTask(com.evolveum.midpoint.repo.sqale.qmodel.task.QTask) com.evolveum.midpoint.repo.sqale.qmodel.accesscert(com.evolveum.midpoint.repo.sqale.qmodel.accesscert) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UUID(java.util.UUID) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) MContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

Containerable (com.evolveum.midpoint.prism.Containerable)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 ItemName (com.evolveum.midpoint.prism.path.ItemName)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 DeleteObjectResult (com.evolveum.midpoint.repo.api.DeleteObjectResult)2 RepoAddOptions.createOverwrite (com.evolveum.midpoint.repo.api.RepoAddOptions.createOverwrite)2 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)2 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)2 SqaleRepositoryService (com.evolveum.midpoint.repo.sqale.SqaleRepositoryService)2 Jsonb (com.evolveum.midpoint.repo.sqale.jsonb.Jsonb)2 com.evolveum.midpoint.repo.sqale.qmodel.accesscert (com.evolveum.midpoint.repo.sqale.qmodel.accesscert)2 com.evolveum.midpoint.repo.sqale.qmodel.assignment (com.evolveum.midpoint.repo.sqale.qmodel.assignment)2 MCase (com.evolveum.midpoint.repo.sqale.qmodel.cases.MCase)2 QCase (com.evolveum.midpoint.repo.sqale.qmodel.cases.QCase)2 com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem (com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem)2 MContainer (com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer)2 MContainerType (com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType)2 QContainer (com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer)2 MConnector (com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnector)2 MConnectorHost (com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnectorHost)2