|
40 | 40 | @SpringApplicationConfiguration(classes = ApplicationConfiguration.class)
|
41 | 41 | public class UserRepositoryIntegrationTests {
|
42 | 42 |
|
43 |
| - @Autowired UserRepository repository; |
| 43 | + @Autowired |
| 44 | + UserRepository repository; |
44 | 45 |
|
45 |
| - User skyler, walter, flynn, marie, hank; |
| 46 | + User skyler, walter, flynn, marie, hank; |
46 | 47 |
|
47 |
| - @Before |
48 |
| - public void setUp() { |
| 48 | + @Before |
| 49 | + public void setUp() { |
49 | 50 |
|
50 |
| - repository.deleteAll(); |
| 51 | + repository.deleteAll(); |
51 | 52 |
|
52 |
| - this.skyler = repository.save(new User("Skyler", "White", 45)); |
53 |
| - this.walter = repository.save(new User("Walter", "White", 50)); |
54 |
| - this.flynn = repository.save(new User("Walter Jr. (Flynn)", "White", 17)); |
55 |
| - this.marie = repository.save(new User("Marie", "Schrader", 38)); |
56 |
| - this.hank = repository.save(new User("Hank", "Schrader", 43)); |
57 |
| - } |
| 53 | + this.skyler = repository.save(new User("Skyler", "White", 45)); |
| 54 | + this.walter = repository.save(new User("Walter", "White", 50)); |
| 55 | + this.flynn = repository.save(new User("Walter Jr. (Flynn)", "White", 17)); |
| 56 | + this.marie = repository.save(new User("Marie", "Schrader", 38)); |
| 57 | + this.hank = repository.save(new User("Hank", "Schrader", 43)); |
| 58 | + } |
58 | 59 |
|
59 |
| - /** |
60 |
| - * @see DATAJPA-218 |
61 |
| - */ |
62 |
| - @Test |
63 |
| - public void countBySimpleExample() { |
| 60 | + /** |
| 61 | + * @see DATAJPA-218 |
| 62 | + */ |
| 63 | + @Test |
| 64 | + public void countBySimpleExample() { |
64 | 65 |
|
65 |
| - Example<User> example = Example.of(new User(null, "White", null)); |
| 66 | + Example<User> example = Example.of(new User(null, "White", null)); |
66 | 67 |
|
67 |
| - assertThat(repository.count(example), is(3L)); |
68 |
| - } |
| 68 | + assertThat(repository.count(example), is(3L)); |
| 69 | + } |
69 | 70 |
|
70 |
| - /** |
71 |
| - * @see DATAJPA-218 |
72 |
| - */ |
73 |
| - @Test |
74 |
| - public void ignorePropertiesAndMatchByAge() { |
| 71 | + /** |
| 72 | + * @see DATAJPA-218 |
| 73 | + */ |
| 74 | + @Test |
| 75 | + public void ignorePropertiesAndMatchByAge() { |
75 | 76 |
|
76 |
| - ExampleSpec<User> exampleSpec = ExampleSpec.of(User.class). // |
77 |
| - withIgnorePaths("firstname", "lastname"); |
| 77 | + ExampleSpec exampleSpec = ExampleSpec.untyped(). // |
| 78 | + withIgnorePaths("firstname", "lastname"); |
78 | 79 |
|
79 |
| - assertThat(repository.findOne(Example.of(flynn, exampleSpec)), is(flynn)); |
80 |
| - } |
| 80 | + assertThat(repository.findOne(Example.of(flynn, exampleSpec)), is(flynn)); |
| 81 | + } |
81 | 82 |
|
82 |
| - /** |
83 |
| - * @see DATAJPA-218 |
84 |
| - */ |
85 |
| - @Test |
86 |
| - public void substringMatching() { |
| 83 | + /** |
| 84 | + * @see DATAJPA-218 |
| 85 | + */ |
| 86 | + @Test |
| 87 | + public void substringMatching() { |
87 | 88 |
|
88 |
| - ExampleSpec<User> exampleSpec = ExampleSpec.of(User.class).// |
89 |
| - withStringMatcherEnding(); |
| 89 | + ExampleSpec exampleSpec = ExampleSpec.untyped().// |
| 90 | + withStringMatcherEnding(); |
90 | 91 |
|
91 |
| - assertThat(repository.findAll(Example.of(new User("er", null, null), exampleSpec)), hasItems(skyler, walter)); |
92 |
| - } |
| 92 | + assertThat(repository.findAll(Example.of(new User("er", null, null), exampleSpec)), hasItems(skyler, walter)); |
| 93 | + } |
93 | 94 |
|
94 |
| - /** |
95 |
| - * @see DATAJPA-218 |
96 |
| - */ |
97 |
| - @Test |
98 |
| - public void matchStartingStringsIgnoreCase() { |
| 95 | + /** |
| 96 | + * @see DATAJPA-218 |
| 97 | + */ |
| 98 | + @Test |
| 99 | + public void matchStartingStringsIgnoreCase() { |
99 | 100 |
|
100 |
| - ExampleSpec<User> exampleSpec = ExampleSpec.of(User.class). // |
101 |
| - withIgnorePaths("age").// |
102 |
| - withMatcher("firstname", startsWith()).// |
103 |
| - withMatcher("lastname", ignoreCase()); |
| 101 | + ExampleSpec exampleSpec = ExampleSpec.untyped(). // |
| 102 | + withIgnorePaths("age").// |
| 103 | + withMatcher("firstname", startsWith()).// |
| 104 | + withMatcher("lastname", ignoreCase()); |
104 | 105 |
|
105 |
| - assertThat(repository.findAll(Example.of(new User("Walter", "WHITE", null), exampleSpec)), hasItems(flynn, walter)); |
106 |
| - } |
| 106 | + assertThat(repository.findAll(Example.of(new User("Walter", "WHITE", null), exampleSpec)), hasItems(flynn, walter)); |
| 107 | + } |
107 | 108 |
|
108 |
| - /** |
109 |
| - * @see DATAJPA-218 |
110 |
| - */ |
111 |
| - @Test |
112 |
| - public void configuringMatchersUsingLambdas() { |
| 109 | + /** |
| 110 | + * @see DATAJPA-218 |
| 111 | + */ |
| 112 | + @Test |
| 113 | + public void configuringMatchersUsingLambdas() { |
113 | 114 |
|
114 |
| - ExampleSpec<User> exampleSpec = ExampleSpec.of(User.class).withIgnorePaths("age"). // |
115 |
| - withMatcher("firstname", matcher -> matcher.startsWith()). // |
116 |
| - withMatcher("lastname", matcher -> matcher.ignoreCase()); |
| 115 | + ExampleSpec exampleSpec = ExampleSpec.untyped().withIgnorePaths("age"). // |
| 116 | + withMatcher("firstname", matcher -> matcher.startsWith()). // |
| 117 | + withMatcher("lastname", matcher -> matcher.ignoreCase()); |
117 | 118 |
|
118 |
| - assertThat(repository.findAll(Example.of(new User("Walter", "WHITE", null), exampleSpec)), hasItems(flynn, walter)); |
119 |
| - } |
| 119 | + assertThat(repository.findAll(Example.of(new User("Walter", "WHITE", null), exampleSpec)), hasItems(flynn, walter)); |
| 120 | + } |
120 | 121 |
|
121 |
| - /** |
122 |
| - * @see DATAJPA-218 |
123 |
| - */ |
124 |
| - @Test |
125 |
| - public void valueTransformer() { |
| 122 | + /** |
| 123 | + * @see DATAJPA-218 |
| 124 | + */ |
| 125 | + @Test |
| 126 | + public void valueTransformer() { |
126 | 127 |
|
127 |
| - ExampleSpec<User> exampleSpec = ExampleSpec.of(User.class). // |
128 |
| - withMatcher("age", matcher -> matcher.transform(value -> Integer.valueOf(50))); |
| 128 | + ExampleSpec exampleSpec = ExampleSpec.untyped(). // |
| 129 | + withMatcher("age", matcher -> matcher.transform(value -> Integer.valueOf(50))); |
129 | 130 |
|
130 |
| - assertThat(repository.findAll(Example.of(new User(null, "White", 99), exampleSpec)), hasItems(walter)); |
131 |
| - } |
| 131 | + assertThat(repository.findAll(Example.of(new User(null, "White", 99), exampleSpec)), hasItems(walter)); |
| 132 | + } |
132 | 133 |
|
133 | 134 | }
|
0 commit comments