use of org.baeldung.persistence.dao.UserSpecification in project tutorials by eugenp.
the class UserController method resolveSpecificationFromInfixExpr.
protected Specification<User> resolveSpecificationFromInfixExpr(String searchParameters) {
CriteriaParser parser = new CriteriaParser();
GenericSpecificationsBuilder<User> specBuilder = new GenericSpecificationsBuilder<>();
return specBuilder.build(parser.parse(searchParameters), UserSpecification::new);
}
use of org.baeldung.persistence.dao.UserSpecification in project tutorials by eugenp.
the class JPASpecificationIntegrationTest method givenMinAge_whenGettingListOfUsers_thenCorrect.
@Test
public void givenMinAge_whenGettingListOfUsers_thenCorrect() {
final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("age", SearchOperation.GREATER_THAN, "25"));
final List<User> results = repository.findAll(Specifications.where(spec));
assertThat(userTom, isIn(results));
assertThat(userJohn, not(isIn(results)));
}
use of org.baeldung.persistence.dao.UserSpecification in project tutorials by eugenp.
the class JPASpecificationIntegrationTest method givenFirstNameSuffix_whenGettingListOfUsers_thenCorrect.
@Test
public void givenFirstNameSuffix_whenGettingListOfUsers_thenCorrect() {
final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.ENDS_WITH, "n"));
final List<User> results = repository.findAll(spec);
assertThat(userJohn, isIn(results));
assertThat(userTom, not(isIn(results)));
}
use of org.baeldung.persistence.dao.UserSpecification in project tutorials by eugenp.
the class JPASpecificationIntegrationTest method givenFirstNamePrefix_whenGettingListOfUsers_thenCorrect.
@Test
public void givenFirstNamePrefix_whenGettingListOfUsers_thenCorrect() {
final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.STARTS_WITH, "jo"));
final List<User> results = repository.findAll(spec);
assertThat(userJohn, isIn(results));
assertThat(userTom, not(isIn(results)));
}
Aggregations