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