@@ -151,18 +151,14 @@ class CountryServiceImplTest extends Specification {
151
151
service. findIdsByNames(names) == []
152
152
}
153
153
154
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
155
154
def ' findIdsByNames() should invoke dao, pass argument and return result from dao' () {
156
155
given :
157
156
Set<String > expectedNames = Random . setOfStrings()
158
157
List<Integer > expectedResult = Random . listOfIntegers()
159
158
when :
160
159
List<Integer > result = service. findIdsByNames(expectedNames)
161
160
then :
162
- 1 * countryDao. findIdsByNames({ Set<String > names ->
163
- assert names == expectedNames
164
- return true
165
- }) >> expectedResult
161
+ 1 * countryDao. findIdsByNames(expectedNames) >> expectedResult
166
162
and :
167
163
result == expectedResult
168
164
}
@@ -187,7 +183,6 @@ class CountryServiceImplTest extends Specification {
187
183
thrown IllegalArgumentException
188
184
}
189
185
190
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
191
186
def ' findIdsWhenNameStartsWith() should invoke dao, pass argument and return result from dao' () {
192
187
given :
193
188
String name = between(1 , 10 ). english()
@@ -197,10 +192,7 @@ class CountryServiceImplTest extends Specification {
197
192
when :
198
193
List<Integer > result = service. findIdsWhenNameStartsWith(name)
199
194
then :
200
- 1 * countryDao. findIdsByNamePattern({ String pattern ->
201
- assert pattern == expectedPattern
202
- return true
203
- }) >> expectedResult
195
+ 1 * countryDao. findIdsByNamePattern(expectedPattern) >> expectedResult
204
196
and :
205
197
result == expectedResult
206
198
}
@@ -225,15 +217,11 @@ class CountryServiceImplTest extends Specification {
225
217
}
226
218
227
219
@Unroll
228
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
229
220
def " findAllAsLinkEntities(String) should pass language '#expectedLanguage' to dao" (String expectedLanguage) {
230
221
when :
231
222
service. findAllAsLinkEntities(expectedLanguage)
232
223
then :
233
- 1 * countryDao. findAllAsLinkEntities({ String language ->
234
- assert language == expectedLanguage
235
- return true
236
- })
224
+ 1 * countryDao. findAllAsLinkEntities(expectedLanguage)
237
225
where :
238
226
expectedLanguage | _
239
227
' ru' | _
@@ -256,7 +244,6 @@ class CountryServiceImplTest extends Specification {
256
244
null | _
257
245
}
258
246
259
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
260
247
def " findOneAsLinkEntity() should pass arguments to dao" () {
261
248
given :
262
249
String expectedSlug = ' france'
@@ -267,16 +254,7 @@ class CountryServiceImplTest extends Specification {
267
254
when :
268
255
LinkEntityDto actualDto = service. findOneAsLinkEntity(expectedSlug, expectedLang)
269
256
then :
270
- 1 * countryDao. findOneAsLinkEntity(
271
- { String countrySlug ->
272
- assert expectedSlug == countrySlug
273
- return true
274
- },
275
- { String lang ->
276
- assert expectedLang == lang
277
- return true
278
- }
279
- ) >> expectedDto
257
+ 1 * countryDao. findOneAsLinkEntity(expectedSlug, expectedLang) >> expectedDto
280
258
and :
281
259
actualDto == expectedDto
282
260
}
@@ -307,17 +285,13 @@ class CountryServiceImplTest extends Specification {
307
285
thrown IllegalArgumentException
308
286
}
309
287
310
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
311
288
def " countCountriesOf() should pass arguments to dao" () {
312
289
given :
313
290
Integer expectedCollectionId = 9
314
291
when :
315
292
service. countCountriesOf(expectedCollectionId)
316
293
then :
317
- 1 * countryDao. countCountriesOfCollection({ Integer collectionId ->
318
- assert expectedCollectionId == collectionId
319
- return true
320
- }) >> 0L
294
+ 1 * countryDao. countCountriesOfCollection(expectedCollectionId) >> 0L
321
295
}
322
296
323
297
//
@@ -360,15 +334,11 @@ class CountryServiceImplTest extends Specification {
360
334
result == 2L
361
335
}
362
336
363
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
364
337
def " countByName() should pass country name to dao in lowercase" () {
365
338
when :
366
339
service. countByName(' Canada' )
367
340
then :
368
- 1 * countryDao. countByName({ String name ->
369
- assert name == ' canada'
370
- return true
371
- })
341
+ 1 * countryDao. countByName(' canada' )
372
342
}
373
343
374
344
//
@@ -391,15 +361,11 @@ class CountryServiceImplTest extends Specification {
391
361
result == 2L
392
362
}
393
363
394
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
395
364
def " countByNameRu() should pass category name to dao in lowercase" () {
396
365
when :
397
366
service. countByNameRu(' Канада' )
398
367
then :
399
- 1 * countryDao. countByNameRu({ String name ->
400
- assert name == ' канада'
401
- return true
402
- })
368
+ 1 * countryDao. countByNameRu(' канада' )
403
369
}
404
370
405
371
//
@@ -413,7 +379,6 @@ class CountryServiceImplTest extends Specification {
413
379
thrown IllegalArgumentException
414
380
}
415
381
416
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
417
382
def " countAddedSince() should invoke dao, pass argument and return result from dao" () {
418
383
given :
419
384
Date expectedDate = new Date ()
@@ -422,10 +387,7 @@ class CountryServiceImplTest extends Specification {
422
387
when :
423
388
long result = service. countAddedSince(expectedDate)
424
389
then :
425
- 1 * countryDao. countAddedSince({ Date date ->
426
- assert date == expectedDate
427
- return true
428
- }) >> expectedResult
390
+ 1 * countryDao. countAddedSince(expectedDate) >> expectedResult
429
391
and :
430
392
result == expectedResult
431
393
}
@@ -441,7 +403,6 @@ class CountryServiceImplTest extends Specification {
441
403
thrown IllegalArgumentException
442
404
}
443
405
444
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
445
406
def " countUntranslatedNamesSince() should invoke dao, pass argument and return result from dao" () {
446
407
given :
447
408
Date expectedDate = new Date ()
@@ -450,10 +411,7 @@ class CountryServiceImplTest extends Specification {
450
411
when :
451
412
long result = service. countUntranslatedNamesSince(expectedDate)
452
413
then :
453
- 1 * countryDao. countUntranslatedNamesSince({ Date date ->
454
- assert date == expectedDate
455
- return true
456
- }) >> expectedResult
414
+ 1 * countryDao. countUntranslatedNamesSince(expectedDate) >> expectedResult
457
415
and :
458
416
result == expectedResult
459
417
}
@@ -469,7 +427,6 @@ class CountryServiceImplTest extends Specification {
469
427
thrown IllegalArgumentException
470
428
}
471
429
472
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
473
430
def " getStatisticsOf() should pass arguments to dao" () {
474
431
given :
475
432
Integer expectedCollectionId = 17
@@ -478,16 +435,7 @@ class CountryServiceImplTest extends Specification {
478
435
when :
479
436
service. getStatisticsOf(expectedCollectionId, expectedLang)
480
437
then :
481
- 1 * countryDao. getStatisticsOf(
482
- { Integer collectionId ->
483
- assert expectedCollectionId == collectionId
484
- return true
485
- },
486
- { String lang ->
487
- assert expectedLang == lang
488
- return true
489
- }
490
- ) >> null
438
+ 1 * countryDao. getStatisticsOf(expectedCollectionId, expectedLang) >> null
491
439
}
492
440
493
441
//
@@ -501,50 +449,38 @@ class CountryServiceImplTest extends Specification {
501
449
thrown IllegalArgumentException
502
450
}
503
451
504
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
505
452
def ' suggestCountryForUser() should return country of the last created series' () {
506
453
given :
507
454
Integer expectedUserId = 18
508
455
String expectedSlug = ' brazil'
509
456
when :
510
457
String slug = service. suggestCountryForUser(expectedUserId)
511
458
then :
512
- 1 * countryDao. findCountryOfLastCreatedSeriesByUser({ Integer userId ->
513
- assert expectedUserId == userId
514
- return true
515
- }) >> expectedSlug
459
+ 1 * countryDao. findCountryOfLastCreatedSeriesByUser(expectedUserId) >> expectedSlug
516
460
and :
517
461
slug == expectedSlug
518
462
}
519
463
520
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
521
464
def ' suggestCountryForUser() should return popular country from collection' () {
522
465
given :
523
466
Integer expectedUserId = 19
524
467
String expectedSlug = ' mexica'
525
468
when :
526
469
String slug = service. suggestCountryForUser(expectedUserId)
527
470
then :
528
- 1 * countryDao. findPopularCountryInCollection({ Integer userId ->
529
- assert expectedUserId == userId
530
- return true
531
- }) >> expectedSlug
471
+ 1 * countryDao. findPopularCountryInCollection(expectedUserId) >> expectedSlug
532
472
and :
533
473
slug == expectedSlug
534
474
}
535
475
536
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
537
476
def ' suggestCountryForUser() should return a recently created country' () {
538
477
given :
539
478
Integer expectedUserId = 21
540
479
String expectedSlug = ' spain'
541
480
when :
542
481
String slug = service. suggestCountryForUser(expectedUserId)
543
482
then :
544
- 1 * countryDao. findLastCountryCreatedByUser({ Integer userId ->
545
- assert expectedUserId == userId
546
- return true
547
- }) >> expectedSlug
483
+ 1 * countryDao. findLastCountryCreatedByUser(expectedUserId) >> expectedSlug
548
484
and :
549
485
slug == expectedSlug
550
486
}
0 commit comments