use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class IndexTests method useIndexDesignDocJsonTypeIsString.
/**
* Test that a design document name is passed as a string.
*
* @throws Exception
*/
@Test
public void useIndexDesignDocJsonTypeIsString() throws Exception {
JsonElement useIndex = getUseIndexFromRequest(new QueryBuilder(empty()).useIndex("Movie_year"));
assertUseIndexString(useIndex);
}
use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class IndexTests method useIndexReplaced.
/**
* Test that use_index is replaced if called multiple times
*
* @throws Exception
*/
@Test
public void useIndexReplaced() throws Exception {
QueryBuilder builder = new QueryBuilder(empty()).useIndex("Movie_year", "Person_name").useIndex("Movie_year");
assertUseIndexString(getUseIndexFromRequest(builder));
}
use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class IndexTests method testIndexMovieFindByIndexDesignDocAndName.
@Test
public void testIndexMovieFindByIndexDesignDocAndName() {
QueryResult<Movie> movies = db.query(new QueryBuilder(and(gt("Movie_year", 1960), eq("Person_name", "Alec Guinness"))).sort(Sort.desc("Movie_year")).fields("Movie_name", "Movie_year").limit(1).skip(1).useIndex("Movie_year", "Movie_year").build(), Movie.class);
assertNotNull(movies);
assert (movies.getDocs().size() == 1);
for (Movie m : movies.getDocs()) {
assertNotNull(m.getMovie_name());
assertNotNull(m.getMovie_year());
}
}
use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class QueryTests method basicSelector1WithAllOptions.
// "Selector basics"
@Test
public void basicSelector1WithAllOptions() {
QueryBuilder qb = new QueryBuilder(eq("director", "Lars von Trier")).fields("_id", "_rev", "year", "title").sort(Sort.asc("year"), Sort.desc("director")).limit(10).skip(0);
Assertions.assertEquals("{\"selector\": {\"director\": {\"$eq\": \"Lars von Trier\"}}, " + "\"fields\": [\"_id\", \"_rev\", \"year\", \"title\"], " + "\"sort\": [{\"year\": \"asc\"}, {\"director\": \"desc\"}], \"limit\": 10, " + "\"skip\": 0}", qb.build());
}
use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.
the class QueryTests method basicSelector12.
// "$lt operator used with database indexed on the field "year""
// (similar for all (in)equality tests, so one is representative
@Test
public void basicSelector12() {
QueryBuilder qb = new QueryBuilder(lt("year", 1900));
Assertions.assertEquals("{\"selector\": {\"year\": {\"$lt\": 1900}}}", qb.build());
}
Aggregations