use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method createsNonSphericalNearForDistanceWithDefaultMetric.
// DATAMONGO-1139
@Test
void createsNonSphericalNearForDistanceWithDefaultMetric() {
Point point = new Point(1.0, 1.0);
Distance distance = new Distance(1.0);
PartTree tree = new PartTree("findByLocationNear", Venue.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, point, distance), context);
Query query = creator.createQuery();
assertThat(query).isEqualTo(query(where("location").near(point).maxDistance(1.0)));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method shouldCreateInClauseWhenUsingNotContainsOnCollectionLikeProperty.
// DATAMONGO-1075
@Test
void shouldCreateInClauseWhenUsingNotContainsOnCollectionLikeProperty() {
PartTree tree = new PartTree("findByEmailAddressesNotContaining", User.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "dave"), context);
Query query = creator.createQuery();
assertThat(query).isEqualTo(query(where("emailAddresses").not().in("dave")));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method shouldCreateDeleteByQueryCorrectly.
// DATAMONGO-566
@Test
void shouldCreateDeleteByQueryCorrectly() {
PartTree tree = new PartTree("deleteByFirstName", Person.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "dave", 42), context);
Query query = creator.createQuery();
assertThat(tree.isDelete()).isTrue();
assertThat(query).isEqualTo(query(where("firstName").is("dave")));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method queryShouldThrowExceptionWhenArgumentDoesNotMatchDeclaration.
// DATAMONGO-1588
@Test
void queryShouldThrowExceptionWhenArgumentDoesNotMatchDeclaration() {
PartTree tree = new PartTree("findByLocationNear", User.class);
ConvertingParameterAccessor accessor = getAccessor(converter, new GeoJsonLineString(new Point(-74.044502D, 40.689247D), new Point(-73.997330D, 40.730824D)));
assertThatIllegalArgumentException().isThrownBy(() -> new MongoQueryCreator(tree, accessor, context).createQuery()).withMessageContaining("Expected parameter type of " + Point.class);
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method createsQueryWithContainingPredicateCorrectly.
// DATAMONGO-418
@Test
void createsQueryWithContainingPredicateCorrectly() {
PartTree tree = new PartTree("findByUsernameContaining", User.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "thew"), context);
Query query = creator.createQuery();
assertThat(query).isEqualTo(query(where("username").regex(".*thew.*")));
}
Aggregations