use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method replaceFullDocument.
@Test
void replaceFullDocument() {
JsonObject content = JsonObject.create().put("foo", "bar");
String docId = prepare(content);
coll.mutateIn(docId, Arrays.asList(MutateInSpec.replace("", JsonObject.create().put("foo2", "bar2"))));
assertEquals("bar2", getContent(docId).getString("foo2"));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method arrayPrepend.
@Test
public void arrayPrepend() {
JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create().put("foo", JsonArray.from("hello")), Arrays.asList(MutateInSpec.arrayPrepend("foo", Arrays.asList("world"))));
assertEquals(JsonArray.from("world", "hello"), updatedContent.getArray("foo"));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method arrayPrependMulti.
@Test
public void arrayPrependMulti() {
JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create().put("foo", JsonArray.from("hello")), Arrays.asList(MutateInSpec.arrayPrepend("foo", Arrays.asList("world", "mars"))));
assertEquals(JsonArray.from("world", "mars", "hello"), updatedContent.getArray("foo"));
}
use of com.couchbase.client.java.json.JsonObject 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.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method upsertStringDoesNotExist.
@Test
void upsertStringDoesNotExist() {
JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create(), Arrays.asList(upsert("foo", "bar2")));
assertEquals("bar2", updatedContent.getString("foo"));
}
Aggregations