use of org.springframework.data.domain.ExampleMatcher in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameAndLastnameWithNullMatchingIgnoringFirstName.
// GH-929
@Test
void queryByExampleWithFirstnameAndLastnameWithNullMatchingIgnoringFirstName() {
Person person = new Person();
person.setFirstname("Frodo");
person.setLastname("Baggins");
ExampleMatcher matcher = matching().withIncludeNullValues().withIgnorePaths("firstname");
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(lastname IS NULL OR lastname = 'Baggins')");
}
use of org.springframework.data.domain.ExampleMatcher in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameWithStringMatchingRegEx.
// GH-929
@Test
void queryByExampleWithFirstnameWithStringMatchingRegEx() {
Person person = new Person();
person.setFirstname("do");
ExampleMatcher matcher = matching().withStringMatcher(ExampleMatcher.StringMatcher.REGEX);
Example<Person> example = Example.of(person, matcher);
assertThatIllegalStateException().isThrownBy(() -> exampleMapper.getMappedExample(example)).withMessageContaining("REGEX is not supported!");
}
use of org.springframework.data.domain.ExampleMatcher in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameWithStringMatchingAtTheBeginning.
// GH-929
@Test
void queryByExampleWithFirstnameWithStringMatchingAtTheBeginning() {
Person person = new Person();
person.setFirstname("Fro");
ExampleMatcher matcher = matching().withStringMatcher(STARTING);
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(firstname LIKE 'Fro%')");
}
use of org.springframework.data.domain.ExampleMatcher in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameWithFieldSpecificStringMatcherEndsWith.
// GH-929
@Test
void queryByExampleWithFirstnameWithFieldSpecificStringMatcherEndsWith() {
Person person = new Person();
person.setFirstname("do");
ExampleMatcher matcher = matching().withMatcher("firstname", endsWith());
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(firstname LIKE '%do')");
}
use of org.springframework.data.domain.ExampleMatcher in project spring-data-jdbc by spring-projects.
the class RelationalExampleMapperTests method queryByExampleWithFirstnameIgnoreCase.
// GH-929
@Test
void queryByExampleWithFirstnameIgnoreCase() {
Person person = new Person();
person.setFirstname("Frodo");
ExampleMatcher matcher = matching().withIgnoreCase(true);
Example<Person> example = Example.of(person, matcher);
Query query = exampleMapper.getMappedExample(example);
//
assertThat(query.getCriteria()).map(//
Object::toString).hasValue("(firstname = 'Frodo')");
assertThat(example.getMatcher().isIgnoreCaseEnabled()).isTrue();
}
Aggregations