Search in sources :

Example 51 with Test

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);
}
Also used : JsonElement(com.google.gson.JsonElement) QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Example 52 with Test

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));
}
Also used : QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Example 53 with Test

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());
    }
}
Also used : QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Example 54 with Test

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());
}
Also used : QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Example 55 with Test

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());
}
Also used : QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)67450 lombok.val (lombok.val)3880 File (java.io.File)2228 HashMap (java.util.HashMap)2180 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2164 ArrayList (java.util.ArrayList)2137 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2027 SqlSession (org.apache.ibatis.session.SqlSession)1845 List (java.util.List)1799 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1484 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1184 Map (java.util.Map)1143 IOException (java.io.IOException)1048 Path (java.nio.file.Path)1006 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)935 Date (java.util.Date)914 Method (java.lang.reflect.Method)862 TestBean (org.springframework.beans.testfixture.beans.TestBean)822 Transaction (org.neo4j.graphdb.Transaction)752 BaseDataTest (org.apache.ibatis.BaseDataTest)740