Search in sources :

Example 1 with Assertions.assertThatThrownBy

use of org.assertj.core.api.Assertions.assertThatThrownBy in project midpoint by Evolveum.

the class SqaleRepoModifyObjectTest method test811ModifyDynamicallyWithFailingSupplier.

@Test
public void test811ModifyDynamicallyWithFailingSupplier() {
    OperationResult result = createOperationResult();
    MUser originalRow = selectObjectByOid(QUser.class, user1Oid);
    expect("modifyObjectDynamically with failing supplier fails");
    Assertions.assertThatThrownBy(() -> repositoryService.modifyObjectDynamically(UserType.class, user1Oid, null, u -> {
        throw new RuntimeException("Random exception");
    }, null, result)).isInstanceOf(SystemException.class).hasMessage("Random exception");
    and("operation is fatal error and modification is not executed");
    assertThatOperationResult(result).isFatalError();
    MUser row = selectObjectByOid(QUser.class, user1Oid);
    assertThat(row.version).isEqualTo(originalRow.version);
}
Also used : QService(com.evolveum.midpoint.repo.sqale.qmodel.role.QService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SqaleUtils(com.evolveum.midpoint.repo.sqale.SqaleUtils) MService(com.evolveum.midpoint.repo.sqale.qmodel.role.MService) JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) BigDecimal(java.math.BigDecimal) Assertions(org.assertj.core.api.Assertions) MReference(com.evolveum.midpoint.repo.sqale.qmodel.ref.MReference) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) BeforeClass(org.testng.annotations.BeforeClass) MContainerType(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) MTask(com.evolveum.midpoint.repo.sqale.qmodel.task.MTask) QConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnector) SystemException(com.evolveum.midpoint.util.exception.SystemException) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) MObject(com.evolveum.midpoint.repo.sqale.qmodel.object.MObject) QUserMapping(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUserMapping) QName(javax.xml.namespace.QName) NotNull(org.jetbrains.annotations.NotNull) java.util(java.util) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Item(com.evolveum.midpoint.prism.Item) Jsonb(com.evolveum.midpoint.repo.sqale.jsonb.Jsonb) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Assert.assertEquals(org.testng.Assert.assertEquals) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) QObjectReferenceMapping(com.evolveum.midpoint.repo.sqale.qmodel.ref.QObjectReferenceMapping) MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) TestUtil(com.evolveum.midpoint.test.util.TestUtil) Comparator.comparing(java.util.Comparator.comparing) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) MObjectType(com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType) QObjectReference(com.evolveum.midpoint.repo.sqale.qmodel.ref.QObjectReference) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) 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) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) ItemName(com.evolveum.midpoint.prism.path.ItemName) RepoModifyOptions(com.evolveum.midpoint.repo.api.RepoModifyOptions) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) Assert.assertTrue(org.testng.Assert.assertTrue) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) QTask(com.evolveum.midpoint.repo.sqale.qmodel.task.QTask) com.evolveum.midpoint.repo.sqale.qmodel.accesscert(com.evolveum.midpoint.repo.sqale.qmodel.accesscert) SystemException(com.evolveum.midpoint.util.exception.SystemException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

Item (com.evolveum.midpoint.prism.Item)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1 ItemName (com.evolveum.midpoint.prism.path.ItemName)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 RepoModifyOptions (com.evolveum.midpoint.repo.api.RepoModifyOptions)1 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)1 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)1 SqaleUtils (com.evolveum.midpoint.repo.sqale.SqaleUtils)1 Jsonb (com.evolveum.midpoint.repo.sqale.jsonb.Jsonb)1 com.evolveum.midpoint.repo.sqale.qmodel.accesscert (com.evolveum.midpoint.repo.sqale.qmodel.accesscert)1 com.evolveum.midpoint.repo.sqale.qmodel.assignment (com.evolveum.midpoint.repo.sqale.qmodel.assignment)1 MContainerType (com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType)1 QConnector (com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnector)1 MUser (com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser)1 QUser (com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser)1