@@ -87,7 +87,8 @@ class SeriesServiceImplTest extends Specification {
87
87
when :
88
88
service. add(null , Random . userId(), bool())
89
89
then :
90
- thrown IllegalArgumentException
90
+ IllegalArgumentException ex = thrown()
91
+ ex. message == ' DTO must be non null'
91
92
}
92
93
93
94
def " add() should throw exception if quantity is null" () {
@@ -96,7 +97,8 @@ class SeriesServiceImplTest extends Specification {
96
97
when :
97
98
service. add(form, Random . userId(), bool())
98
99
then :
99
- thrown IllegalArgumentException
100
+ IllegalArgumentException ex = thrown()
101
+ ex. message == ' Quantity must be non null'
100
102
}
101
103
102
104
def " add() should throw exception if perforated is null" () {
@@ -105,7 +107,8 @@ class SeriesServiceImplTest extends Specification {
105
107
when :
106
108
service. add(form, Random . userId(), bool())
107
109
then :
108
- thrown IllegalArgumentException
110
+ IllegalArgumentException ex = thrown()
111
+ ex. message == ' Perforated property must be non null'
109
112
}
110
113
111
114
def " add() should throw exception if category is null" () {
@@ -114,7 +117,8 @@ class SeriesServiceImplTest extends Specification {
114
117
when :
115
118
service. add(form, Random . userId(), bool())
116
119
then :
117
- thrown IllegalArgumentException
120
+ IllegalArgumentException ex = thrown()
121
+ ex. message == ' Category must be non null'
118
122
}
119
123
120
124
def " add() should throw exception if category id is null" () {
@@ -123,14 +127,16 @@ class SeriesServiceImplTest extends Specification {
123
127
when :
124
128
service. add(form, Random . userId(), bool())
125
129
then :
126
- thrown IllegalArgumentException
130
+ IllegalArgumentException ex = thrown()
131
+ ex. message == ' Category id must be non null'
127
132
}
128
133
129
134
def " add() should throw exception when user is null" () {
130
135
when :
131
136
service. add(form, null , bool())
132
137
then :
133
- thrown IllegalArgumentException
138
+ IllegalArgumentException ex = thrown()
139
+ ex. message == ' User id must be non null'
134
140
}
135
141
136
142
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
@@ -257,7 +263,8 @@ class SeriesServiceImplTest extends Specification {
257
263
when :
258
264
service. add(form, Random . userId(), true )
259
265
then :
260
- thrown IllegalArgumentException
266
+ IllegalArgumentException ex = thrown()
267
+ ex. message == ' Comment must be non empty'
261
268
}
262
269
263
270
@Unroll
@@ -445,15 +452,16 @@ class SeriesServiceImplTest extends Specification {
445
452
and :
446
453
seriesDao. add(_ as AddSeriesDbDto ) >> Random . id()
447
454
and :
448
- imageService. addToSeries(_ as Integer , _ as Integer ) >> { throw new IllegalStateException () }
455
+ imageService. addToSeries(_ as Integer , _ as Integer ) >> { throw new IllegalStateException (' oops ' ) }
449
456
when :
450
457
service. add(form, Random . userId(), bool())
451
458
then :
452
459
imageService. save(_) >> expectedImageInfo
453
460
and :
454
461
1 * imageService. removeIfPossible(expectedImageInfo)
455
462
and :
456
- thrown IllegalStateException
463
+ IllegalStateException ex = thrown()
464
+ ex. message == ' oops'
457
465
}
458
466
459
467
//
@@ -464,21 +472,24 @@ class SeriesServiceImplTest extends Specification {
464
472
when :
465
473
service. addImageToSeries(null , Random . id(), Random . userId())
466
474
then :
467
- thrown IllegalArgumentException
475
+ IllegalArgumentException ex = thrown()
476
+ ex. message == ' DTO must be non null'
468
477
}
469
478
470
479
def " addImageToSeries() should throw exception when series id is null" () {
471
480
when :
472
481
service. addImageToSeries(imageForm, null , Random . userId())
473
482
then :
474
- thrown IllegalArgumentException
483
+ IllegalArgumentException ex = thrown()
484
+ ex. message == ' Series id must be non null'
475
485
}
476
486
477
487
def " addImageToSeries() should throw exception when user id is null" () {
478
488
when :
479
489
service. addImageToSeries(imageForm, Random . id(), null )
480
490
then :
481
- thrown IllegalArgumentException
491
+ IllegalArgumentException ex = thrown()
492
+ ex. message == ' User id must be non null'
482
493
}
483
494
484
495
@SuppressWarnings (' UnnecessaryReturnKeyword' )
@@ -525,15 +536,16 @@ class SeriesServiceImplTest extends Specification {
525
536
given :
526
537
ImageInfoDto expectedImageInfo = TestObjects . createImageInfoDto()
527
538
and :
528
- imageService. addToSeries(_ as Integer , _ as Integer ) >> { throw new IllegalStateException () }
539
+ imageService. addToSeries(_ as Integer , _ as Integer ) >> { throw new IllegalStateException (' oops ' ) }
529
540
when :
530
541
service. addImageToSeries(imageForm, Random . id(), Random . userId())
531
542
then :
532
543
imageService. save(_) >> expectedImageInfo
533
544
and :
534
545
1 * imageService. removeIfPossible(expectedImageInfo)
535
546
and :
536
- thrown IllegalStateException
547
+ IllegalStateException ex = thrown()
548
+ ex. message == ' oops'
537
549
}
538
550
539
551
//
@@ -574,7 +586,8 @@ class SeriesServiceImplTest extends Specification {
574
586
when :
575
587
service. countAddedSince(null )
576
588
then :
577
- thrown IllegalArgumentException
589
+ IllegalArgumentException ex = thrown()
590
+ ex. message == ' Date must be non null'
578
591
}
579
592
580
593
def " countAddedSince() should invoke dao, pass argument and return result from dao" () {
@@ -598,7 +611,8 @@ class SeriesServiceImplTest extends Specification {
598
611
when :
599
612
service. countUpdatedSince(null )
600
613
then :
601
- thrown IllegalArgumentException
614
+ IllegalArgumentException ex = thrown()
615
+ ex. message == ' Date must be non null'
602
616
}
603
617
604
618
def " countUpdatedSince() should invoke dao, pass argument and return result from dao" () {
@@ -622,7 +636,8 @@ class SeriesServiceImplTest extends Specification {
622
636
when :
623
637
service. isSeriesExist(null )
624
638
then :
625
- thrown IllegalArgumentException
639
+ IllegalArgumentException ex = thrown()
640
+ ex. message == ' Series id must be non null'
626
641
}
627
642
628
643
@Unroll
@@ -650,7 +665,8 @@ class SeriesServiceImplTest extends Specification {
650
665
when :
651
666
service. findQuantityById(null )
652
667
then :
653
- thrown IllegalArgumentException
668
+ IllegalArgumentException ex = thrown()
669
+ ex. message == ' Series id must be non null'
654
670
}
655
671
656
672
def ' findQuantityById() should invoke dao, pass argument and return result from dao' () {
@@ -1009,7 +1025,8 @@ class SeriesServiceImplTest extends Specification {
1009
1025
when :
1010
1026
service. findByCategorySlug(null , Random . lang())
1011
1027
then :
1012
- thrown IllegalArgumentException
1028
+ IllegalArgumentException ex = thrown()
1029
+ ex. message == ' Category slug must be non null'
1013
1030
}
1014
1031
1015
1032
def " findByCategorySlug() should call dao and return result" () {
@@ -1033,7 +1050,8 @@ class SeriesServiceImplTest extends Specification {
1033
1050
when :
1034
1051
service. findByCountrySlug(null , Random . lang())
1035
1052
then :
1036
- thrown IllegalArgumentException
1053
+ IllegalArgumentException ex = thrown()
1054
+ ex. message == ' Country slug must be non null'
1037
1055
}
1038
1056
1039
1057
def " findByCountrySlug() should call dao and return result" () {
@@ -1058,7 +1076,8 @@ class SeriesServiceImplTest extends Specification {
1058
1076
when :
1059
1077
service. findRecentlyAdded(quantity, null )
1060
1078
then :
1061
- thrown IllegalArgumentException
1079
+ IllegalArgumentException ex = thrown()
1080
+ ex. message == ' Quantity of recently added series must be greater than 0'
1062
1081
where :
1063
1082
quantity | _
1064
1083
-1 | _
@@ -1100,7 +1119,8 @@ class SeriesServiceImplTest extends Specification {
1100
1119
when :
1101
1120
service. findPurchasesAndSales(null )
1102
1121
then :
1103
- thrown IllegalArgumentException
1122
+ IllegalArgumentException ex = thrown()
1123
+ ex. message == ' Series id must be non null'
1104
1124
}
1105
1125
1106
1126
def " findPurchasesAndSales() should invoke dao, pass argument and return result from dao" () {
0 commit comments