Example usage for org.springframework.data.domain Example of

List of usage examples for org.springframework.data.domain Example of

Introduction

In this page you can find the example usage for org.springframework.data.domain Example of.

Prototype

static <T> Example<T> of(T probe, ExampleMatcher matcher) 

Source Link

Document

Create a new Example using the given ExampleMatcher .

Usage

From source file:example.UserRepositoryIntegrationTests.java

@Test
public void ignorePropertiesAndMatchByAge() {

    Example<Person> example = Example.of(flynn, matching(). //
            withIgnorePaths("firstname", "lastname"));

    assertThat(repository.findOne(example), is(flynn));
}

From source file:example.springdata.mongodb.querybyexample.UserRepositoryIntegrationTests.java

/**
 * @see #153// www .  j  ava  2  s. c o m
 */
@Test
public void ignorePropertiesAndMatchByAge() {

    Example<Person> example = Example.of(flynn, matching(). //
            withIgnorePaths("firstname", "lastname"));

    assertThat(repository.findOne(example), is(flynn));
}

From source file:example.springdata.jpa.querybyexample.UserRepositoryIntegrationTests.java

/**
 * @see #153/*  www  .ja  va 2  s.  c om*/
 */
@Test
public void ignorePropertiesAndMatchByAge() {

    Example<User> example = Example.of(flynn, matching().//
            withIgnorePaths("firstname", "lastname"));

    assertThat(repository.findOne(example), is(flynn));
}

From source file:example.ContactRepositoryIntegrationTests.java

@Test
public void findAllPersonsBySimpleExample() {

    Example<Person> example = Example.of(new Person(".*", null, null), //
            matching().withStringMatcher(StringMatcher.REGEX));

    assertThat(userRepository.findAll(example), containsInAnyOrder(skyler, walter, flynn));
    assertThat(userRepository.findAll(example), not(containsInAnyOrder(hank, marie)));
}

From source file:example.UserRepositoryIntegrationTests.java

@Test
public void substringMatching() {

    Example<Person> example = Example.of(new Person("er", null, null), matching().//
            withStringMatcher(StringMatcher.ENDING));

    assertThat(repository.findAll(example), hasItems(skyler, walter));
}

From source file:example.MongoOperationsIntegrationTests.java

@Test
public void substringMatching() {

    Example<Person> example = Example.of(new Person("er", null, null), matching().//
            withStringMatcher(StringMatcher.ENDING));

    assertThat(operations.find(query(byExample(example)), Person.class), hasItems(skyler, walter));
}

From source file:example.springdata.mongodb.querybyexample.ContactRepositoryIntegrationTests.java

/**
 * @see #153/* ww w. j a va  2 s  .  c  o  m*/
 */
@Test
public void findAllPersonsBySimpleExample() {

    Example<Person> example = Example.of(new Person(".*", null, null), //
            matching().withStringMatcher(StringMatcher.REGEX));

    assertThat(userRepository.findAll(example), containsInAnyOrder(skyler, walter, flynn));
    assertThat(userRepository.findAll(example), not(containsInAnyOrder(hank, marie)));
}

From source file:example.springdata.mongodb.querybyexample.UserRepositoryIntegrationTests.java

/**
 * @see #153/*  w  w  w .jav  a2s. c om*/
 */
@Test
public void substringMatching() {

    Example<Person> example = Example.of(new Person("er", null, null), matching().//
            withStringMatcher(StringMatcher.ENDING));

    assertThat(repository.findAll(example), hasItems(skyler, walter));
}

From source file:example.springdata.jpa.querybyexample.UserRepositoryIntegrationTests.java

/**
 * @see #153// www .  ja v  a 2 s  .  c o  m
 */
@Test
public void substringMatching() {

    Example<User> example = Example.of(new User("er", null, null), matching().//
            withStringMatcher(StringMatcher.ENDING));

    assertThat(repository.findAll(example), hasItems(skyler, walter));
}

From source file:example.springdata.mongodb.querybyexample.MongoOperationsIntegrationTests.java

/**
 * @see #153//w w  w  .j ava 2 s  .  c o  m
 */
@Test
public void substringMatching() {

    Example<Person> example = Example.of(new Person("er", null, null), matching().//
            withStringMatcher(StringMatcher.ENDING));

    assertThat(operations.find(query(byExample(example)), Person.class), hasItems(skyler, walter));
}