Search in sources :

Example 6 with MShadow

use of com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow in project midpoint by Evolveum.

the class SqaleRepoModifyObjectTest method test152PendingOperationCountStoresZeroForEmptyContainer.

@Test
public void test152PendingOperationCountStoresZeroForEmptyContainer() throws Exception {
    OperationResult result = createOperationResult();
    given("delta clearing the pending operation container for shadow 1");
    ObjectDelta<ShadowType> delta = prismContext.deltaFor(ShadowType.class).item(ShadowType.F_PENDING_OPERATION).replace().asObjectDelta(shadow1Oid);
    and("shadow row previously having non-zero count of pending operations");
    MShadow originalRow = selectObjectByOid(QShadow.class, shadow1Oid);
    assertThat(originalRow.pendingOperationCount).isNotZero();
    when("modifyObject is called");
    repositoryService.modifyObject(ShadowType.class, shadow1Oid, delta.getModifications(), result);
    then("operation is successful");
    assertThatOperationResult(result).isSuccess();
    and("serialized form (fullObject) is updated");
    ShadowType shadowObject = repositoryService.getObject(ShadowType.class, shadow1Oid, null, result).asObjectable();
    assertThat(shadowObject.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
    assertThat(shadowObject.getPendingOperation()).isNullOrEmpty();
    and("externalized column is updated to zero, not null");
    MShadow row = selectObjectByOid(QShadow.class, shadow1Oid);
    assertThat(row.version).isEqualTo(originalRow.version + 1);
    assertThat(row.pendingOperationCount).isZero();
}
Also used : MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 7 with MShadow

use of com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow in project midpoint by Evolveum.

the class SqaleRepoModifyObjectTest method test150PendingOperationCountColumn.

@Test
public void test150PendingOperationCountColumn() throws Exception {
    OperationResult result = createOperationResult();
    given("delta adding a pending operation for shadow 1");
    ObjectDelta<ShadowType> delta = prismContext.deltaFor(ShadowType.class).item(ShadowType.F_PENDING_OPERATION).add(new PendingOperationType(prismContext).requestTimestamp(MiscUtil.asXMLGregorianCalendar(1L))).asObjectDelta(shadow1Oid);
    and("shadow row previously having zero count of pending operations");
    MShadow originalRow = selectObjectByOid(QShadow.class, shadow1Oid);
    assertThat(originalRow.pendingOperationCount).isZero();
    when("modifyObject is called");
    repositoryService.modifyObject(ShadowType.class, shadow1Oid, delta.getModifications(), result);
    then("operation is successful");
    assertThatOperationResult(result).isSuccess();
    and("serialized form (fullObject) is updated");
    ShadowType shadowObject = repositoryService.getObject(ShadowType.class, shadow1Oid, null, result).asObjectable();
    assertThat(shadowObject.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
    assertThat(shadowObject.getPendingOperation()).hasSize(1);
    and("externalized column is updated");
    MShadow row = selectObjectByOid(QShadow.class, shadow1Oid);
    assertThat(row.version).isEqualTo(originalRow.version + 1);
    assertThat(row.pendingOperationCount).isEqualTo(1);
}
Also used : MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)7 MShadow (com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 Test (org.testng.annotations.Test)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 QName (javax.xml.namespace.QName)2 UUID (java.util.UUID)1