use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method counterAddXattrCreatePath.
// TODO failing with bad input server error
// @Test
// public void arrayInsertXattrCreatePath() {
// JsonObject updatedContent = checkSingleOpSuccessXattr(JsonObject.create(),
// Arrays.asList(MutateInSpec.arrayInsert(true, "x.foo[0]", "cruel", true));
// assertEquals(JsonArray.from("cruel"), updatedContent.getArray("foo"));
// }
//
// @Test
// public void arrayInsertUniqueDoesNotExistXattrCreatePath() {
// JsonObject updatedContent = checkSingleOpSuccessXattr(JsonObject.create(),
// Arrays.asList(MutateInSpec.arrayAddUnique(true, "x.foo", "cruel", true));
// assertEquals(JsonArray.from("hello", "world", "cruel"), updatedContent.getArray("foo"));
// }
@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void counterAddXattrCreatePath() {
JsonObject updatedContent = checkSingleOpSuccessXattr(JsonObject.create(), Arrays.asList(MutateInSpec.increment("x.foo", 5).xattr().createPath()));
assertEquals(5, (int) updatedContent.getInt("foo"));
}
use of com.couchbase.client.java.json.JsonObject 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.json.JsonObject 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.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method reviveDocumentWithoutAccessDeleted.
@IgnoreWhen(missesCapabilities = { Capabilities.SUBDOC_REVIVE_DOCUMENT })
@Test
void reviveDocumentWithoutAccessDeleted() {
String docId = docId();
JsonObject body = JsonObject.create().put("foo", "bar");
coll.insert(docId, body);
try {
coll.mutateIn(docId, Collections.singletonList(upsert("foo", "bar").xattr()), MutateInOptions.mutateInOptions().storeSemantics(StoreSemantics.REVIVE));
fail();
} catch (CouchbaseException err) {
// "ReviveDocument can’t be used without AccessDeleted"
}
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method removeXattr.
@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void removeXattr() {
JsonObject updatedContent = checkSingleOpSuccessXattr(JsonObject.create().put("foo", "bar"), Arrays.asList(MutateInSpec.remove("x.foo").xattr()));
assertFalse(updatedContent.containsKey("foo"));
}
Aggregations