Search in sources :

Example 1 with DeleteObjectResult

use of com.evolveum.midpoint.repo.api.DeleteObjectResult in project midpoint by Evolveum.

the class SqaleRepoSmokeTest method test110DeleteObject.

@Test
public void test110DeleteObject() throws Exception {
    OperationResult result = createOperationResult();
    given("existing user");
    UserType user = new UserType(prismContext).name("user" + getTestNumber());
    String userOid = repositoryService.addObject(user.asPrismObject(), null, result);
    and("cleared performance information");
    SqlPerformanceMonitorImpl pm = repositoryService.getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    when("user is deleted from the repository");
    DeleteObjectResult deleteResult = repositoryService.deleteObject(UserType.class, userOid, result);
    then("added object is assigned OID and operation is success");
    assertThat(deleteResult).isNotNull();
    assertThatOperationResult(result).isSuccess();
    assertThat(selectNullableObjectByOid(QUser.class, userOid)).isNull();
    assertSingleOperationRecorded(REPO_OP_PREFIX + RepositoryService.OP_DELETE_OBJECT);
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) DeleteObjectResult(com.evolveum.midpoint.repo.api.DeleteObjectResult) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 2 with DeleteObjectResult

use of com.evolveum.midpoint.repo.api.DeleteObjectResult in project midpoint by Evolveum.

the class SqaleRepoAddDeleteObjectTest method test999DeleteAllOtherObjects.

@Test
public void test999DeleteAllOtherObjects() throws Exception {
    // this doesn't follow given-when-then, sorry
    OperationResult result = createOperationResult();
    // we didn't create that many in this class, it should be OK to read them all at once
    for (MObject row : select(QObject.CLASS)) {
        DeleteObjectResult deleteResult = repositoryService.deleteObject(row.objectType.getSchemaType(), row.oid.toString(), result);
        assertThat(deleteResult).isNotNull();
    }
    assertThatOperationResult(result).isSuccess();
    assertThat(select(QObject.CLASS)).isEmpty();
    assertThat(select(QContainer.CLASS)).isEmpty();
    assertThat(select(QReference.CLASS)).isEmpty();
}
Also used : DeleteObjectResult(com.evolveum.midpoint.repo.api.DeleteObjectResult) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 3 with DeleteObjectResult

use of com.evolveum.midpoint.repo.api.DeleteObjectResult in project midpoint by Evolveum.

the class SqaleRepoAddDeleteObjectTest method test911DeleteUserUsingFocusWorksOk.

// slight variation of the above, but using lower-level abstract table
@Test
public void test911DeleteUserUsingFocusWorksOk() throws Exception {
    OperationResult result = createOperationResult();
    given("random user existing in the repository");
    // we'll sacrifice one of the users for this
    UUID userOid = randomExistingOid(QUser.class);
    when("deleting it using the focus type");
    DeleteObjectResult deleteResult = repositoryService.deleteObject(FocusType.class, userOid.toString(), result);
    then("user is deleted");
    assertThatOperationResult(result).isSuccess();
    assertThat(deleteResult).isNotNull();
    assertThat(deleteResult.getObjectTextRepresentation()).isNotNull();
    assertThat(selectNullableObjectByOid(QUser.class, userOid)).isNull();
}
Also used : DeleteObjectResult(com.evolveum.midpoint.repo.api.DeleteObjectResult) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UUID(java.util.UUID) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 4 with DeleteObjectResult

use of com.evolveum.midpoint.repo.api.DeleteObjectResult in project midpoint by Evolveum.

the class SqaleRepoAddDeleteObjectTest method test910DeleteUsingSupertypeWorksOk.

@Test
public void test910DeleteUsingSupertypeWorksOk() throws Exception {
    OperationResult result = createOperationResult();
    given("any object existing in the repository");
    // we'll sacrifice one of the users for this
    UUID userOid = randomExistingOid(QUser.class);
    when("deleting the object using its supertype");
    DeleteObjectResult deleteResult = repositoryService.deleteObject(ObjectType.class, userOid.toString(), result);
    then("object is deleted");
    assertThatOperationResult(result).isSuccess();
    assertThat(deleteResult).isNotNull();
    assertThat(deleteResult.getObjectTextRepresentation()).isNotNull();
    assertThat(selectNullableObjectByOid(QUser.class, userOid)).isNull();
}
Also used : DeleteObjectResult(com.evolveum.midpoint.repo.api.DeleteObjectResult) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UUID(java.util.UUID) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

DeleteObjectResult (com.evolveum.midpoint.repo.api.DeleteObjectResult)4 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 Test (org.testng.annotations.Test)4 UUID (java.util.UUID)2 SqlPerformanceMonitorImpl (com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl)1