use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method likeShouldEscapeSourceWhenUsedWithLeadingWildcard.
// DATAMONGO-1232
@Test
public void likeShouldEscapeSourceWhenUsedWithLeadingWildcard() {
PartTree tree = new PartTree("findByUsernameLike", User.class);
ConvertingParameterAccessor accessor = getAccessor(converter, "*steel.heart+");
Query query = new MongoQueryCreator(tree, accessor, context).createQuery();
assertThat(query, is(query(where("username").regex(".*\\Qsteel.heart+\\E"))));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method likeShouldEscapeSourceWhenUsedWithLeadingAndTrailingWildcard.
// DATAMONGO-1232
@Test
public void likeShouldEscapeSourceWhenUsedWithLeadingAndTrailingWildcard() {
PartTree tree = new PartTree("findByUsernameLike", User.class);
ConvertingParameterAccessor accessor = getAccessor(converter, "*fire.fight+*");
Query query = new MongoQueryCreator(tree, accessor, context).createQuery();
assertThat(query, is(query(where("username").regex(".*\\Qfire.fight+\\E.*"))));
}
use of org.springframework.data.repository.query.parser.PartTree in project spring-data-mongodb by spring-projects.
the class MongoQueryCreatorUnitTests method createsLessThanEqualQueryCorrectly.
@Test
public void createsLessThanEqualQueryCorrectly() throws Exception {
PartTree tree = new PartTree("findByAgeLessThanEqual", Person.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, 18), context);
Query reference = query(where("age").lte(18));
assertThat(creator.createQuery(), is(reference));
}
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
public void createsQueryWithFindByIgnoreCaseCorrectly() {
PartTree tree = new PartTree("findByfirstNameIgnoreCase", Person.class);
MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "dave"), context);
Query query = creator.createQuery();
assertThat(query, is(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 likeShouldEscapeSourceWhenUsedWithTrailingWildcard.
// DATAMONGO-1232
@Test
public void likeShouldEscapeSourceWhenUsedWithTrailingWildcard() {
PartTree tree = new PartTree("findByUsernameLike", User.class);
ConvertingParameterAccessor accessor = getAccessor(converter, "cala.mity+*");
Query query = new MongoQueryCreator(tree, accessor, context).createQuery();
assertThat(query, is(query(where("username").regex("\\Qcala.mity+\\E.*"))));
}
Aggregations