Search in sources :

Example 56 with Test

use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.

the class QueryTests method basicSelector6.

// "$or operator used with full text indexing"
@Test
public void basicSelector6() {
    QueryBuilder qb = new QueryBuilder(or(eq("director", "George Lucas"), eq("director", "Steven Spielberg")));
    Assertions.assertEquals("{\"selector\": {\"$or\": [{\"director\": {\"$eq\": \"George " + "Lucas\"}}, {\"director\": {\"$eq\": \"Steven Spielberg\"}}]}}", qb.build());
}
Also used : QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Example 57 with Test

use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.

the class QueryTests method basicSelector11.

// "elemMatch operator used with full text indexing"
@Test
public void basicSelector11() {
    QueryBuilder qb = new QueryBuilder(elemMatch("genre", PredicateExpression.eq("Horror")));
    Assertions.assertEquals("{\"selector\": {\"genre\": {\"$elemMatch\": {\"$eq\": " + "\"Horror\"}}}}", qb.build());
}
Also used : QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Example 58 with Test

use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.

the class QueryTests method basicSelector14.

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

Example 59 with Test

use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.

the class QueryTests method basicSelector16.

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

Example 60 with Test

use of org.junit.jupiter.api.Test in project java-cloudant by cloudant.

the class QueryTests method basicSelector1WithSort.

// "Selector basics"
@Test
public void basicSelector1WithSort() {
    QueryBuilder qb = new QueryBuilder(eq("director", "Lars von Trier")).sort(Sort.asc("year"), Sort.desc("director"));
    Assertions.assertEquals("{\"selector\": {\"director\": {\"$eq\": \"Lars von Trier\"}}, " + "\"sort\": [{\"year\": \"asc\"}, {\"director\": \"desc\"}]}", 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