use of com.couchbase.client.java.kv.ReplaceBodyWithXattr in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method replaceBodyWithXattrPathNotFound.
@IgnoreWhen(missesCapabilities = { Capabilities.SUBDOC_REVIVE_DOCUMENT })
@Test
void replaceBodyWithXattrPathNotFound() {
String docId = docId();
JsonObject body = JsonObject.create().put("foo", "bar");
coll.mutateIn(docId, Collections.singletonList(upsert("txn", JsonObject.create().put("stgd", body).put("baz", "qux")).xattr().createPath()), MutateInOptions.mutateInOptions().createAsDeleted(true).accessDeleted(true).storeSemantics(StoreSemantics.INSERT));
try {
coll.mutateIn(docId, Arrays.asList(new ReplaceBodyWithXattr("does_not_exist")), MutateInOptions.mutateInOptions().accessDeleted(true).storeSemantics(StoreSemantics.REVIVE));
fail();
} catch (PathNotFoundException ignored) {
}
}
use of com.couchbase.client.java.kv.ReplaceBodyWithXattr in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method replaceBodyWithXattrWithoutReviveDocument.
@IgnoreWhen(missesCapabilities = { Capabilities.SUBDOC_REVIVE_DOCUMENT })
@Test
void replaceBodyWithXattrWithoutReviveDocument() {
String docId = docId();
JsonObject body = JsonObject.create().put("foo", "bar");
coll.mutateIn(docId, Collections.singletonList(upsert("txn", JsonObject.create().put("stgd", body).put("baz", "qux")).xattr().createPath()), MutateInOptions.mutateInOptions().storeSemantics(StoreSemantics.INSERT));
coll.mutateIn(docId, Arrays.asList(new ReplaceBodyWithXattr("txn.stgd"), MutateInSpec.remove("txn").xattr()), MutateInOptions.mutateInOptions().accessDeleted(true));
GetResult gr = coll.get(docId);
assertEquals(gr.contentAsObject(), body);
}
use of com.couchbase.client.java.kv.ReplaceBodyWithXattr in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method reviveDocumentWithCAS3.
@IgnoreWhen(missesCapabilities = { Capabilities.SUBDOC_REVIVE_DOCUMENT })
@Test
void reviveDocumentWithCAS3() {
String docId = docId();
JsonObject body = JsonObject.create().put("foo", "bar");
MutateInResult mr = coll.mutateIn(docId, Collections.singletonList(upsert("txn", JsonObject.create().put("stgd", body).put("baz", "qux")).xattr().createPath()), MutateInOptions.mutateInOptions().createAsDeleted(true).accessDeleted(true).storeSemantics(StoreSemantics.INSERT));
// Create a CAS mismatch
coll.insert(docId, JsonObject.create());
try {
coll.mutateIn(docId, Arrays.asList(new ReplaceBodyWithXattr("txn.stgd"), MutateInSpec.remove("txn").xattr()), MutateInOptions.mutateInOptions().accessDeleted(true).cas(mr.cas()).storeSemantics(StoreSemantics.REVIVE));
fail();
} catch (CasMismatchException ignored) {
// It hits this rather than CannotReviveAliveDocumentException
}
}
use of com.couchbase.client.java.kv.ReplaceBodyWithXattr in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method reviveDocumentWithCAS.
@IgnoreWhen(missesCapabilities = { Capabilities.SUBDOC_REVIVE_DOCUMENT })
@Test
void reviveDocumentWithCAS() {
String docId = docId();
JsonObject body = JsonObject.create().put("foo", "bar");
MutateInResult mr = coll.mutateIn(docId, Collections.singletonList(upsert("txn", JsonObject.create().put("stgd", body).put("baz", "qux")).xattr().createPath()), MutateInOptions.mutateInOptions().createAsDeleted(true).accessDeleted(true).storeSemantics(StoreSemantics.INSERT));
// Create a CAS mismatch
coll.mutateIn(docId, Collections.singletonList(upsert("txn", JsonObject.create().put("stgd", body).put("baz", "qux")).xattr().createPath()), MutateInOptions.mutateInOptions().accessDeleted(true));
try {
coll.mutateIn(docId, Arrays.asList(new ReplaceBodyWithXattr("txn.stgd"), MutateInSpec.remove("txn").xattr()), MutateInOptions.mutateInOptions().accessDeleted(true).cas(mr.cas()).storeSemantics(StoreSemantics.REVIVE));
fail();
} catch (CasMismatchException ignored) {
}
}
use of com.couchbase.client.java.kv.ReplaceBodyWithXattr in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method replaceBodyWithXattrSimulatingTransactionalInsert.
@IgnoreWhen(missesCapabilities = { Capabilities.SUBDOC_REVIVE_DOCUMENT })
@Test
void replaceBodyWithXattrSimulatingTransactionalInsert() {
String docId = docId();
JsonObject body = JsonObject.create().put("foo", "bar");
coll.mutateIn(docId, Collections.singletonList(upsert("txn", JsonObject.create().put("stgd", body).put("baz", "qux")).xattr().createPath()), MutateInOptions.mutateInOptions().createAsDeleted(true).accessDeleted(true).storeSemantics(StoreSemantics.INSERT));
coll.mutateIn(docId, Arrays.asList(new ReplaceBodyWithXattr("txn.stgd"), MutateInSpec.remove("txn").xattr()), MutateInOptions.mutateInOptions().accessDeleted(true).storeSemantics(StoreSemantics.REVIVE));
GetResult gr = coll.get(docId);
assertEquals(gr.contentAsObject(), body);
}
Aggregations