Package org.springframework.data.jpa.showcase.snippets.test

Source Code of org.springframework.data.jpa.showcase.snippets.test.CustomerRepositoryIntegrationTest

package org.springframework.data.jpa.showcase.snippets.test;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.springframework.data.jpa.domain.Specifications.*;
import static org.springframework.data.jpa.showcase.snippets.CustomerSpecifications.*;

import java.util.List;

import org.joda.time.LocalDate;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.showcase.after.CustomerRepository;
import org.springframework.data.jpa.showcase.core.Customer;

/**
* Snippets to show the usage of {@link Specification}s.
*
* @author Oliver Gierke
*/
public class CustomerRepositoryIntegrationTest {

  private CustomerRepository repository;

  public void findsCustomersBySpecification() throws Exception {

    Customer dave = repository.findOne(1L);

    LocalDate expiryLimit = new LocalDate(2011, 3, 1);
    List<Customer> result = repository.findAll(where(accountExpiresBefore(expiryLimit)));

    assertThat(result.size(), is(1));
    assertThat(result, hasItems(dave));
  }
}
TOP

Related Classes of org.springframework.data.jpa.showcase.snippets.test.CustomerRepositoryIntegrationTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.