use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method createsQueryWithEndingWithPredicateCorrectly.
// DATAMONGO-418
@Test
void createsQueryWithEndingWithPredicateCorrectly() {
PartTree tree = new PartTree("findByUsernameEndingWith", User.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "ews"), context);
Query query = creator.createQuery();
assertThat(query).isEqualTo(query(where("username").regex("ews$")));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method queryShouldAcceptSubclassOfDeclaredArgument.
// DATAMONGO-1588
@Test
void queryShouldAcceptSubclassOfDeclaredArgument() {
PartTree tree = new PartTree("findByLocationNear", User.class);
ConvertingParameterAccessor accessor = getAccessor(converter, new GeoJsonPoint(-74.044502D, 40.689247D));
Query query = new MongoQueryCreator(tree, accessor, context).createQuery();
assertThat(query.getQueryObject()).containsKey("location");
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method nearShouldUseMetricDistanceForGeoJsonTypes.
// DATAMONGO-2394
@Test
void nearShouldUseMetricDistanceForGeoJsonTypes() {
GeoJsonPoint point = new GeoJsonPoint(27.987901, 86.9165379);
PartTree tree = new PartTree("findByLocationNear", User.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, point, new Distance(1, Metrics.KILOMETERS)), context);
assertThat(creator.createQuery()).isEqualTo(query(where("location").nearSphere(point).maxDistance(1000.0D)));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method createsQueryWithFindByIgnoreCaseCorrectly.
// DATAMONGO-770
@Test
void createsQueryWithFindByIgnoreCaseCorrectly() {
PartTree tree = new PartTree("findByfirstNameIgnoreCase", Person.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "dave"), context);
Query query = creator.createQuery();
assertThat(query).isEqualTo(query(where("firstName").regex("^dave$", "i")));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method createsQueryWithFindByNotIgnoreCaseCorrectly.
// DATAMONGO-770
@Test
void createsQueryWithFindByNotIgnoreCaseCorrectly() {
PartTree tree = new PartTree("findByFirstNameNotIgnoreCase", Person.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "dave"), context);
Query query = creator.createQuery();
assertThat(query.toString()).isEqualTo(query(where("firstName").not().regex("^dave$", "i")).toString());
}
Aggregations