use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method appliesIgnoreCaseToLeafProperty.
// DATAMONGO-1229
@Test
void appliesIgnoreCaseToLeafProperty() {
PartTree tree = new PartTree("findByAddressStreetIgnoreCase", User.class);
ConvertingParameterAccessor accessor = getAccessor(converter, "Street");
assertThat(new MongoQueryCreator(tree, accessor, context).createQuery()).isNotNull();
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method ignoreCaseShouldEscapeSourceWhenUsedForEndingWith.
// DATAMONGO-1232
@Test
void ignoreCaseShouldEscapeSourceWhenUsedForEndingWith() {
PartTree tree = new PartTree("findByUsernameEndingWithIgnoreCase", User.class);
ConvertingParameterAccessor accessor = getAccessor(converter, "new.ton+");
Query query = new MongoQueryCreator(tree, accessor, context).createQuery();
assertThat(query).isEqualTo(query(where("username").regex("\\Qnew.ton+\\E$", "i")));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method createsQueryWithFindByContainingIgnoreCaseCorrectly.
// DATAMONGO-770
@Test
void createsQueryWithFindByContainingIgnoreCaseCorrectly() {
PartTree tree = new PartTree("findByFirstNameContainingIgnoreCase", 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 ignoreCaseShouldEscapeSourceWhenUsedForStartingWith.
// DATAMONGO-1232
@Test
void ignoreCaseShouldEscapeSourceWhenUsedForStartingWith() {
PartTree tree = new PartTree("findByUsernameStartingWithIgnoreCase", User.class);
ConvertingParameterAccessor accessor = getAccessor(converter, "dawns.light+");
Query query = new MongoQueryCreator(tree, accessor, context).createQuery();
assertThat(query).isEqualTo(query(where("username").regex("^\\Qdawns.light+\\E", "i")));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method shouldCreateDeleteByQueryCorrectlyForMultipleCriteriaAndCaseExpressions.
// DATAMONGO-566
@Test
void shouldCreateDeleteByQueryCorrectlyForMultipleCriteriaAndCaseExpressions() {
PartTree tree = new PartTree("deleteByFirstNameAndAgeAllIgnoreCase", 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").regex("^dave$", "i").and("age").is(42)));
}
Aggregations