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));
}
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");
}
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);
}
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"));
}
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"));
}
Aggregations