use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method shouldCreateNearQueryForMinMaxDistance.
// DATAMONGO-1110
@Test
void shouldCreateNearQueryForMinMaxDistance() {
Point point = new Point(10, 20);
Range<Distance> range = Distance.between(new Distance(10), new Distance(20));
PartTree tree = new PartTree("findByAddress_GeoNear", User.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, point, range), context);
Query query = creator.createQuery();
assertThat(query).isEqualTo(query(where("address.geo").near(point).minDistance(10D).maxDistance(20D)));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method createsGreaterThanEqualQueryCorrectly.
@Test
void createsGreaterThanEqualQueryCorrectly() {
PartTree tree = new PartTree("findByAgeGreaterThanEqual", Person.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, 18), context);
Query reference = query(where("age").gte(18));
assertThat(creator.createQuery()).isEqualTo(reference);
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method createsRegexQueryForPatternWithOptionsCorrectly.
// DATAMONGO-2003
@Test
void createsRegexQueryForPatternWithOptionsCorrectly() {
Pattern pattern = Pattern.compile(".*", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
PartTree tree = new PartTree("findByFirstNameRegex", Person.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, pattern), context);
assertThat(creator.createQuery()).isEqualTo(query(where("firstName").regex(".*", "iu")));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method shouldCreateWithinQueryCorrectly.
// DATAMONGO-1136
@Test
void shouldCreateWithinQueryCorrectly() {
Point first = new Point(1, 1);
Point second = new Point(2, 2);
Point third = new Point(3, 3);
Shape shape = new Polygon(first, second, third);
PartTree tree = new PartTree("findByAddress_GeoWithin", User.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, shape), context);
Query query = creator.createQuery();
assertThat(query).isEqualTo(query(where("address.geo").within(shape)));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method createsFalseClauseCorrectly.
// DATAMONGO-338
@Test
void createsFalseClauseCorrectly() {
PartTree tree = new PartTree("findByActiveFalse", Person.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter), context);
Query query = query(where("active").is(false));
assertThat(creator.createQuery()).isEqualTo(query);
}
Aggregations