Search in sources :

Example 6 with ConflictWatcherImpl

use of com.evolveum.midpoint.repo.sqlbase.ConflictWatcherImpl in project midpoint by Evolveum.

the class AddGetObjectTest method test203WatcherOverwriteWithOidAndVersion.

@Test
public void test203WatcherOverwriteWithOidAndVersion() throws Exception {
    OperationResult result = createOperationResult();
    // GIVEN
    UserType user = new UserType(prismContext).name("t200").oid(OID_200).version("1000");
    // WHEN
    ConflictWatcherImpl watcher = (ConflictWatcherImpl) repositoryService.createAndRegisterConflictWatcher(OID_200);
    repositoryService.addObject(user.asPrismObject(), RepoAddOptions.createOverwrite(), result);
    // THEN
    assertTrue("watcher is not initialized", watcher.isInitialized());
    assertFalse("watcher is marked as deleted", watcher.isObjectDeleted());
    // the version is ignored when overwriting
    assertEquals("expectedVersion is wrong", 3, watcher.getExpectedVersion());
    boolean hasConflict = repositoryService.hasConflict(watcher, result);
    assertFalse("false conflict reported for " + watcher, hasConflict);
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ConflictWatcherImpl(com.evolveum.midpoint.repo.sqlbase.ConflictWatcherImpl) Test(org.testng.annotations.Test)

Example 7 with ConflictWatcherImpl

use of com.evolveum.midpoint.repo.sqlbase.ConflictWatcherImpl in project midpoint by Evolveum.

the class AddGetObjectTest method test200WatcherAddWithOid.

@Test
public void test200WatcherAddWithOid() throws Exception {
    OperationResult result = new OperationResult("test200WatcherAddWithOid");
    // GIVEN
    UserType user = new UserType(prismContext).name("t200").oid(OID_200);
    // WHEN
    ConflictWatcherImpl watcher = (ConflictWatcherImpl) repositoryService.createAndRegisterConflictWatcher(OID_200);
    repositoryService.addObject(user.asPrismObject(), null, result);
    // THEN
    assertTrue("watcher is not initialized", watcher.isInitialized());
    assertFalse("watcher is marked as deleted", watcher.isObjectDeleted());
    assertEquals("expectedVersion is wrong", 0, watcher.getExpectedVersion());
    boolean hasConflict = repositoryService.hasConflict(watcher, result);
    assertFalse("false conflict reported for " + watcher, hasConflict);
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ConflictWatcherImpl(com.evolveum.midpoint.repo.sqlbase.ConflictWatcherImpl) Test(org.testng.annotations.Test)

Example 8 with ConflictWatcherImpl

use of com.evolveum.midpoint.repo.sqlbase.ConflictWatcherImpl in project midpoint by Evolveum.

the class AddGetObjectTest method test210WatcherAddWithOidAndVersion.

@Test
public void test210WatcherAddWithOidAndVersion() throws Exception {
    OperationResult result = createOperationResult();
    // GIVEN
    final String OID = "f82cdad5-8748-43c1-b20b-7f679fbc1995";
    UserType user = new UserType(prismContext).name("t210").oid(OID).version("443");
    // WHEN
    ConflictWatcherImpl watcher = (ConflictWatcherImpl) repositoryService.createAndRegisterConflictWatcher(OID);
    repositoryService.addObject(user.asPrismObject(), null, result);
    // THEN
    assertTrue("watcher is not initialized", watcher.isInitialized());
    assertFalse("watcher is marked as deleted", watcher.isObjectDeleted());
    assertEquals("expectedVersion is wrong", 443, watcher.getExpectedVersion());
    boolean hasConflict = repositoryService.hasConflict(watcher, result);
    assertFalse("false conflict reported for " + watcher, hasConflict);
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ConflictWatcherImpl(com.evolveum.midpoint.repo.sqlbase.ConflictWatcherImpl) Test(org.testng.annotations.Test)

Example 9 with ConflictWatcherImpl

use of com.evolveum.midpoint.repo.sqlbase.ConflictWatcherImpl in project midpoint by Evolveum.

the class AddGetObjectTest method test220WatcherAddWithNoOidNorVersion.

@Test
public void test220WatcherAddWithNoOidNorVersion() throws Exception {
    OperationResult result = createOperationResult();
    // GIVEN
    UserType user = new UserType(prismContext).name("t220");
    // WHEN
    String oid = repositoryService.addObject(user.asPrismObject(), null, result);
    ConflictWatcherImpl watcher = (ConflictWatcherImpl) repositoryService.createAndRegisterConflictWatcher(oid);
    // the version should be set by repo here
    watcher.setExpectedVersion(user.getVersion());
    // THEN
    assertTrue("watcher is not initialized", watcher.isInitialized());
    assertFalse("watcher is marked as deleted", watcher.isObjectDeleted());
    assertEquals("expectedVersion is wrong", 0, watcher.getExpectedVersion());
    boolean hasConflict = repositoryService.hasConflict(watcher, result);
    assertFalse("false conflict reported for " + watcher, hasConflict);
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ConflictWatcherImpl(com.evolveum.midpoint.repo.sqlbase.ConflictWatcherImpl) Test(org.testng.annotations.Test)

Aggregations

ConflictWatcherImpl (com.evolveum.midpoint.repo.sqlbase.ConflictWatcherImpl)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 Test (org.testng.annotations.Test)7 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3