DATACOUCH-595 - Add cas to replace options if present on entity.
This commit is contained in:
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.dao.DataRetrievalFailureException;
|
||||
import org.springframework.dao.DataIntegrityViolationException;;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.data.couchbase.CouchbaseClientFactory;
|
||||
import org.springframework.data.couchbase.SimpleCouchbaseClientFactory;
|
||||
@@ -74,6 +74,12 @@ class CouchbaseTemplateKeyValueIntegrationTests extends ClusterAwareIntegrationT
|
||||
User modified = couchbaseTemplate.upsertById(User.class).one(user);
|
||||
assertEquals(user, modified);
|
||||
|
||||
modified = couchbaseTemplate.replaceById(User.class).one(user);
|
||||
assertEquals(user, modified);
|
||||
|
||||
user.setVersion(12345678);
|
||||
assertThrows(DataIntegrityViolationException.class, () -> couchbaseTemplate.replaceById(User.class).one(user));
|
||||
|
||||
User found = couchbaseTemplate.findById(User.class).one(user.getId());
|
||||
assertEquals(user, found);
|
||||
|
||||
|
||||
@@ -85,6 +85,10 @@ public class User {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
|
||||
Reference in New Issue
Block a user