use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class QueryIntegrationTest method handlesPreparedStatements.
/**
* This test is intentionally kept generic, since we want to make sure with every query version
* that we run against we have a version that works. Also, we perform the same query multiple times
* to make sure a primed and non-primed cache both work out of the box.
*/
@Test
void handlesPreparedStatements() {
String id = insertDoc();
for (int i = 0; i < 10; i++) {
QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS).adhoc(false);
QueryResult result = cluster.query("select " + bucketName + ".* from " + bucketName + " where meta().id=\"" + id + "\"", options);
List<JsonObject> rows = result.rowsAs(JsonObject.class);
assertEquals(1, rows.size());
assertEquals(FOO_CONTENT, rows.get(0));
}
}
use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class QueryIntegrationTest method blockingSelect.
@Test
void blockingSelect() {
String id = insertDoc();
QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS);
QueryResult result = cluster.query("select * from " + bucketName + " where meta().id=\"" + id + "\"", options);
assertNotNull(result.metaData().requestId());
assertFalse(result.metaData().clientContextId().isEmpty());
assertEquals(QueryStatus.SUCCESS, result.metaData().status());
assertTrue(result.metaData().warnings().isEmpty());
assertEquals(1, result.rowsAs(JsonObject.class).size());
assertTrue(result.metaData().signature().isPresent());
}
use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class QueryIntegrationTest method blockingNamedParameterizedSelectQuery.
@Test
void blockingNamedParameterizedSelectQuery() {
String id = insertDoc();
QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS).parameters(JsonObject.create().put("id", id));
QueryResult result = cluster.query("select " + bucketName + ".* from " + bucketName + " where meta().id=$id", options);
List<JsonObject> rows = result.rowsAs(JsonObject.class);
assertEquals(1, rows.size());
assertEquals(FOO_CONTENT, rows.get(0));
}
use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class QueryIntegrationTest method exerciseAllOptions.
@Test
void exerciseAllOptions() {
String id = insertDoc();
QueryOptions options = queryOptions().adhoc(true).clientContextId("123").maxParallelism(3).metrics(true).pipelineBatch(1).pipelineCap(1).readonly(true).scanCap(10).scanConsistency(QueryScanConsistency.REQUEST_PLUS).scanWait(Duration.ofMillis(50));
QueryResult result = cluster.query("select * from " + bucketName + " where meta().id=\"" + id + "\"", options);
assertEquals(QueryStatus.SUCCESS, result.metaData().status());
assertEquals("123", result.metaData().clientContextId());
assertTrue(result.metaData().metrics().isPresent());
}
use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class QueryIntegrationTest method noProfileRequestedGivesEmptyProfile.
@Test
void noProfileRequestedGivesEmptyProfile() {
String id = insertDoc();
QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS);
QueryResult result = cluster.query("select * from " + bucketName + " where meta().id=\"" + id + "\"", options);
assertFalse(result.metaData().profile().isPresent());
}
Aggregations