@@ -152,7 +152,7 @@ class SeriesServiceImplTest extends Specification {
152
152
1 * seriesDao. add({ AddSeriesDbDto series ->
153
153
assert series?. countryId == expectedCountryId
154
154
return true
155
- }) >> 123
155
+ }) >> Random . id()
156
156
}
157
157
158
158
@Unroll
@@ -173,7 +173,7 @@ class SeriesServiceImplTest extends Specification {
173
173
assert series?. releaseMonth == expectedMonth
174
174
assert series?. releaseYear == expectedYear
175
175
return true
176
- }) >> 123
176
+ }) >> Random . id()
177
177
where :
178
178
day | month | year || expectedDay | expectedMonth | expectedYear
179
179
null | null | null || null | null | null
@@ -200,7 +200,7 @@ class SeriesServiceImplTest extends Specification {
200
200
1 * seriesDao. add({ AddSeriesDbDto series ->
201
201
assert series?. categoryId == expectedCategoryId
202
202
return true
203
- }) >> 123
203
+ }) >> Random . id()
204
204
}
205
205
206
206
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
@@ -214,7 +214,7 @@ class SeriesServiceImplTest extends Specification {
214
214
1 * seriesDao. add({ AddSeriesDbDto series ->
215
215
assert series?. quantity == expectedQuantity
216
216
return true
217
- }) >> 123
217
+ }) >> Random . id()
218
218
}
219
219
220
220
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
@@ -228,7 +228,7 @@ class SeriesServiceImplTest extends Specification {
228
228
1 * seriesDao. add({ AddSeriesDbDto series ->
229
229
assert series?. perforated == expectedResult
230
230
return true
231
- }) >> 123
231
+ }) >> Random . id()
232
232
}
233
233
234
234
@SuppressWarnings ([ ' ClosureAsLastMethodParameter' , ' UnnecessaryObjectReferences' , ' UnnecessaryReturnKeyword' ])
@@ -281,7 +281,7 @@ class SeriesServiceImplTest extends Specification {
281
281
1 * seriesDao. add({ AddSeriesDbDto series ->
282
282
assert series?. comment == expectedComment
283
283
return true
284
- }) >> 123
284
+ }) >> Random . id()
285
285
where :
286
286
canAddComment | comment || expectedComment
287
287
false | null || null
@@ -303,12 +303,12 @@ class SeriesServiceImplTest extends Specification {
303
303
assert DateUtils . roughlyEqual(series?. createdAt, new Date ())
304
304
assert DateUtils . roughlyEqual(series?. updatedAt, new Date ())
305
305
return true
306
- }) >> 123
306
+ }) >> Random . id()
307
307
}
308
308
309
309
def " add() should pass dto to series dao and return its result" () {
310
310
given :
311
- Integer expected = 456
311
+ Integer expected = Random . id()
312
312
when :
313
313
Integer actual = service. add(form, Random . userId(), false )
314
314
then :
@@ -323,7 +323,7 @@ class SeriesServiceImplTest extends Specification {
323
323
and :
324
324
form. setMichelNumbers(expectedNumbers. join(' ,' ))
325
325
and :
326
- Integer expectedSeriesId = 456
326
+ Integer expectedSeriesId = Random . id()
327
327
and :
328
328
seriesDao. add(_ as AddSeriesDbDto ) >> expectedSeriesId
329
329
when :
@@ -340,7 +340,7 @@ class SeriesServiceImplTest extends Specification {
340
340
and :
341
341
form. setScottNumbers(expectedNumbers. join(' ,' ))
342
342
and :
343
- Integer expectedSeriesId = 456
343
+ Integer expectedSeriesId = Random . id()
344
344
and :
345
345
seriesDao. add(_ as AddSeriesDbDto ) >> expectedSeriesId
346
346
when :
@@ -357,7 +357,7 @@ class SeriesServiceImplTest extends Specification {
357
357
and :
358
358
form. setYvertNumbers(expectedNumbers. join(' ,' ))
359
359
and :
360
- Integer expectedSeriesId = 456
360
+ Integer expectedSeriesId = Random . id()
361
361
and :
362
362
seriesDao. add(_ as AddSeriesDbDto ) >> expectedSeriesId
363
363
when :
@@ -374,7 +374,7 @@ class SeriesServiceImplTest extends Specification {
374
374
and :
375
375
form. setGibbonsNumbers(expectedNumbers. join(' ,' ))
376
376
and :
377
- Integer expectedSeriesId = 456
377
+ Integer expectedSeriesId = Random . id()
378
378
and :
379
379
seriesDao. add(_ as AddSeriesDbDto ) >> expectedSeriesId
380
380
when :
@@ -430,11 +430,11 @@ class SeriesServiceImplTest extends Specification {
430
430
431
431
def " add() should add image to the series" () {
432
432
given :
433
- Integer expectedSeriesId = 123
433
+ Integer expectedSeriesId = Random . id()
434
434
and :
435
435
seriesDao. add(_ as AddSeriesDbDto ) >> expectedSeriesId
436
436
and :
437
- Integer expectedImageId = 456
437
+ Integer expectedImageId = Random . id()
438
438
when :
439
439
service. add(form, Random . userId(), false )
440
440
then :
@@ -448,7 +448,7 @@ class SeriesServiceImplTest extends Specification {
448
448
given :
449
449
ImageInfoDto expectedImageInfo = new ImageInfoDto (654 , ' JPEG' )
450
450
and :
451
- seriesDao. add(_ as AddSeriesDbDto ) >> 111
451
+ seriesDao. add(_ as AddSeriesDbDto ) >> Random . id()
452
452
and :
453
453
imageService. addToSeries(_ as Integer , _ as Integer ) >> { throw new IllegalStateException () }
454
454
when :
@@ -467,7 +467,7 @@ class SeriesServiceImplTest extends Specification {
467
467
468
468
def " addImageToSeries() should throw exception when dto is null" () {
469
469
when :
470
- service. addImageToSeries(null , 111 , 222 )
470
+ service. addImageToSeries(null , Random . id() , 222 )
471
471
then :
472
472
thrown IllegalArgumentException
473
473
}
@@ -481,15 +481,15 @@ class SeriesServiceImplTest extends Specification {
481
481
482
482
def " addImageToSeries() should throw exception when user id is null" () {
483
483
when :
484
- service. addImageToSeries(imageForm, 111 , null )
484
+ service. addImageToSeries(imageForm, Random . id() , null )
485
485
then :
486
486
thrown IllegalArgumentException
487
487
}
488
488
489
489
@SuppressWarnings (' UnnecessaryReturnKeyword' )
490
490
def " addImageToSeries() should mark series as modified" () {
491
491
given :
492
- Integer expectedSeriesId = 123
492
+ Integer expectedSeriesId = Random . id()
493
493
Integer expectedUserId = 321
494
494
when :
495
495
service. addImageToSeries(imageForm, expectedSeriesId, expectedUserId)
@@ -508,16 +508,16 @@ class SeriesServiceImplTest extends Specification {
508
508
given :
509
509
imageForm. setImage(multipartFile)
510
510
when :
511
- service. addImageToSeries(imageForm, 111 , 222 )
511
+ service. addImageToSeries(imageForm, Random . id() , 222 )
512
512
then :
513
513
1 * imageService. save(multipartFile) >> TestObjects . createImageInfoDto()
514
514
}
515
515
516
516
def " addImageToSeries() should add image to series" () {
517
517
given :
518
- Integer expectedSeriesId = 123
518
+ Integer expectedSeriesId = Random . id()
519
519
Integer expectedUserId = 321
520
- Integer expectedImageId = 456
520
+ Integer expectedImageId = Random . id()
521
521
when :
522
522
service. addImageToSeries(imageForm, expectedSeriesId, expectedUserId)
523
523
then :
@@ -532,7 +532,7 @@ class SeriesServiceImplTest extends Specification {
532
532
and :
533
533
imageService. addToSeries(_ as Integer , _ as Integer ) >> { throw new IllegalStateException () }
534
534
when :
535
- service. addImageToSeries(imageForm, 111 , 222 )
535
+ service. addImageToSeries(imageForm, Random . id() , 222 )
536
536
then :
537
537
imageService. save(_) >> expectedImageInfo
538
538
and :
@@ -584,7 +584,7 @@ class SeriesServiceImplTest extends Specification {
584
584
585
585
def " countSeriesOf() should pass argument to dao" () {
586
586
given :
587
- Integer expectedCollectionId = 7
587
+ Integer expectedCollectionId = Random . id()
588
588
when :
589
589
service. countSeriesOf(expectedCollectionId)
590
590
then :
@@ -604,7 +604,7 @@ class SeriesServiceImplTest extends Specification {
604
604
605
605
def " countStampsOf() should pass arguments to dao" () {
606
606
given :
607
- Integer expectedCollectionId = 8
607
+ Integer expectedCollectionId = Random . id()
608
608
when :
609
609
service. countStampsOf(expectedCollectionId)
610
610
then :
@@ -674,7 +674,7 @@ class SeriesServiceImplTest extends Specification {
674
674
@SuppressWarnings ([ ' LineLength' , /* false positive: */ ' UnnecessaryBooleanExpression' ])
675
675
def " isSeriesExist() should return #expectedResult when dao returns #daoReturnValue" (Integer daoReturnValue, boolean expectedResult) {
676
676
given :
677
- Integer expectedSeriesId = 13
677
+ Integer expectedSeriesId = Random . id()
678
678
when :
679
679
boolean result = service. isSeriesExist(expectedSeriesId)
680
680
then :
@@ -700,7 +700,7 @@ class SeriesServiceImplTest extends Specification {
700
700
701
701
def " findFullInfoById() should return null when series not found" () {
702
702
when :
703
- SeriesDto result = service. findFullInfoById(10 , ' de' )
703
+ SeriesDto result = service. findFullInfoById(Random . id() , ' de' )
704
704
then :
705
705
1 * seriesDao. findByIdAsSeriesFullInfo(_ as Integer , _ as String )
706
706
and :
@@ -716,7 +716,7 @@ class SeriesServiceImplTest extends Specification {
716
716
@SuppressWarnings (' UnnecessaryObjectReferences' )
717
717
def " findFullInfoById() should return info about series" () {
718
718
given :
719
- Integer expectedSeriesId = 20
719
+ Integer expectedSeriesId = Random . id()
720
720
String expectedLang = ' kz'
721
721
SeriesFullInfoDto expectedInfo = TestObjects . createSeriesFullInfoDto()
722
722
List<String > expectedMichelNumbers = [ ' 1' , ' 2' ]
@@ -1087,7 +1087,7 @@ class SeriesServiceImplTest extends Specification {
1087
1087
1088
1088
def " findByCollectionId() should pass arguments to dao" () {
1089
1089
given :
1090
- Integer expectedCollectionId = 16
1090
+ Integer expectedCollectionId = Random . id()
1091
1091
and :
1092
1092
String expectedLang = ' expected'
1093
1093
when :
@@ -1152,7 +1152,7 @@ class SeriesServiceImplTest extends Specification {
1152
1152
1153
1153
def " findPurchasesAndSales() should invoke dao, pass argument and return result from dao" () {
1154
1154
given :
1155
- Integer expectedSeriesId = 88
1155
+ Integer expectedSeriesId = Random . id()
1156
1156
and :
1157
1157
List<PurchaseAndSaleDto > expectedResult = [ TestObjects . createPurchaseAndSaleDto() ]
1158
1158
when :
0 commit comments