Search in sources :

Example 11 with JsonObject

use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.

the class JsonSerializerTestBase method encodesJsonObject.

@Test
void encodesJsonObject() {
    JsonObject input = JsonObject.create().put("foo", "bar");
    byte[] output = serializer().serialize(input);
    assertEquals("{\"foo\":\"bar\"}", new String(output, UTF_8));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) Test(org.junit.jupiter.api.Test)

Example 12 with JsonObject

use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.

the class QueryOptionsSmokeTest method testProfile.

@Test
void testProfile() {
    QueryOptions options = QueryOptions.queryOptions().profile(QueryProfile.TIMINGS);
    QueryOptions.Built opts = options.build();
    JsonObject queryJson = JsonObject.create();
    opts.injectParams(queryJson);
    assertEquals(queryJson.get("profile"), "timings");
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) Test(org.junit.jupiter.api.Test)

Example 13 with JsonObject

use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.

the class QueryOptionsSmokeTest method testClientContextId.

@Test
void testClientContextId() {
    String randomId = UUID.randomUUID().toString();
    QueryOptions options = QueryOptions.queryOptions().clientContextId(randomId);
    QueryOptions.Built opts = options.build();
    JsonObject queryJson = JsonObject.create();
    opts.injectParams(queryJson);
    assertEquals(queryJson.get("client_context_id"), randomId);
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) Test(org.junit.jupiter.api.Test)

Example 14 with JsonObject

use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.

the class SearchOptionsTest method injectsTimeout.

@Test
void injectsTimeout() {
    JsonObject output = JsonObject.create();
    searchOptions().build().injectParams("idx", output, Duration.ofSeconds(1));
    assertEquals(1000, output.getObject("ctl").getLong("timeout"));
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject) Test(org.junit.jupiter.api.Test)

Example 15 with JsonObject

use of com.couchbase.client.java.json.JsonObject in project couchbase-jvm-clients by couchbase.

the class SearchOptionsTest method allowToDisableScoring.

/**
 * Makes sure that (only) when scoring is disabled, it shows up in the resulting query.
 */
@Test
void allowToDisableScoring() {
    JsonObject output = JsonObject.create();
    searchOptions().disableScoring(true).build().injectParams("idx", output, Duration.ofSeconds(1));
    assertEquals(output.getString("score"), "none");
    output = JsonObject.create();
    searchOptions().disableScoring(false).build().injectParams("idx", output, Duration.ofSeconds(1));
    assertFalse(output.containsKey("score"));
    output = JsonObject.create();
    searchOptions().build().injectParams("idx", output, Duration.ofSeconds(1));
    assertFalse(output.containsKey("score"));
}
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