Search in sources :

Example 1 with Collection

use of com.couchbase.client.java.Collection in project spring-boot by spring-projects.

the class CouchbaseAutoConfigurationIntegrationTests method whenCouchbaseIsUsingCustomObjectMapperThenJsonCanBeRoundTripped.

@Test
void whenCouchbaseIsUsingCustomObjectMapperThenJsonCanBeRoundTripped() {
    this.contextRunner.withBean(ObjectMapper.class, ObjectMapper::new).run((context) -> {
        Cluster cluster = context.getBean(Cluster.class);
        Bucket bucket = cluster.bucket(BUCKET_NAME);
        bucket.waitUntilReady(Duration.ofMinutes(5));
        Collection collection = bucket.defaultCollection();
        collection.insert("test-document", JsonObject.create().put("a", "alpha"));
        assertThat(collection.get("test-document").contentAsObject().get("a")).isEqualTo("alpha");
    });
}
Also used : Bucket(com.couchbase.client.java.Bucket) Cluster(com.couchbase.client.java.Cluster) Collection(com.couchbase.client.java.Collection) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Aggregations

Bucket (com.couchbase.client.java.Bucket)1 Cluster (com.couchbase.client.java.Cluster)1 Collection (com.couchbase.client.java.Collection)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Test (org.junit.jupiter.api.Test)1