Search in sources :

Example 31 with QueryBuilder

use of com.cloudant.client.api.query.QueryBuilder in project java-cloudant by cloudant.

the class QueryTests method basicSelector10_single.

// "$all operator used with full text indexing"
@Test
public void basicSelector10_single() {
    QueryBuilder qb = new QueryBuilder(all("genre", "Comedy"));
    Assertions.assertEquals("{\"selector\": {\"genre\": {\"$all\": [\"Comedy\"]}}}", qb.build());
}
Also used : QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Example 32 with QueryBuilder

use of com.cloudant.client.api.query.QueryBuilder in project java-cloudant by cloudant.

the class QueryTests method basicSelector15_single.

// "$in operator used with full text indexing"
@Test
public void basicSelector15_single() {
    QueryBuilder qb = new QueryBuilder(in("year", 2010));
    Assertions.assertEquals("{\"selector\": {\"year\": {\"$in\": [2010]}}}", qb.build());
}
Also used : QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Example 33 with QueryBuilder

use of com.cloudant.client.api.query.QueryBuilder in project java-cloudant by cloudant.

the class QueryTests method basicSelector1WithFields.

// "Selector basics"
@Test
public void basicSelector1WithFields() {
    QueryBuilder qb = new QueryBuilder(eq("director", "Lars von Trier")).fields("_id", "_rev", "year", "title");
    Assertions.assertEquals("{\"selector\": {\"director\": {\"$eq\": \"Lars von Trier\"}}, " + "\"fields\": [\"_id\", \"_rev\", \"year\", \"title\"]}", qb.build());
}
Also used : QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

QueryBuilder (com.cloudant.client.api.query.QueryBuilder)33 Test (org.junit.jupiter.api.Test)33 JsonElement (com.google.gson.JsonElement)3 JsonArray (com.google.gson.JsonArray)1