15
15
*/
16
16
package org .springframework .data .jpa .repository ;
17
17
18
+ import static java .util .Arrays .*;
18
19
import static org .assertj .core .api .Assertions .*;
19
20
import static org .springframework .data .domain .Example .*;
20
21
import static org .springframework .data .domain .ExampleMatcher .*;
@@ -151,7 +152,7 @@ void findsAllByGivenIds() {
151
152
152
153
flushTestUsers ();
153
154
154
- assertThat (repository .findAllById (Arrays . asList (firstUser .getId (), secondUser .getId ()))).contains (firstUser ,
155
+ assertThat (repository .findAllById (asList (firstUser .getId (), secondUser .getId ()))).contains (firstUser ,
155
156
secondUser );
156
157
}
157
158
@@ -166,7 +167,7 @@ void testReadByIdReturnsNullForNotFoundEntities() {
166
167
@ Test
167
168
void savesCollectionCorrectly () throws Exception {
168
169
169
- assertThat (repository .saveAll (Arrays . asList (firstUser , secondUser , thirdUser ))).hasSize (3 ).contains (firstUser ,
170
+ assertThat (repository .saveAll (asList (firstUser , secondUser , thirdUser ))).hasSize (3 ).contains (firstUser ,
170
171
secondUser , thirdUser );
171
172
}
172
173
@@ -238,27 +239,41 @@ void returnsAllIgnoreCaseSortedCorrectly() throws Exception {
238
239
}
239
240
240
241
@ Test
241
- void deleteColletionOfEntities () {
242
+ void deleteCollectionOfEntities () {
242
243
243
244
flushTestUsers ();
244
245
245
246
long before = repository .count ();
246
247
247
- repository .deleteAll (Arrays . asList (firstUser , secondUser ));
248
+ repository .deleteAll (asList (firstUser , secondUser ));
248
249
249
250
assertThat (repository .existsById (firstUser .getId ())).isFalse ();
250
251
assertThat (repository .existsById (secondUser .getId ())).isFalse ();
251
252
assertThat (repository .count ()).isEqualTo (before - 2 );
252
253
}
253
254
254
255
@ Test
255
- void batchDeleteColletionOfEntities () {
256
+ void batchDeleteCollectionOfEntities () {
256
257
257
258
flushTestUsers ();
258
259
259
260
long before = repository .count ();
260
261
261
- repository .deleteInBatch (Arrays .asList (firstUser , secondUser ));
262
+ repository .deleteInBatch (asList (firstUser , secondUser ));
263
+
264
+ assertThat (repository .existsById (firstUser .getId ())).isFalse ();
265
+ assertThat (repository .existsById (secondUser .getId ())).isFalse ();
266
+ assertThat (repository .count ()).isEqualTo (before - 2 );
267
+ }
268
+
269
+ @ Test // DATAJPA-1818
270
+ void deleteCollectionOfEntitiesById () {
271
+
272
+ flushTestUsers ();
273
+
274
+ long before = repository .count ();
275
+
276
+ repository .deleteAllById (asList (firstUser .getId (), secondUser .getId ()));
262
277
263
278
assertThat (repository .existsById (firstUser .getId ())).isFalse ();
264
279
assertThat (repository .existsById (secondUser .getId ())).isFalse ();
@@ -603,7 +618,7 @@ void executesQueryMethodWithDeepTraversalCorrectly() throws Exception {
603
618
604
619
firstUser .setManager (secondUser );
605
620
thirdUser .setManager (firstUser );
606
- repository .saveAll (Arrays . asList (firstUser , thirdUser ));
621
+ repository .saveAll (asList (firstUser , thirdUser ));
607
622
608
623
assertThat (repository .findByManagerLastname ("Arrasz" )).containsOnly (firstUser );
609
624
assertThat (repository .findByManagerLastname ("Gierke" )).containsOnly (thirdUser );
@@ -616,7 +631,7 @@ void executesFindByColleaguesLastnameCorrectly() throws Exception {
616
631
617
632
firstUser .addColleague (secondUser );
618
633
thirdUser .addColleague (firstUser );
619
- repository .saveAll (Arrays . asList (firstUser , thirdUser ));
634
+ repository .saveAll (asList (firstUser , thirdUser ));
620
635
621
636
assertThat (repository .findByColleaguesLastname (secondUser .getLastname ())).containsOnly (firstUser );
622
637
@@ -1178,7 +1193,7 @@ void findByElementCollectionAttribute() {
1178
1193
1179
1194
flushTestUsers ();
1180
1195
1181
- List <User > result = repository .findByAttributesIn (new HashSet <>(Arrays . asList ("cool" , "hip" )));
1196
+ List <User > result = repository .findByAttributesIn (new HashSet <>(asList ("cool" , "hip" )));
1182
1197
1183
1198
assertThat (result ).containsOnly (firstUser , secondUser );
1184
1199
}
@@ -1731,7 +1746,7 @@ void findAllByExampleWithAssociation() {
1731
1746
1732
1747
firstUser .setManager (secondUser );
1733
1748
thirdUser .setManager (firstUser );
1734
- repository .saveAll (Arrays . asList (firstUser , thirdUser ));
1749
+ repository .saveAll (asList (firstUser , thirdUser ));
1735
1750
1736
1751
User manager = new User ();
1737
1752
manager .setLastname ("Arrasz" );
@@ -1854,7 +1869,7 @@ void findAllByExampleWithIncludeNull() {
1854
1869
fifthUser .setFirstname (firstUser .getFirstname ());
1855
1870
fifthUser .setLastname (firstUser .getLastname ());
1856
1871
1857
- repository .saveAll (Arrays . asList (firstUser , fifthUser ));
1872
+ repository .saveAll (asList (firstUser , fifthUser ));
1858
1873
1859
1874
User prototype = new User ();
1860
1875
prototype .setFirstname (firstUser .getFirstname ());
@@ -2242,7 +2257,7 @@ void findByElementCollectionInAttributeIgnoreCase() {
2242
2257
2243
2258
flushTestUsers ();
2244
2259
2245
- List <User > result = repository .findByAttributesIgnoreCaseIn (new HashSet <>(Arrays . asList ("cOOl" , "hIP" )));
2260
+ List <User > result = repository .findByAttributesIgnoreCaseIn (new HashSet <>(asList ("cOOl" , "hIP" )));
2246
2261
2247
2262
assertThat (result ).containsOnly (firstUser , secondUser );
2248
2263
}
@@ -2256,7 +2271,7 @@ void findByElementCollectionNotInAttributeIgnoreCase() {
2256
2271
2257
2272
flushTestUsers ();
2258
2273
2259
- List <User > result = repository .findByAttributesIgnoreCaseNotIn (Arrays . asList ("CooL" , "HIp" ));
2274
+ List <User > result = repository .findByAttributesIgnoreCaseNotIn (asList ("CooL" , "HIp" ));
2260
2275
2261
2276
assertThat (result ).containsOnly (thirdUser );
2262
2277
}
@@ -2284,7 +2299,7 @@ void findByElementCollectionInAttributeIgnoreCaseWithNulls() {
2284
2299
2285
2300
flushTestUsers ();
2286
2301
2287
- List <User > result = repository .findByAttributesIgnoreCaseIn (Arrays . asList ("cOOl" , null ));
2302
+ List <User > result = repository .findByAttributesIgnoreCaseIn (asList ("cOOl" , null ));
2288
2303
2289
2304
assertThat (result ).containsOnly (firstUser );
2290
2305
}
0 commit comments