Search in sources :

Example 61 with Test

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

the class QueryTests method complexSelector2.

@Test
public void complexSelector2() {
    QueryBuilder qb = new QueryBuilder(or(and(eq("Actor", "Schwarzenegger"), eq("Year", 2012)), and(eq("Actor", "de Vito"), eq("Year", 2001))));
    Assertions.assertEquals("{\"selector\": {\"$or\": [{\"$and\": [{\"Actor\": {\"$eq\": " + "\"Schwarzenegger\"}}, {\"Year\": {\"$eq\": 2012}}]}, {\"$and\": [{\"Actor\": " + "{\"$eq\": \"de Vito\"}}, {\"Year\": {\"$eq\": 2001}}]}]}}", qb.build());
}
Also used : QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Example 62 with Test

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

the class QueryTests method basicSelector8.

// "$not operator used with database indexed on the field "year""
@Test
public void basicSelector8() {
    QueryBuilder qb = new QueryBuilder(and(gte("year", 1900), lte("year", 1903), not(eq("year", 1901))));
    Assertions.assertEquals("{\"selector\": {\"$and\": [{\"year\": {\"$gte\": 1900}}, " + "{\"year\": {\"$lte\": 1903}}, {\"$not\": {\"year\": {\"$eq\": 1901}}}]}}", qb.build());
}
Also used : QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Example 63 with Test

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

the class QueryTests method basicSelector7.

// "$or operator used with database indexed on the field "year"
@Test
public void basicSelector7() {
    QueryBuilder qb = new QueryBuilder(and(eq("year", 1977), or(eq("director", "George Lucas"), eq("director", "Steven Spielberg"))));
    Assertions.assertEquals("{\"selector\": {\"$and\": [{\"year\": {\"$eq\": 1977}}, " + "{\"$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 64 with Test

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

the class QueryTests method basicSelector1.

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

Example 65 with Test

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

the class QueryTests method basicSelector3.

// "SUBFIELDS"
@Test
public void basicSelector3() {
    QueryBuilder qb = new QueryBuilder(eq("imdb.rating", 8));
    Assertions.assertEquals("{\"selector\": {\"imdb.rating\": {\"$eq\": 8}}}", 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