Search in sources :

Example 6 with ReplaceBodyWithXattr

use of com.couchbase.client.java.kv.ReplaceBodyWithXattr in project couchbase-jvm-clients by couchbase.

the class SubdocMutateIntegrationTest method replaceBodyWithXattrSimulatingTransactionalReplace.

@IgnoreWhen(missesCapabilities = { Capabilities.SUBDOC_REPLACE_BODY_WITH_XATTR })
@Test
void replaceBodyWithXattrSimulatingTransactionalReplace() {
    String docId = docId();
    JsonObject body = JsonObject.create().put("foo", "bar");
    coll.upsert(docId, JsonObject.create());
    MutateInResult mr = coll.mutateIn(docId, Collections.singletonList(upsert("txn", JsonObject.create().put("stgd", body).put("baz", "qux")).xattr().createPath()), MutateInOptions.mutateInOptions().accessDeleted(true));
    coll.mutateIn(docId, Arrays.asList(new ReplaceBodyWithXattr("txn.stgd"), MutateInSpec.remove("txn").xattr()), MutateInOptions.mutateInOptions().cas(mr.cas()));
    GetResult gr = coll.get(docId);
    assertEquals(gr.contentAsObject(), body);
}
Also used : MutateInResult(com.couchbase.client.java.kv.MutateInResult) GetResult(com.couchbase.client.java.kv.GetResult) JsonObject(com.couchbase.client.java.json.JsonObject) ReplaceBodyWithXattr(com.couchbase.client.java.kv.ReplaceBodyWithXattr) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

JsonObject (com.couchbase.client.java.json.JsonObject)6 ReplaceBodyWithXattr (com.couchbase.client.java.kv.ReplaceBodyWithXattr)6 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)6 IgnoreWhen (com.couchbase.client.test.IgnoreWhen)6 Test (org.junit.jupiter.api.Test)6 GetResult (com.couchbase.client.java.kv.GetResult)3 MutateInResult (com.couchbase.client.java.kv.MutateInResult)3 CasMismatchException (com.couchbase.client.core.error.CasMismatchException)2 PathNotFoundException (com.couchbase.client.core.error.subdoc.PathNotFoundException)1