List of usage examples for org.springframework.data.domain Example of
static <T> Example<T> of(T probe, ExampleMatcher matcher)
From source file:example.UserRepositoryIntegrationTests.java
@Test public void regexMatching() { Example<Person> example = Example.of(new Person("(Skyl|Walt)er", null, null), matching().// withMatcher("firstname", matcher -> matcher.regex())); assertThat(repository.findAll(example), hasItems(skyler, walter)); }
From source file:example.ContactRepositoryIntegrationTests.java
@Test public void findAllRelativesBySimpleExample() { Example<Relative> example = Example.of(new Relative(".*", null, null), // matching().withStringMatcher(StringMatcher.REGEX)); assertThat(contactRepository.findAll(example), containsInAnyOrder(hank, marie)); assertThat(contactRepository.findAll(example), not(containsInAnyOrder(skyler, walter, flynn))); }
From source file:example.MongoOperationsIntegrationTests.java
@Test public void regexMatching() { Example<Person> example = Example.of(new Person("(Skyl|Walt)er", null, null), matching().// withMatcher("firstname", matcher -> matcher.regex())); assertThat(operations.find(query(byExample(example)), Person.class), hasItems(skyler, walter)); }
From source file:example.springdata.mongodb.querybyexample.UserRepositoryIntegrationTests.java
/** * @see #153// w w w . j av a 2 s.c om */ @Test public void regexMatching() { Example<Person> example = Example.of(new Person("(Skyl|Walt)er", null, null), matching().// withMatcher("firstname", matcher -> matcher.regex())); assertThat(repository.findAll(example), hasItems(skyler, walter)); }
From source file:example.springdata.jpa.querybyexample.UserRepositoryIntegrationTests.java
/** * @see #153//from www. j a v a 2s .c o m */ @Test public void matchStartingStringsIgnoreCase() { Example<User> example = Example.of(new User("Walter", "WHITE", null), matching().// withIgnorePaths("age").// withMatcher("firstname", startsWith()).// withMatcher("lastname", ignoreCase())); assertThat(repository.findAll(example), hasItems(flynn, walter)); }
From source file:example.springdata.mongodb.querybyexample.ContactRepositoryIntegrationTests.java
/** * @see #153// ww w . j ava 2 s . c o m */ @Test public void findAllRelativesBySimpleExample() { Example<Relative> example = Example.of(new Relative(".*", null, null), // matching().withStringMatcher(StringMatcher.REGEX)); assertThat(contactRepository.findAll(example), containsInAnyOrder(hank, marie)); assertThat(contactRepository.findAll(example), not(containsInAnyOrder(skyler, walter, flynn))); }
From source file:example.UserRepositoryIntegrationTests.java
@Test public void matchStartingStringsIgnoreCase() { Example<Person> example = Example.of(new Person("Walter", "WHITE", null), matching().// withIgnorePaths("age").// withMatcher("firstname", startsWith()).// withMatcher("lastname", ignoreCase())); assertThat(repository.findAll(example), hasItems(flynn, walter)); }
From source file:example.springdata.mongodb.querybyexample.MongoOperationsIntegrationTests.java
/** * @see #154/*from www . j a va 2s . c o m*/ */ @Test public void regexMatching() { Example<Person> example = Example.of(new Person("(Skyl|Walt)er", null, null), matching().// withMatcher("firstname", matcher -> matcher.regex())); assertThat(operations.find(query(byExample(example)), Person.class), hasItems(skyler, walter)); }
From source file:example.MongoOperationsIntegrationTests.java
@Test public void matchStartingStringsIgnoreCase() { Example<Person> example = Example.of(new Person("Walter", "WHITE", null), matching(). // withIgnorePaths("age").// withMatcher("firstname", startsWith()).// withMatcher("lastname", ignoreCase())); assertThat(operations.find(query(byExample(example)), Person.class), hasItems(flynn, walter)); }
From source file:example.springdata.mongodb.querybyexample.UserRepositoryIntegrationTests.java
/** * @see #153/*from w w w. ja v a 2 s. c om*/ */ @Test public void matchStartingStringsIgnoreCase() { Example<Person> example = Example.of(new Person("Walter", "WHITE", null), matching().// withIgnorePaths("age").// withMatcher("firstname", startsWith()).// withMatcher("lastname", ignoreCase())); assertThat(repository.findAll(example), hasItems(flynn, walter)); }