Search in sources :

Example 1 with JsonObject

use of com.couchbase.client.java.json.JsonObject in project ShedLock by lukas-krecan.

the class CouchbaseLockProviderIntegrationTest method assertLocked.

@Override
public void assertLocked(String lockName) {
    GetResult result = bucket.defaultCollection().get(lockName);
    JsonObject lockDocument = result.contentAsObject();
    assertThat(parse((String) lockDocument.get(LOCK_UNTIL))).isAfter(now());
    assertThat(parse((String) lockDocument.get(LOCKED_AT))).isBeforeOrEqualTo(now());
    assertThat(lockDocument.get(LOCKED_BY)).asString().isNotEmpty();
}
Also used : GetResult(com.couchbase.client.java.kv.GetResult) JsonObject(com.couchbase.client.java.json.JsonObject)

Example 2 with JsonObject

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

the class ConjunctionQuery method injectParams.

@Override
protected void injectParams(JsonObject input) {
    if (childQueries.isEmpty()) {
        throw InvalidArgumentException.fromMessage("Compound query has no child query");
    }
    JsonArray conjuncts = JsonArray.create();
    for (SearchQuery childQuery : childQueries) {
        JsonObject childJson = JsonObject.create();
        childQuery.injectParamsAndBoost(childJson);
        conjuncts.add(childJson);
    }
    input.put("conjuncts", conjuncts);
}
Also used : JsonArray(com.couchbase.client.java.json.JsonArray) SearchQuery(com.couchbase.client.java.search.SearchQuery) JsonObject(com.couchbase.client.java.json.JsonObject)

Example 3 with JsonObject

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

the class DisjunctionQuery method injectParams.

@Override
protected void injectParams(JsonObject input) {
    if (childQueries.isEmpty()) {
        throw InvalidArgumentException.fromMessage("Compound query has no child query");
    }
    if (childQueries.size() < min) {
        throw InvalidArgumentException.fromMessage("Disjunction query as fewer children than the configured minimum " + min);
    }
    if (min > 0) {
        input.put("min", min);
    }
    JsonArray disjuncts = JsonArray.create();
    for (SearchQuery childQuery : childQueries) {
        JsonObject childJson = JsonObject.create();
        childQuery.injectParamsAndBoost(childJson);
        disjuncts.add(childJson);
    }
    input.put("disjuncts", disjuncts);
}
Also used : JsonArray(com.couchbase.client.java.json.JsonArray) SearchQuery(com.couchbase.client.java.search.SearchQuery) JsonObject(com.couchbase.client.java.json.JsonObject)

Example 4 with JsonObject

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

the class SearchQuery method toString.

/**
 * @return the String representation of the FTS query, which is its JSON representation without global parameters.
 */
@Override
public String toString() {
    JsonObject json = JsonObject.create();
    injectParamsAndBoost(json);
    return json.toString();
}
Also used : JsonObject(com.couchbase.client.java.json.JsonObject)

Example 5 with JsonObject

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

the class DateRangeFacet method injectParams.

@Override
public void injectParams(JsonObject queryJson) {
    super.injectParams(queryJson);
    JsonArray dateRange = JsonArray.create();
    for (DateRange dr : dateRanges) {
        JsonObject drJson = JsonObject.create();
        drJson.put("name", dr.name());
        if (dr.start() != null) {
            drJson.put("start", dr.start());
        }
        if (dr.end() != null) {
            drJson.put("end", dr.end());
        }
        dateRange.add(drJson);
    }
    queryJson.put("date_ranges", dateRange);
}
Also used : JsonArray(com.couchbase.client.java.json.JsonArray) JsonObject(com.couchbase.client.java.json.JsonObject)

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