@@ -152,18 +152,14 @@ class CategoryServiceImplTest extends Specification {
152
152
service. findIdsByNames(names) == []
153
153
}
154
154
155
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
156
155
def ' findIdsByNames() should invoke dao, pass argument and return result from dao' () {
157
156
given :
158
157
Set<String > expectedNames = Random . setOfStrings()
159
158
List<Integer > expectedResult = Random . listOfIntegers()
160
159
when :
161
160
List<Integer > result = service. findIdsByNames(expectedNames)
162
161
then :
163
- 1 * categoryDao. findIdsByNames({ Set<String > names ->
164
- assert names == expectedNames
165
- return true
166
- }) >> expectedResult
162
+ 1 * categoryDao. findIdsByNames(expectedNames) >> expectedResult
167
163
and :
168
164
result == expectedResult
169
165
}
@@ -188,7 +184,6 @@ class CategoryServiceImplTest extends Specification {
188
184
thrown IllegalArgumentException
189
185
}
190
186
191
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
192
187
def ' findIdsWhenNameStartsWith() should invoke dao, pass argument and return result from dao' () {
193
188
given :
194
189
String name = between(1 , 10 ). english()
@@ -198,10 +193,7 @@ class CategoryServiceImplTest extends Specification {
198
193
when :
199
194
List<Integer > result = service. findIdsWhenNameStartsWith(name)
200
195
then :
201
- 1 * categoryDao. findIdsByNamePattern({ String pattern ->
202
- assert pattern == expectedPattern
203
- return true
204
- }) >> expectedResult
196
+ 1 * categoryDao. findIdsByNamePattern(expectedPattern) >> expectedResult
205
197
and :
206
198
result == expectedResult
207
199
}
@@ -226,15 +218,11 @@ class CategoryServiceImplTest extends Specification {
226
218
}
227
219
228
220
@Unroll
229
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
230
221
def " findAllAsLinkEntities(String) should pass language '#expectedLanguage' to dao" (String expectedLanguage) {
231
222
when :
232
223
service. findAllAsLinkEntities(expectedLanguage)
233
224
then :
234
- 1 * categoryDao. findAllAsLinkEntities({ String language ->
235
- assert language == expectedLanguage
236
- return true
237
- })
225
+ 1 * categoryDao. findAllAsLinkEntities(expectedLanguage)
238
226
where :
239
227
expectedLanguage | _
240
228
' ru' | _
@@ -245,18 +233,14 @@ class CategoryServiceImplTest extends Specification {
245
233
// Tests for findCategoriesWithParents()
246
234
//
247
235
248
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
249
236
def ' findCategoriesWithParents() should invoke dao and return its result' () {
250
237
given :
251
238
String expectedLang = nullOr(Random . lang())
252
239
List<EntityWithParentDto > expectedResult = Random . listOfEntityWithParentDto()
253
240
when :
254
241
List<EntityWithParentDto > result = service. findCategoriesWithParents(expectedLang)
255
242
then :
256
- 1 * categoryDao. findCategoriesWithParents({ String lang ->
257
- assert lang == expectedLang
258
- return true
259
- }) >> expectedResult
243
+ 1 * categoryDao. findCategoriesWithParents(expectedLang) >> expectedResult
260
244
and :
261
245
result == expectedResult
262
246
}
@@ -278,7 +262,6 @@ class CategoryServiceImplTest extends Specification {
278
262
null | _
279
263
}
280
264
281
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
282
265
def " findOneAsLinkEntity() should pass arguments to dao" () {
283
266
given :
284
267
String expectedSlug = ' people'
@@ -289,16 +272,7 @@ class CategoryServiceImplTest extends Specification {
289
272
when :
290
273
LinkEntityDto actualDto = service. findOneAsLinkEntity(expectedSlug, expectedLang)
291
274
then :
292
- 1 * categoryDao. findOneAsLinkEntity(
293
- { String slug ->
294
- assert expectedSlug == slug
295
- return true
296
- },
297
- { String lang ->
298
- assert expectedLang == lang
299
- return true
300
- }
301
- ) >> expectedDto
275
+ 1 * categoryDao. findOneAsLinkEntity(expectedSlug, expectedLang) >> expectedDto
302
276
and :
303
277
actualDto == expectedDto
304
278
}
@@ -329,17 +303,13 @@ class CategoryServiceImplTest extends Specification {
329
303
thrown IllegalArgumentException
330
304
}
331
305
332
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
333
306
def " countCategoriesOf() should pass arguments to dao" () {
334
307
given :
335
308
Integer expectedCollectionId = 10
336
309
when :
337
310
service. countCategoriesOf(expectedCollectionId)
338
311
then :
339
- 1 * categoryDao. countCategoriesOfCollection({ Integer collectionId ->
340
- assert expectedCollectionId == collectionId
341
- return true
342
- }) >> 0L
312
+ 1 * categoryDao. countCategoriesOfCollection(expectedCollectionId) >> 0L
343
313
}
344
314
345
315
//
@@ -382,15 +352,11 @@ class CategoryServiceImplTest extends Specification {
382
352
result == 2L
383
353
}
384
354
385
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
386
355
def " countByName() should pass category name to dao in lowercase" () {
387
356
when :
388
357
service. countByName(' Sport' )
389
358
then :
390
- 1 * categoryDao. countByName({ String name ->
391
- assert name == ' sport'
392
- return true
393
- })
359
+ 1 * categoryDao. countByName(' sport' )
394
360
}
395
361
396
362
//
@@ -413,15 +379,11 @@ class CategoryServiceImplTest extends Specification {
413
379
result == 2L
414
380
}
415
381
416
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
417
382
def " countByNameRu() should pass category name to dao in lowercase" () {
418
383
when :
419
384
service. countByNameRu(' Спорт' )
420
385
then :
421
- 1 * categoryDao. countByNameRu({ String name ->
422
- assert name == ' спорт'
423
- return true
424
- })
386
+ 1 * categoryDao. countByNameRu(' спорт' )
425
387
}
426
388
427
389
//
@@ -435,7 +397,6 @@ class CategoryServiceImplTest extends Specification {
435
397
thrown IllegalArgumentException
436
398
}
437
399
438
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
439
400
def " countAddedSince() should invoke dao, pass argument and return result from dao" () {
440
401
given :
441
402
Date expectedDate = new Date ()
@@ -444,10 +405,7 @@ class CategoryServiceImplTest extends Specification {
444
405
when :
445
406
long result = service. countAddedSince(expectedDate)
446
407
then :
447
- 1 * categoryDao. countAddedSince({ Date date ->
448
- assert date == expectedDate
449
- return true
450
- }) >> expectedResult
408
+ 1 * categoryDao. countAddedSince(expectedDate) >> expectedResult
451
409
and :
452
410
result == expectedResult
453
411
}
@@ -463,7 +421,6 @@ class CategoryServiceImplTest extends Specification {
463
421
thrown IllegalArgumentException
464
422
}
465
423
466
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
467
424
def " countUntranslatedNamesSince() should invoke dao, pass argument and return result from dao" () {
468
425
given :
469
426
Date expectedDate = new Date ()
@@ -472,10 +429,7 @@ class CategoryServiceImplTest extends Specification {
472
429
when :
473
430
long result = service. countUntranslatedNamesSince(expectedDate)
474
431
then :
475
- 1 * categoryDao. countUntranslatedNamesSince({ Date date ->
476
- assert date == expectedDate
477
- return true
478
- }) >> expectedResult
432
+ 1 * categoryDao. countUntranslatedNamesSince(expectedDate) >> expectedResult
479
433
and :
480
434
result == expectedResult
481
435
}
@@ -491,7 +445,6 @@ class CategoryServiceImplTest extends Specification {
491
445
thrown IllegalArgumentException
492
446
}
493
447
494
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
495
448
def " getStatisticsOf() should pass arguments to dao" () {
496
449
given :
497
450
Integer expectedCollectionId = 15
@@ -500,16 +453,7 @@ class CategoryServiceImplTest extends Specification {
500
453
when :
501
454
service. getStatisticsOf(expectedCollectionId, expectedLang)
502
455
then :
503
- 1 * categoryDao. getStatisticsOf(
504
- { Integer collectionId ->
505
- assert expectedCollectionId == collectionId
506
- return true
507
- },
508
- { String lang ->
509
- assert expectedLang == lang
510
- return true
511
- }
512
- ) >> null
456
+ 1 * categoryDao. getStatisticsOf(expectedCollectionId, expectedLang) >> null
513
457
}
514
458
515
459
}
0 commit comments