|
|
|
|
@ -29,13 +29,6 @@ public class QueryTests {
@@ -29,13 +29,6 @@ public class QueryTests {
|
|
|
|
|
Assert.assertEquals(expected, q.getQueryObject().toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testSimpleQueryWithChainedCriteria() { |
|
|
|
|
Query q = new Query(where("name").is("Thomas").and("age").lt(80)); |
|
|
|
|
String expected = "{ \"name\" : \"Thomas\" , \"age\" : { \"$lt\" : 80}}"; |
|
|
|
|
Assert.assertEquals(expected, q.getQueryObject().toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testQueryWithNot() { |
|
|
|
|
Query q = new Query(where("name").is("Thomas")).and(where("age").not().mod(10, 0)); |
|
|
|
|
@ -81,6 +74,22 @@ public class QueryTests {
@@ -81,6 +74,22 @@ public class QueryTests {
|
|
|
|
|
Assert.assertEquals(expected, q.getQueryObject().toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testSimpleQueryWithChainedCriteria() { |
|
|
|
|
Query q = new Query(where("name").is("Thomas").and("age").lt(80)); |
|
|
|
|
String expected = "{ \"name\" : \"Thomas\" , \"age\" : { \"$lt\" : 80}}"; |
|
|
|
|
Assert.assertEquals(expected, q.getQueryObject().toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testComplexQueryWithMultipleChainedCriteria() { |
|
|
|
|
Query q1 = new Query(where("name").regex("^T.*").and("age").gt(20).lt(80).and("city").in("Stockholm", "London", "New York")); |
|
|
|
|
Query q2 = new Query(where("name").regex("^T.*").and("age").gt(20).lt(80)).and(where("city").in("Stockholm", "London", "New York")); |
|
|
|
|
Assert.assertEquals(q1.getQueryObject().toString(), q2.getQueryObject().toString()); |
|
|
|
|
Query q3 = new Query(where("name").regex("^T.*")).and(where("age").gt(20).lt(80)).and(where("city").in("Stockholm", "London", "New York")); |
|
|
|
|
Assert.assertEquals(q1.getQueryObject().toString(), q3.getQueryObject().toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testQueryWithElemMatch() { |
|
|
|
|
Query q = new Query(where("openingHours").elemMatch(where("dayOfWeek").is("Monday").and("open").lte("1800"))); |
|
|
|
|
|