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);
}
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);
}
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);
}
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);
}
Aggregations