Search in sources :

Example 1 with ReactiveAirportRepository

use of org.springframework.data.couchbase.domain.ReactiveAirportRepository in project spring-data-couchbase by spring-projects.

the class ReactiveCouchbaseRepositoryQueryCollectionIntegrationTests method findBySimplePropertyWithOptions.

@Test
void findBySimplePropertyWithOptions() {
    Airport vie = new Airport("airports::vie", "vie", "loww");
    ReactiveAirportRepository ar = airportRepository.withScope(scopeName).withCollection(collectionName);
    JsonArray positionalParams = JsonArray.create().add("\"this parameter will be overridden\"");
    try {
        Airport saved = ar.save(vie).block();
        Airport airport3 = ar.withOptions(QueryOptions.queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS).parameters(positionalParams)).iata(vie.getIata()).block();
        assertEquals(saved, airport3);
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    } finally {
        ar.delete(vie).block();
    }
}
Also used : JsonArray(com.couchbase.client.java.json.JsonArray) Airport(org.springframework.data.couchbase.domain.Airport) ReactiveAirportRepository(org.springframework.data.couchbase.domain.ReactiveAirportRepository) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) IndexFailureException(com.couchbase.client.core.error.IndexFailureException) Test(org.junit.jupiter.api.Test)

Example 2 with ReactiveAirportRepository

use of org.springframework.data.couchbase.domain.ReactiveAirportRepository in project spring-data-couchbase by spring-projects.

the class ReactiveCouchbaseRepositoryQueryCollectionIntegrationTests method myTest.

@Test
public void myTest() {
    ReactiveAirportRepository ar = airportRepository.withScope(scopeName).withCollection(collectionName);
    Airport vie = new Airport("airports::vie", "vie", "loww");
    try {
        Airport saved = ar.save(vie).block();
        Airport airport2 = ar.save(saved).block();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    } finally {
        ar.delete(vie).block();
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) ReactiveAirportRepository(org.springframework.data.couchbase.domain.ReactiveAirportRepository) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) IndexFailureException(com.couchbase.client.core.error.IndexFailureException) Test(org.junit.jupiter.api.Test)

Example 3 with ReactiveAirportRepository

use of org.springframework.data.couchbase.domain.ReactiveAirportRepository in project spring-data-couchbase by spring-projects.

the class ReactiveCouchbaseRepositoryQueryCollectionIntegrationTests method findBySimplePropertyWithCollection.

/**
 * can test against _default._default without setting up additional scope/collection and also test for collections and
 * scopes that do not exist These same tests should be repeated on non-default scope and collection in a test that
 * supports collections
 */
@Test
@IgnoreWhen(missesCapabilities = { Capabilities.QUERY, Capabilities.COLLECTIONS }, clusterTypes = ClusterType.MOCKED)
void findBySimplePropertyWithCollection() {
    Airport vie = new Airport("airports::vie", "vie", "loww");
    // create proxy with scope, collection
    ReactiveAirportRepository ar = airportRepository.withScope(scopeName).withCollection(collectionName);
    try {
        Airport saved = ar.save(vie).block();
        // valid scope, collection in options
        Airport airport2 = ar.withOptions(QueryOptions.queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS)).iata(vie.getIata()).block();
        assertEquals(saved, airport2);
        // given bad collectionName in fluent
        assertThrows(IndexFailureException.class, () -> ar.withCollection("bogusCollection").iata(vie.getIata()).block());
        // given bad scopeName in fluent
        assertThrows(IndexFailureException.class, () -> ar.withScope("bogusScope").iata(vie.getIata()).block());
        Airport airport6 = ar.withOptions(QueryOptions.queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS)).iata(vie.getIata()).block();
        assertEquals(saved, airport6);
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    } finally {
        ar.deleteAll().block();
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) ReactiveAirportRepository(org.springframework.data.couchbase.domain.ReactiveAirportRepository) DataRetrievalFailureException(org.springframework.dao.DataRetrievalFailureException) IndexFailureException(com.couchbase.client.core.error.IndexFailureException) IgnoreWhen(org.springframework.data.couchbase.util.IgnoreWhen) Test(org.junit.jupiter.api.Test)

Aggregations

IndexFailureException (com.couchbase.client.core.error.IndexFailureException)3 Test (org.junit.jupiter.api.Test)3 DataRetrievalFailureException (org.springframework.dao.DataRetrievalFailureException)3 Airport (org.springframework.data.couchbase.domain.Airport)3 ReactiveAirportRepository (org.springframework.data.couchbase.domain.ReactiveAirportRepository)3 JsonArray (com.couchbase.client.java.json.JsonArray)1 IgnoreWhen (org.springframework.data.couchbase.util.IgnoreWhen)1