Search in sources :

Example 6 with JsonObject

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);
}
Also used : JsonArray(com.couchbase.client.java.json.JsonArray) JsonObject(com.couchbase.client.java.json.JsonObject)

Example 7 with JsonObject

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"));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) Test(org.junit.jupiter.api.Test)

Example 8 with JsonObject

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;
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject)

Example 9 with JsonObject

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"));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) Test(org.junit.jupiter.api.Test)

Example 10 with JsonObject

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"));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) Test(org.junit.jupiter.api.Test)

Aggregations

JsonObject (com.couchbase.client.java.json.JsonObject)189 Test (org.junit.jupiter.api.Test)145 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)119 IgnoreWhen (com.couchbase.client.test.IgnoreWhen)39 JsonArray (com.couchbase.client.java.json.JsonArray)18 QueryResult (com.couchbase.client.java.query.QueryResult)16 GetResult (com.couchbase.client.java.kv.GetResult)15 MutationResult (com.couchbase.client.java.kv.MutationResult)15 QueryOptions (com.couchbase.client.java.query.QueryOptions)15 ReactiveQueryResult (com.couchbase.client.java.query.ReactiveQueryResult)15 RequestSpan (com.couchbase.client.core.cnc.RequestSpan)6 RetryStrategy (com.couchbase.client.core.retry.RetryStrategy)6 Collection (com.couchbase.client.java.Collection)6 ReplaceBodyWithXattr (com.couchbase.client.java.kv.ReplaceBodyWithXattr)6 Duration (java.time.Duration)6 DisplayName (org.junit.jupiter.api.DisplayName)6 CouchbaseUtilTest (org.talend.components.couchbase.CouchbaseUtilTest)6 ArrayList (java.util.ArrayList)5 TestData (org.talend.components.couchbase.TestData)5 MutateInResult (com.couchbase.client.java.kv.MutateInResult)4