|
|
|
@ -15,18 +15,13 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package org.springframework.data.mongodb.core.query; |
|
|
|
package org.springframework.data.mongodb.core.query; |
|
|
|
|
|
|
|
|
|
|
|
import static org.hamcrest.CoreMatchers.*; |
|
|
|
import static org.assertj.core.api.Assertions.*; |
|
|
|
import static org.junit.Assert.*; |
|
|
|
|
|
|
|
import static org.springframework.data.mongodb.core.query.Criteria.*; |
|
|
|
import static org.springframework.data.mongodb.core.query.Criteria.*; |
|
|
|
import static org.springframework.data.mongodb.core.query.Query.*; |
|
|
|
import static org.springframework.data.mongodb.core.query.Query.*; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.bson.Document; |
|
|
|
import org.bson.Document; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Rule; |
|
|
|
|
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.rules.ExpectedException; |
|
|
|
|
|
|
|
import org.springframework.data.domain.Sort; |
|
|
|
import org.springframework.data.domain.Sort; |
|
|
|
import org.springframework.data.domain.Sort.Direction; |
|
|
|
import org.springframework.data.domain.Sort.Direction; |
|
|
|
import org.springframework.data.mongodb.InvalidMongoDbApiUsageException; |
|
|
|
import org.springframework.data.mongodb.InvalidMongoDbApiUsageException; |
|
|
|
@ -44,41 +39,40 @@ import org.springframework.data.mongodb.core.SpecialDoc; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class QueryTests { |
|
|
|
public class QueryTests { |
|
|
|
|
|
|
|
|
|
|
|
@Rule public ExpectedException exception = ExpectedException.none(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testSimpleQuery() { |
|
|
|
public void testSimpleQuery() { |
|
|
|
|
|
|
|
|
|
|
|
Query q = new Query(where("name").is("Thomas").and("age").lt(80)); |
|
|
|
Query q = new Query(where("name").is("Thomas").and("age").lt(80)); |
|
|
|
Document expected = Document.parse("{ \"name\" : \"Thomas\" , \"age\" : { \"$lt\" : 80}}"); |
|
|
|
assertThat(q.getQueryObject()).isEqualTo(Document.parse("{ \"name\" : \"Thomas\" , \"age\" : { \"$lt\" : 80}}")); |
|
|
|
Assert.assertEquals(expected, q.getQueryObject()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryWithNot() { |
|
|
|
public void testQueryWithNot() { |
|
|
|
|
|
|
|
|
|
|
|
Query q = new Query(where("name").is("Thomas").and("age").not().mod(10, 0)); |
|
|
|
Query q = new Query(where("name").is("Thomas").and("age").not().mod(10, 0)); |
|
|
|
Document expected = Document.parse("{ \"name\" : \"Thomas\" , \"age\" : { \"$not\" : { \"$mod\" : [ 10 , 0]}}}"); |
|
|
|
assertThat(q.getQueryObject()) |
|
|
|
Assert.assertEquals(expected, q.getQueryObject()); |
|
|
|
.isEqualTo(Document.parse("{ \"name\" : \"Thomas\" , \"age\" : { \"$not\" : { \"$mod\" : [ 10 , 0]}}}")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testInvalidQueryWithNotIs() { |
|
|
|
public void testInvalidQueryWithNotIs() { |
|
|
|
try { |
|
|
|
|
|
|
|
new Query(where("name").not().is("Thomas")); |
|
|
|
assertThatExceptionOfType(InvalidMongoDbApiUsageException.class) |
|
|
|
Assert.fail("This should have caused an InvalidDocumentStoreApiUsageException"); |
|
|
|
.isThrownBy(() -> new Query(where("name").not().is("Thomas"))); |
|
|
|
} catch (InvalidMongoDbApiUsageException e) {} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testOrQuery() { |
|
|
|
public void testOrQuery() { |
|
|
|
|
|
|
|
|
|
|
|
Query q = new Query(new Criteria().orOperator(where("name").is("Sven").and("age").lt(50), where("age").lt(50), |
|
|
|
Query q = new Query(new Criteria().orOperator(where("name").is("Sven").and("age").lt(50), where("age").lt(50), |
|
|
|
where("name").is("Thomas"))); |
|
|
|
where("name").is("Thomas"))); |
|
|
|
Document expected = Document.parse( |
|
|
|
assertThat(q.getQueryObject()).isEqualTo(Document.parse( |
|
|
|
"{ \"$or\" : [ { \"name\" : \"Sven\" , \"age\" : { \"$lt\" : 50}} , { \"age\" : { \"$lt\" : 50}} , { \"name\" : \"Thomas\"}]}"); |
|
|
|
"{ \"$or\" : [ { \"name\" : \"Sven\" , \"age\" : { \"$lt\" : 50}} , { \"age\" : { \"$lt\" : 50}} , { \"name\" : \"Thomas\"}]}")); |
|
|
|
Assert.assertEquals(expected, q.getQueryObject()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testAndQuery() { |
|
|
|
public void testAndQuery() { |
|
|
|
|
|
|
|
|
|
|
|
Query q = new Query(new Criteria().andOperator(where("name").is("Sven"), where("age").lt(50))); |
|
|
|
Query q = new Query(new Criteria().andOperator(where("name").is("Sven"), where("age").lt(50))); |
|
|
|
Document expected = Document.parse("{ \"$and\" : [ { \"name\" : \"Sven\"} , { \"age\" : { \"$lt\" : 50}}]}"); |
|
|
|
Document expected = Document.parse("{ \"$and\" : [ { \"name\" : \"Sven\"} , { \"age\" : { \"$lt\" : 50}}]}"); |
|
|
|
Assert.assertEquals(expected, q.getQueryObject()); |
|
|
|
Assert.assertEquals(expected, q.getQueryObject()); |
|
|
|
@ -86,33 +80,35 @@ public class QueryTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testNorQuery() { |
|
|
|
public void testNorQuery() { |
|
|
|
|
|
|
|
|
|
|
|
Query q = new Query( |
|
|
|
Query q = new Query( |
|
|
|
new Criteria().norOperator(where("name").is("Sven"), where("age").lt(50), where("name").is("Thomas"))); |
|
|
|
new Criteria().norOperator(where("name").is("Sven"), where("age").lt(50), where("name").is("Thomas"))); |
|
|
|
Document expected = Document |
|
|
|
assertThat(q.getQueryObject()).isEqualTo(Document |
|
|
|
.parse("{ \"$nor\" : [ { \"name\" : \"Sven\"} , { \"age\" : { \"$lt\" : 50}} , { \"name\" : \"Thomas\"}]}"); |
|
|
|
.parse("{ \"$nor\" : [ { \"name\" : \"Sven\"} , { \"age\" : { \"$lt\" : 50}} , { \"name\" : \"Thomas\"}]}")); |
|
|
|
Assert.assertEquals(expected, q.getQueryObject()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryWithLimit() { |
|
|
|
public void testQueryWithLimit() { |
|
|
|
|
|
|
|
|
|
|
|
Query q = new Query(where("name").gte("M").lte("T").and("age").not().gt(22)); |
|
|
|
Query q = new Query(where("name").gte("M").lte("T").and("age").not().gt(22)); |
|
|
|
q.limit(50); |
|
|
|
q.limit(50); |
|
|
|
Document expected = Document |
|
|
|
|
|
|
|
.parse("{ \"name\" : { \"$gte\" : \"M\" , \"$lte\" : \"T\"} , \"age\" : { \"$not\" : { \"$gt\" : 22}}}"); |
|
|
|
assertThat(q.getQueryObject()).isEqualTo(Document |
|
|
|
Assert.assertEquals(expected, q.getQueryObject()); |
|
|
|
.parse("{ \"name\" : { \"$gte\" : \"M\" , \"$lte\" : \"T\"} , \"age\" : { \"$not\" : { \"$gt\" : 22}}}")); |
|
|
|
Assert.assertEquals(50, q.getLimit()); |
|
|
|
Assert.assertEquals(50, q.getLimit()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryWithFieldsAndSlice() { |
|
|
|
public void testQueryWithFieldsAndSlice() { |
|
|
|
|
|
|
|
|
|
|
|
Query q = new Query(where("name").gte("M").lte("T").and("age").not().gt(22)); |
|
|
|
Query q = new Query(where("name").gte("M").lte("T").and("age").not().gt(22)); |
|
|
|
q.fields().exclude("address").include("name").slice("orders", 10); |
|
|
|
q.fields().exclude("address").include("name").slice("orders", 10); |
|
|
|
|
|
|
|
|
|
|
|
Document expected = Document |
|
|
|
assertThat(q.getQueryObject()).isEqualTo(Document |
|
|
|
.parse("{ \"name\" : { \"$gte\" : \"M\" , \"$lte\" : \"T\"} , \"age\" : { \"$not\" : { \"$gt\" : 22}}}"); |
|
|
|
.parse("{ \"name\" : { \"$gte\" : \"M\" , \"$lte\" : \"T\"} , \"age\" : { \"$not\" : { \"$gt\" : 22}}}")); |
|
|
|
Assert.assertEquals(expected, q.getQueryObject()); |
|
|
|
|
|
|
|
Document expectedFields = Document.parse("{ \"address\" : 0 , \"name\" : 1 , \"orders\" : { \"$slice\" : 10}}"); |
|
|
|
assertThat(q.getFieldsObject()) |
|
|
|
Assert.assertEquals(expectedFields, q.getFieldsObject()); |
|
|
|
.isEqualTo(Document.parse("{ \"address\" : 0 , \"name\" : 1 , \"orders\" : { \"$slice\" : 10}}")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // DATAMONGO-652
|
|
|
|
@Test // DATAMONGO-652
|
|
|
|
@ -121,87 +117,87 @@ public class QueryTests { |
|
|
|
Query query = query(where("name").gte("M").lte("T").and("age").not().gt(22)); |
|
|
|
Query query = query(where("name").gte("M").lte("T").and("age").not().gt(22)); |
|
|
|
query.fields().elemMatch("products", where("name").is("milk")).position("comments", 2); |
|
|
|
query.fields().elemMatch("products", where("name").is("milk")).position("comments", 2); |
|
|
|
|
|
|
|
|
|
|
|
Document expected = Document |
|
|
|
assertThat(query.getQueryObject()).isEqualTo(Document |
|
|
|
.parse("{ \"name\" : { \"$gte\" : \"M\" , \"$lte\" : \"T\"} , \"age\" : { \"$not\" : { \"$gt\" : 22}}}"); |
|
|
|
.parse("{ \"name\" : { \"$gte\" : \"M\" , \"$lte\" : \"T\"} , \"age\" : { \"$not\" : { \"$gt\" : 22}}}")); |
|
|
|
assertThat(query.getQueryObject(), is(expected)); |
|
|
|
assertThat(query.getFieldsObject()) |
|
|
|
Document expectedFields = Document |
|
|
|
.isEqualTo(Document.parse("{ \"products\" : { \"$elemMatch\" : { \"name\" : \"milk\"}} , \"comments.$\" : 2}")); |
|
|
|
.parse("{ \"products\" : { \"$elemMatch\" : { \"name\" : \"milk\"}} , \"comments.$\" : 2}"); |
|
|
|
|
|
|
|
assertThat(query.getFieldsObject(), is(expectedFields)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testSimpleQueryWithChainedCriteria() { |
|
|
|
public void testSimpleQueryWithChainedCriteria() { |
|
|
|
|
|
|
|
|
|
|
|
Query q = new Query(where("name").is("Thomas").and("age").lt(80)); |
|
|
|
Query q = new Query(where("name").is("Thomas").and("age").lt(80)); |
|
|
|
Document expected = Document.parse("{ \"name\" : \"Thomas\" , \"age\" : { \"$lt\" : 80}}"); |
|
|
|
assertThat(q.getQueryObject()).isEqualTo(Document.parse("{ \"name\" : \"Thomas\" , \"age\" : { \"$lt\" : 80}}")); |
|
|
|
Assert.assertEquals(expected, q.getQueryObject()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testComplexQueryWithMultipleChainedCriteria() { |
|
|
|
public void testComplexQueryWithMultipleChainedCriteria() { |
|
|
|
|
|
|
|
|
|
|
|
Query q = new Query( |
|
|
|
Query q = new Query( |
|
|
|
where("name").regex("^T.*").and("age").gt(20).lt(80).and("city").in("Stockholm", "London", "New York")); |
|
|
|
where("name").regex("^T.*").and("age").gt(20).lt(80).and("city").in("Stockholm", "London", "New York")); |
|
|
|
Document expected = Document |
|
|
|
assertThat(q.getQueryObject().toJson()).isEqualTo(Document.parse( |
|
|
|
.parse("{ \"name\" : { \"$regex\" : \"^T.*\", \"$options\" : \"\" } , \"age\" : { \"$gt\" : 20 , \"$lt\" : 80} , " |
|
|
|
"{ \"name\" : { \"$regex\" : \"^T.*\", \"$options\" : \"\" } , \"age\" : { \"$gt\" : 20 , \"$lt\" : 80} , " |
|
|
|
+ "\"city\" : { \"$in\" : [ \"Stockholm\" , \"London\" , \"New York\"]}}"); |
|
|
|
+ "\"city\" : { \"$in\" : [ \"Stockholm\" , \"London\" , \"New York\"]}}") |
|
|
|
|
|
|
|
.toJson()); |
|
|
|
Assert.assertEquals(expected.toJson(), q.getQueryObject().toJson()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testAddCriteriaWithComplexQueryWithMultipleChainedCriteria() { |
|
|
|
public void testAddCriteriaWithComplexQueryWithMultipleChainedCriteria() { |
|
|
|
|
|
|
|
|
|
|
|
Query q1 = new Query( |
|
|
|
Query q1 = new Query( |
|
|
|
where("name").regex("^T.*").and("age").gt(20).lt(80).and("city").in("Stockholm", "London", "New York")); |
|
|
|
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)) |
|
|
|
Query q2 = new Query(where("name").regex("^T.*").and("age").gt(20).lt(80)) |
|
|
|
.addCriteria(where("city").in("Stockholm", "London", "New York")); |
|
|
|
.addCriteria(where("city").in("Stockholm", "London", "New York")); |
|
|
|
Assert.assertEquals(q1.getQueryObject().toString(), q2.getQueryObject().toString()); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(q1.getQueryObject().toString()).isEqualTo(q2.getQueryObject().toString()); |
|
|
|
|
|
|
|
|
|
|
|
Query q3 = new Query(where("name").regex("^T.*")).addCriteria(where("age").gt(20).lt(80)) |
|
|
|
Query q3 = new Query(where("name").regex("^T.*")).addCriteria(where("age").gt(20).lt(80)) |
|
|
|
.addCriteria(where("city").in("Stockholm", "London", "New York")); |
|
|
|
.addCriteria(where("city").in("Stockholm", "London", "New York")); |
|
|
|
Assert.assertEquals(q1.getQueryObject().toString(), q3.getQueryObject().toString()); |
|
|
|
assertThat(q1.getQueryObject().toString()).isEqualTo(q3.getQueryObject().toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryWithElemMatch() { |
|
|
|
public void testQueryWithElemMatch() { |
|
|
|
|
|
|
|
|
|
|
|
Query q = new Query(where("openingHours").elemMatch(where("dayOfWeek").is("Monday").and("open").lte("1800"))); |
|
|
|
Query q = new Query(where("openingHours").elemMatch(where("dayOfWeek").is("Monday").and("open").lte("1800"))); |
|
|
|
Document expected = Document.parse( |
|
|
|
assertThat(q.getQueryObject()).isEqualTo(Document.parse( |
|
|
|
"{ \"openingHours\" : { \"$elemMatch\" : { \"dayOfWeek\" : \"Monday\" , \"open\" : { \"$lte\" : \"1800\"}}}}"); |
|
|
|
"{ \"openingHours\" : { \"$elemMatch\" : { \"dayOfWeek\" : \"Monday\" , \"open\" : { \"$lte\" : \"1800\"}}}}")); |
|
|
|
Assert.assertEquals(expected, q.getQueryObject()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryWithIn() { |
|
|
|
public void testQueryWithIn() { |
|
|
|
|
|
|
|
|
|
|
|
Query q = new Query(where("state").in("NY", "NJ", "PA")); |
|
|
|
Query q = new Query(where("state").in("NY", "NJ", "PA")); |
|
|
|
Document expected = Document.parse("{ \"state\" : { \"$in\" : [ \"NY\" , \"NJ\" , \"PA\"]}}"); |
|
|
|
assertThat(q.getQueryObject()).isEqualTo(Document.parse("{ \"state\" : { \"$in\" : [ \"NY\" , \"NJ\" , \"PA\"]}}")); |
|
|
|
Assert.assertEquals(expected, q.getQueryObject()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryWithRegex() { |
|
|
|
public void testQueryWithRegex() { |
|
|
|
|
|
|
|
|
|
|
|
Query q = new Query(where("name").regex("b.*")); |
|
|
|
Query q = new Query(where("name").regex("b.*")); |
|
|
|
Document expected = Document.parse("{ \"name\" : { \"$regex\" : \"b.*\", \"$options\" : \"\" }}"); |
|
|
|
assertThat(q.getQueryObject().toJson()) |
|
|
|
Assert.assertEquals(expected.toJson(), q.getQueryObject().toJson()); |
|
|
|
.isEqualTo(Document.parse("{ \"name\" : { \"$regex\" : \"b.*\", \"$options\" : \"\" }}").toJson()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryWithRegexAndOption() { |
|
|
|
public void testQueryWithRegexAndOption() { |
|
|
|
Query q = new Query(where("name").regex("b.*", "i")); |
|
|
|
Query q = new Query(where("name").regex("b.*", "i")); |
|
|
|
Document expected = Document.parse("{ \"name\" : { \"$regex\" : \"b.*\" , \"$options\" : \"i\"}}"); |
|
|
|
assertThat(q.getQueryObject().toJson()) |
|
|
|
Assert.assertEquals(expected.toJson(), q.getQueryObject().toJson()); |
|
|
|
.isEqualTo(Document.parse("{ \"name\" : { \"$regex\" : \"b.*\" , \"$options\" : \"i\"}}").toJson()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // DATAMONGO-538
|
|
|
|
@Test // DATAMONGO-538
|
|
|
|
public void addsSortCorrectly() { |
|
|
|
public void addsSortCorrectly() { |
|
|
|
|
|
|
|
|
|
|
|
Query query = new Query().with(Sort.by(Direction.DESC, "foo")); |
|
|
|
Query query = new Query().with(Sort.by(Direction.DESC, "foo")); |
|
|
|
assertThat(query.getSortObject(), is(Document.parse("{ \"foo\" : -1}"))); |
|
|
|
assertThat(query.getSortObject()).isEqualTo(Document.parse("{ \"foo\" : -1}")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void rejectsOrderWithIgnoreCase() { |
|
|
|
public void rejectsOrderWithIgnoreCase() { |
|
|
|
|
|
|
|
|
|
|
|
exception.expect(IllegalArgumentException.class); |
|
|
|
assertThatExceptionOfType(IllegalArgumentException.class) |
|
|
|
exception.expectMessage("foo"); |
|
|
|
.isThrownBy(() -> new Query().with(Sort.by(new Sort.Order("foo").ignoreCase()))); |
|
|
|
|
|
|
|
|
|
|
|
new Query().with(Sort.by(new Sort.Order("foo").ignoreCase())); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // DATAMONGO-709, DATAMONGO-1735, // DATAMONGO-2198
|
|
|
|
@Test // DATAMONGO-709, DATAMONGO-1735, // DATAMONGO-2198
|
|
|
|
@ -210,21 +206,20 @@ public class QueryTests { |
|
|
|
|
|
|
|
|
|
|
|
Query query = new Query(where("name").is("foo")).restrict(SpecialDoc.class); |
|
|
|
Query query = new Query(where("name").is("foo")).restrict(SpecialDoc.class); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(query.getRestrictedTypes(), is(notNullValue())); |
|
|
|
assertThat(query.getRestrictedTypes()).containsExactly(SpecialDoc.class); |
|
|
|
assertThat(query.getRestrictedTypes().size(), is(1)); |
|
|
|
|
|
|
|
assertThat(query.getRestrictedTypes(), hasItems(Arrays.asList(SpecialDoc.class).toArray(new Class<?>[0]))); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // DATAMONGO-1421
|
|
|
|
@Test // DATAMONGO-1421
|
|
|
|
public void addCriteriaForSamePropertyMultipleTimesShouldThrowAndSafelySerializeErrorMessage() { |
|
|
|
public void addCriteriaForSamePropertyMultipleTimesShouldThrowAndSafelySerializeErrorMessage() { |
|
|
|
|
|
|
|
|
|
|
|
exception.expect(InvalidMongoDbApiUsageException.class); |
|
|
|
assertThatExceptionOfType(InvalidMongoDbApiUsageException.class).isThrownBy(() -> { |
|
|
|
exception.expectMessage("second 'value' criteria"); |
|
|
|
|
|
|
|
exception.expectMessage("already contains '{ \"value\" : { \"$java\" : VAL_1 } }'"); |
|
|
|
Query query = new Query(); |
|
|
|
|
|
|
|
query.addCriteria(where("value").is(EnumType.VAL_1)); |
|
|
|
|
|
|
|
query.addCriteria(where("value").is(EnumType.VAL_2)); |
|
|
|
|
|
|
|
}).withMessageContaining("second 'value' criteria") |
|
|
|
|
|
|
|
.withMessageContaining("already contains '{ \"value\" : { \"$java\" : VAL_1 } }'"); |
|
|
|
|
|
|
|
|
|
|
|
Query query = new Query(); |
|
|
|
|
|
|
|
query.addCriteria(where("value").is(EnumType.VAL_1)); |
|
|
|
|
|
|
|
query.addCriteria(where("value").is(EnumType.VAL_2)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
enum EnumType { |
|
|
|
enum EnumType { |
|
|
|
|