|
3 | 3 | import static org.hamcrest.Matchers.*;
|
4 | 4 | import static org.junit.Assert.*;
|
5 | 5 |
|
6 |
| -import java.util.List; |
7 |
| - |
8 | 6 | import org.junit.Test;
|
9 | 7 | import org.springframework.beans.factory.annotation.Autowired;
|
10 | 8 | import org.springframework.data.domain.Page;
|
|
13 | 11 | import org.springframework.data.jpa.showcase.core.Customer;
|
14 | 12 | import org.springframework.test.context.ContextConfiguration;
|
15 | 13 |
|
16 |
| - |
17 | 14 | /**
|
18 | 15 | * @author Oliver Gierke
|
19 | 16 | */
|
20 | 17 | @ContextConfiguration("classpath:application-context-after.xml")
|
21 | 18 | public class CustomerRepositoryIntegrationTest extends AbstractShowcaseTest {
|
22 | 19 |
|
23 |
| - @Autowired |
24 |
| - CustomerRepository repository; |
25 |
| - |
26 |
| - |
27 |
| - @Test |
28 |
| - public void findsAllCustomers() throws Exception { |
29 |
| - |
30 |
| - List<Customer> result = repository.findAll(); |
| 20 | + @Autowired |
| 21 | + CustomerRepository repository; |
31 | 22 |
|
32 |
| - assertThat(result, is(notNullValue())); |
33 |
| - assertFalse(result.isEmpty()); |
34 |
| - } |
| 23 | + @Test |
| 24 | + public void findsAllCustomers() throws Exception { |
35 | 25 |
|
| 26 | + Iterable<Customer> result = repository.findAll(); |
36 | 27 |
|
37 |
| - @Test |
38 |
| - public void findsFirstPageOfMatthews() throws Exception { |
| 28 | + assertThat(result, is(notNullValue())); |
| 29 | + assertTrue(result.iterator().hasNext()); |
| 30 | + } |
39 | 31 |
|
40 |
| - Page<Customer> customers = |
41 |
| - repository.findByLastname("Matthews", new PageRequest(0, 2)); |
| 32 | + @Test |
| 33 | + public void findsFirstPageOfMatthews() throws Exception { |
42 | 34 |
|
43 |
| - assertThat(customers.getContent().size(), is(2)); |
44 |
| - assertFalse(customers.hasPreviousPage()); |
45 |
| - } |
| 35 | + Page<Customer> customers = repository.findByLastname("Matthews", new PageRequest(0, 2)); |
46 | 36 |
|
| 37 | + assertThat(customers.getContent().size(), is(2)); |
| 38 | + assertFalse(customers.hasPreviousPage()); |
| 39 | + } |
47 | 40 |
|
48 |
| - @Test |
49 |
| - public void findsCustomerById() throws Exception { |
| 41 | + @Test |
| 42 | + public void findsCustomerById() throws Exception { |
50 | 43 |
|
51 |
| - Customer customer = repository.findOne(2L); |
| 44 | + Customer customer = repository.findOne(2L); |
52 | 45 |
|
53 |
| - assertThat(customer.getFirstname(), is("Carter")); |
54 |
| - assertThat(customer.getLastname(), is("Beauford")); |
55 |
| - } |
| 46 | + assertThat(customer.getFirstname(), is("Carter")); |
| 47 | + assertThat(customer.getLastname(), is("Beauford")); |
| 48 | + } |
56 | 49 | }
|
0 commit comments