use of com.couchbase.client.java.kv.MutateInResult 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.MutateInResult 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.MutateInResult in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method xattrOpsAreReordered.
@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void xattrOpsAreReordered() {
JsonObject content = JsonObject.create();
String docId = prepareXattr(content);
MutateInResult result = coll.mutateIn(docId, Arrays.asList(MutateInSpec.insert("foo2", "bar2"), MutateInSpec.increment("x.foo", 5).xattr()));
assertThrows(NoSuchElementException.class, () -> result.contentAs(0, String.class));
assertEquals(5, result.contentAs(1, Integer.class));
}
use of com.couchbase.client.java.kv.MutateInResult 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);
}
use of com.couchbase.client.java.kv.MutateInResult in project couchbase-jvm-clients by couchbase.
the class MutationTokenIntegrationTest method tokenOnSubdocMutate.
@Test
void tokenOnSubdocMutate() {
String id = UUID.randomUUID().toString();
MutationResult result = collection.upsert(id, JsonObject.create());
assertMutationToken(result.mutationToken());
MutateInResult mutateResult = collection.mutateIn(id, Arrays.asList(MutateInSpec.insert("foo", true)));
assertMutationToken(mutateResult.mutationToken());
}
Aggregations