use of com.couchbase.client.java.kv.ReplaceOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method replaceByIdOther.
@Test
public void replaceByIdOther() {
// 9
InsertOptions insertOptions = InsertOptions.insertOptions().timeout(Duration.ofSeconds(10));
ReplaceOptions options = ReplaceOptions.replaceOptions().timeout(Duration.ofSeconds(10));
GetOptions getOptions = GetOptions.getOptions().timeout(Duration.ofSeconds(10));
Airport saved = couchbaseTemplate.insertById(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(insertOptions).one(vie.withIcao("661"));
Airport replaced = couchbaseTemplate.replaceById(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(options).one(vie.withIcao("newIcao"));
try {
Airport found = couchbaseTemplate.findById(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(getOptions).one(saved.getId());
assertEquals(replaced, found);
} finally {
couchbaseTemplate.removeById().inScope(otherScope).inCollection(otherCollection).one(saved.getId());
}
}
use of com.couchbase.client.java.kv.ReplaceOptions in project spring-data-couchbase by spring-projects.
the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method replaceByIdOther.
@Test
public void replaceByIdOther() {
// 9
InsertOptions insertOptions = InsertOptions.insertOptions().timeout(Duration.ofSeconds(10));
ReplaceOptions options = ReplaceOptions.replaceOptions().timeout(Duration.ofSeconds(10));
GetOptions getOptions = GetOptions.getOptions().timeout(Duration.ofSeconds(10));
Airport saved = template.insertById(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(insertOptions).one(vie.withIcao("lown")).block();
Airport replaced = template.replaceById(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(options).one(vie.withIcao("newIcao")).block();
try {
Airport found = template.findById(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(getOptions).one(saved.getId()).block();
assertEquals(replaced, found);
} finally {
template.removeById().inScope(otherScope).inCollection(otherCollection).one(saved.getId()).block();
}
}
use of com.couchbase.client.java.kv.ReplaceOptions in project spring-data-couchbase by spring-projects.
the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method replaceByIdOptions.
@Test
public void replaceByIdOptions() {
// 9 - options
ReplaceOptions options = ReplaceOptions.replaceOptions().timeout(Duration.ofNanos(10));
assertThrows(AmbiguousTimeoutException.class, () -> template.replaceById(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(options).one(vie.withIcao("newIcao")).block());
}
use of com.couchbase.client.java.kv.ReplaceOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method replaceByIdOptions.
@Test
public void replaceByIdOptions() {
// 9 - options
ReplaceOptions options = ReplaceOptions.replaceOptions().timeout(Duration.ofNanos(10));
assertThrows(AmbiguousTimeoutException.class, () -> couchbaseTemplate.replaceById(Airport.class).inScope(otherScope).inCollection(otherCollection).withOptions(options).one(vie.withIcao("newIcao")));
}
use of com.couchbase.client.java.kv.ReplaceOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method replaceById.
@Test
public void replaceById() {
// 9
InsertOptions insertOptions = InsertOptions.insertOptions().timeout(Duration.ofSeconds(10));
ReplaceOptions options = ReplaceOptions.replaceOptions().timeout(Duration.ofSeconds(10));
GetOptions getOptions = GetOptions.getOptions().timeout(Duration.ofSeconds(10));
Airport saved = couchbaseTemplate.insertById(Airport.class).inScope(scopeName).inCollection(collectionName).withOptions(insertOptions).one(vie.withIcao("508"));
Airport replaced = couchbaseTemplate.replaceById(Airport.class).inScope(scopeName).inCollection(collectionName).withOptions(options).one(vie.withIcao("newIcao"));
try {
Airport found = couchbaseTemplate.findById(Airport.class).inScope(scopeName).inCollection(collectionName).withOptions(getOptions).one(saved.getId());
assertEquals(replaced, found);
} finally {
couchbaseTemplate.removeById().inScope(scopeName).inCollection(collectionName).one(saved.getId());
}
}
Aggregations