use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class NumericRangeFacet method injectParams.
@Override
public void injectParams(JsonObject queryJson) {
super.injectParams(queryJson);
JsonArray numericRange = JsonArray.create();
for (NumericRange nr : ranges) {
JsonObject nrJson = JsonObject.create();
nrJson.put("name", nr.name());
if (nr.min() != null) {
nrJson.put("min", nr.min());
}
if (nr.max() != null) {
nrJson.put("max", nr.max());
}
numericRange.add(nrJson);
}
queryJson.put("numeric_ranges", numericRange);
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class AnalyticsOptionsTest method testAlwaysSetClientContextId.
@Test
void testAlwaysSetClientContextId() {
JsonObject result = build(analyticsOptions());
assertNotNull(result.getString("client_context_id"));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class AnalyticsOptionsTest method build.
private static JsonObject build(final AnalyticsOptions options) {
JsonObject export = JsonObject.create();
options.build().injectParams(export);
return export;
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class AnalyticsOptionsTest method testCustomClientContextId.
@Test
void testCustomClientContextId() {
JsonObject result = build(analyticsOptions().clientContextId("customClientContextId"));
assertEquals("customClientContextId", result.getString("client_context_id"));
}
use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.
the class AnalyticsOptionsTest method testScanWait.
@Test
void testScanWait() {
JsonObject result = build(analyticsOptions().scanWait(Duration.ofSeconds(2)).scanConsistency(AnalyticsScanConsistency.REQUEST_PLUS));
assertEquals("2000ms", result.getString("scan_wait"));
result = build(analyticsOptions().scanWait(Duration.ofSeconds(2)));
assertFalse(result.containsKey("scan_wait"));
result = build(analyticsOptions().scanWait(Duration.ofSeconds(2)).scanConsistency(AnalyticsScanConsistency.NOT_BOUNDED));
assertFalse(result.containsKey("scan_wait"));
}
Aggregations