use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method removeFullDocAndSetSystemXattr.
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
@Test
void removeFullDocAndSetSystemXattr() {
JsonObject content = JsonObject.create().put("foo", "bar");
String docId = prepare(content);
// leading underscore lets it survive document deletion
String systemXattrName = "_x";
coll.mutateIn(docId, listOf(MutateInSpec.remove(""), MutateInSpec.insert(systemXattrName, "y").xattr()));
LookupInResult result = coll.lookupIn(docId, listOf(LookupInSpec.get(systemXattrName).xattr()), LookupInOptions.lookupInOptions().accessDeleted(true));
assertEquals("y", result.contentAs(0, String.class));
assertTrue(result.isDeleted());
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method reviveDocumentWithCAS2.
@IgnoreWhen(missesCapabilities = { Capabilities.SUBDOC_REVIVE_DOCUMENT })
@Test
void reviveDocumentWithCAS2() {
String docId = docId();
JsonObject body = JsonObject.create().put("foo", "bar");
coll.insert(docId, body);
MutationResult mr = coll.remove(docId);
coll.mutateIn(docId, Arrays.asList(// Do a dummy op as server complains if do nothing
MutateInSpec.upsert("txn", JsonObject.create()).xattr()), MutateInOptions.mutateInOptions().accessDeleted(true).cas(mr.cas()).storeSemantics(StoreSemantics.REVIVE));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method insertCreatePath.
@Test
void insertCreatePath() {
JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create(), Arrays.asList(MutateInSpec.insert("foo.baz", "bar2").createPath()));
assertEquals("bar2", updatedContent.getObject("foo").getString("baz"));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method insertExpandMacroXattrDoNotFlag.
@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void insertExpandMacroXattrDoNotFlag() {
JsonObject updatedContent = checkSingleOpSuccessXattr(JsonObject.create(), Arrays.asList(MutateInSpec.insert("x.foo", "${Mutation.CAS}").xattr()));
assertEquals("${Mutation.CAS}", updatedContent.getString("foo"));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method counterAdd.
@Test
void counterAdd() {
JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create().put("foo", 10), Arrays.asList(MutateInSpec.increment("foo", 5)));
assertEquals(15, (int) updatedContent.getInt("foo"));
}
Aggregations