use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocIntegrationTest method counterMulti.
@Test
void counterMulti() {
JsonObject initial = JsonObject.create().put("mutated", 0).put("body", "").put("first_name", "James").put("age", 0);
String id = UUID.randomUUID().toString();
collection.upsert(id, initial);
MutateInResult result = collection.mutateIn(id, Arrays.asList(MutateInSpec.upsert("addr", JsonObject.create().put("state", "NV").put("pincode", 7).put("city", "Chicago")), MutateInSpec.increment("mutated", 1), MutateInSpec.upsert("name", JsonObject.create().put("last", "").put("first", "James"))));
assertEquals(1, result.contentAs(1, Integer.class));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method counterMinusXattrCreatePath.
@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void counterMinusXattrCreatePath() {
JsonObject updatedContent = checkSingleOpSuccessXattr(JsonObject.create(), Arrays.asList(MutateInSpec.decrement("x.foo", 3).xattr().createPath()));
assertEquals(-3, (int) updatedContent.getInt("foo"));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method counterAddCreatePath.
// TODO failing with bad input server error
// @Test
// public void arrayInsertCreatePath() {
// JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create(),
// Arrays.asList(MutateInSpec.arrayInsert("foo[0]", "cruel", true));
// assertEquals(JsonArray.from("cruel"), updatedContent.getArray("foo"));
// }
//
// @Test
// public void arrayInsertUniqueDoesNotExistCreatePath() {
// JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create(),
// Arrays.asList(MutateInSpec.arrayAddUnique("foo", "cruel", true));
// assertEquals(JsonArray.from("hello", "world", "cruel"), updatedContent.getArray("foo"));
// }
@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void counterAddCreatePath() {
JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create(), Arrays.asList(MutateInSpec.increment("foo", 5).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 upsertStringDoesNotExistXattr.
@Test
void upsertStringDoesNotExistXattr() {
JsonObject updatedContent = checkSingleOpSuccessXattr(JsonObject.create(), Arrays.asList(upsert("x.foo", "bar2").xattr()));
assertEquals("bar2", updatedContent.getString("foo"));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocMutateIntegrationTest method arrayAppendCreatePath.
@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void arrayAppendCreatePath() {
JsonObject updatedContent = checkSingleOpSuccess(JsonObject.create(), Arrays.asList(MutateInSpec.arrayAppend("foo", Arrays.asList("world")).createPath()));
assertEquals(JsonArray.from("world"), updatedContent.getArray("foo"));
}
Aggregations