Search in sources :

Example 1 with ReplaceOptions

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());
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) ReplaceOptions(com.couchbase.client.java.kv.ReplaceOptions) InsertOptions(com.couchbase.client.java.kv.InsertOptions) GetOptions(com.couchbase.client.java.kv.GetOptions) Test(org.junit.jupiter.api.Test)

Example 2 with ReplaceOptions

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();
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) ReplaceOptions(com.couchbase.client.java.kv.ReplaceOptions) InsertOptions(com.couchbase.client.java.kv.InsertOptions) GetOptions(com.couchbase.client.java.kv.GetOptions) Test(org.junit.jupiter.api.Test)

Example 3 with ReplaceOptions

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());
}
Also used : ReplaceOptions(com.couchbase.client.java.kv.ReplaceOptions) Test(org.junit.jupiter.api.Test)

Example 4 with ReplaceOptions

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")));
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) ReplaceOptions(com.couchbase.client.java.kv.ReplaceOptions) Test(org.junit.jupiter.api.Test)

Example 5 with ReplaceOptions

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());
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) ReplaceOptions(com.couchbase.client.java.kv.ReplaceOptions) InsertOptions(com.couchbase.client.java.kv.InsertOptions) GetOptions(com.couchbase.client.java.kv.GetOptions) Test(org.junit.jupiter.api.Test)

Aggregations

ReplaceOptions (com.couchbase.client.java.kv.ReplaceOptions)7 Test (org.junit.jupiter.api.Test)6 Airport (org.springframework.data.couchbase.domain.Airport)5 GetOptions (com.couchbase.client.java.kv.GetOptions)4 InsertOptions (com.couchbase.client.java.kv.InsertOptions)4 ReplaceRequest (com.couchbase.client.core.msg.kv.ReplaceRequest)1