DATACMNS-879 - ExampleMatcher now allows to define whether all or any match should be used.

Introduced dedicated factory methods for ExampleMatcher so that it exposes whether the predicates built from Example instances have to be fulfilled all or if it's sufficient that any of them matches.
This commit is contained in:
Oliver Gierke
2016-06-30 08:54:47 +02:00
parent 20653a7ebc
commit d41a9cb5c5
3 changed files with 113 additions and 19 deletions

View File

@@ -29,6 +29,7 @@ import org.springframework.data.domain.ExampleMatcher.StringMatcher;
* Unit test for {@link ExampleMatcher}.
*
* @author Mark Paluch
* @author Oliver Gierke
* @soundtrack K2 - Der Berg Ruft (Club Mix)
*/
public class ExampleMatcherUnitTests {
@@ -176,6 +177,36 @@ public class ExampleMatcherUnitTests {
assertThat(configuredExampleSpec.isIgnoreCaseEnabled(), is(true));
}
/**
* @see DATACMNS-879
*/
@Test
public void defaultMatcherRequiresAllMatching() {
assertThat(matching().isAllMatching(), is(true));
assertThat(matching().isAnyMatching(), is(false));
}
/**
* @see DATACMNS-879
*/
@Test
public void allMatcherRequiresAllMatching() {
assertThat(matchingAll().isAllMatching(), is(true));
assertThat(matchingAll().isAnyMatching(), is(false));
}
/**
* @see DATACMNS-879
*/
@Test
public void anyMatcherYieldsAnyMatching() {
assertThat(matchingAny().isAnyMatching(), is(true));
assertThat(matchingAny().isAllMatching(), is(false));
}
static class Person {
String firstname;