use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class CouchbaseArrayListTest method SimpleRoundTripWithJsonObject.
@Test
void SimpleRoundTripWithJsonObject() {
CouchbaseArrayList<JsonObject> list = new CouchbaseArrayList<>(uuid, collection, JsonObject.class, ArrayListOptions.arrayListOptions());
JsonObject thing1 = JsonObject.fromJson("{\"string\":\"foo\", \"integer\":1}");
JsonObject thing2 = JsonObject.fromJson("{\"string\":\"bar\", \"integer\":2}");
list.add(0, thing1);
list.add(0, thing2);
assertEquals(2, list.size());
assertEquals(thing2, list.get(0));
assertEquals(thing1, list.get(1));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class QueryIntegrationTest method reactivePositionalParameterizedSelectQuery.
@Test
void reactivePositionalParameterizedSelectQuery() {
String id = insertDoc();
QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS).parameters(JsonArray.from(id));
Mono<ReactiveQueryResult> result = cluster.reactive().query("select * from " + bucketName + " where meta().id=$1", options);
List<JsonObject> rows = result.flux().flatMap(ReactiveQueryResult::rowsAsObject).collectList().block();
assertNotNull(rows);
assertEquals(1, rows.size());
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class QueryIntegrationTest method asyncNamedParameterizedSelectQuery.
@Test
void asyncNamedParameterizedSelectQuery() throws Exception {
String id = insertDoc();
QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS).parameters(JsonObject.create().put("id", id));
CompletableFuture<QueryResult> result = cluster.async().query("select * from " + bucketName + " where meta().id=$id", options);
List<JsonObject> rows = result.get().rowsAs(JsonObject.class);
assertEquals(1, rows.size());
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class QueryIntegrationTest method asyncSelect.
@Test
void asyncSelect() throws Exception {
String id = insertDoc();
QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS);
CompletableFuture<QueryResult> result = cluster.async().query("select * from " + bucketName + " where meta().id=\"" + id + "\"", options);
List<JsonObject> rows = result.get().rowsAs(JsonObject.class);
assertEquals(1, rows.size());
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class SubdocIntegrationTest method upsertFullDocument.
@Test
void upsertFullDocument() {
String id = UUID.randomUUID().toString();
JsonObject content = JsonObject.create().put("foo", "bar");
collection.mutateIn(id, Arrays.asList(// Server doesn't allow fullDocument to be only op here, get "key not found"
MutateInSpec.upsert("qix", "qux"), MutateInSpec.replace("", content)), MutateInOptions.mutateInOptions().storeSemantics(StoreSemantics.UPSERT));
GetResult doc = collection.get(id);
assertEquals(content, doc.contentAsObject());
}
Aggregations