@@ -55,23 +55,26 @@ class CollectionServiceImplTest extends Specification {
55
55
when :
56
56
service. createCollection(null , ' test-owner-login' )
57
57
then :
58
- thrown IllegalArgumentException
58
+ IllegalArgumentException ex = thrown()
59
+ ex. message == ' Owner id must be non null'
59
60
}
60
61
61
62
@SuppressWarnings (' FactoryMethodName' )
62
63
def ' createCollection() should throw exception when owner login is null' () {
63
64
when :
64
65
service. createCollection(Random . userId(), null )
65
66
then :
66
- thrown IllegalArgumentException
67
+ IllegalArgumentException ex = thrown()
68
+ ex. message == ' Owner login must be non null'
67
69
}
68
70
69
71
@SuppressWarnings (' FactoryMethodName' )
70
72
def ' createCollection() should throw exception when owner login can\' t be converted to slug' () {
71
73
when :
72
74
service. createCollection(Random . userId(), ' ' )
73
75
then :
74
- thrown IllegalArgumentException
76
+ IllegalArgumentException ex = thrown()
77
+ ex. message == ' Slug for string \'\' must be non empty'
75
78
}
76
79
77
80
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' FactoryMethodName' , ' UnnecessaryReturnKeyword' ])
@@ -121,14 +124,16 @@ class CollectionServiceImplTest extends Specification {
121
124
when :
122
125
service. addToCollection(null , TestObjects . createAddToCollectionDto())
123
126
then :
124
- thrown IllegalArgumentException
127
+ IllegalArgumentException ex = thrown()
128
+ ex. message == ' User id must be non null'
125
129
}
126
130
127
131
def ' addToCollection() should throw exception when dto is null' () {
128
132
when :
129
133
service. addToCollection(Random . userId(), null )
130
134
then :
131
- thrown IllegalArgumentException
135
+ IllegalArgumentException ex = thrown()
136
+ ex. message == ' DTO must be non null'
132
137
}
133
138
134
139
def ' addToCollection() should throw exception when number of stamps is null' () {
@@ -138,7 +143,8 @@ class CollectionServiceImplTest extends Specification {
138
143
when :
139
144
service. addToCollection(Random . userId(), form)
140
145
then :
141
- thrown IllegalArgumentException
146
+ IllegalArgumentException ex = thrown()
147
+ ex. message == ' Number of stamps must be non null'
142
148
}
143
149
144
150
def ' addToCollection() should throw exception when series id is null' () {
@@ -148,7 +154,8 @@ class CollectionServiceImplTest extends Specification {
148
154
when :
149
155
service. addToCollection(Random . userId(), form)
150
156
then :
151
- thrown IllegalArgumentException
157
+ IllegalArgumentException ex = thrown()
158
+ ex. message == ' Series id must be non null'
152
159
}
153
160
154
161
def ' addToCollection() should throw exception when price is specified without currency' () {
@@ -159,7 +166,8 @@ class CollectionServiceImplTest extends Specification {
159
166
when :
160
167
service. addToCollection(Random . userId(), form)
161
168
then :
162
- thrown IllegalStateException
169
+ IllegalStateException ex = thrown()
170
+ ex. message == ' Currency must be non null when price is specified'
163
171
}
164
172
165
173
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
@@ -204,14 +212,16 @@ class CollectionServiceImplTest extends Specification {
204
212
when :
205
213
service. removeFromCollection(null , Random . id())
206
214
then :
207
- thrown IllegalArgumentException
215
+ IllegalArgumentException ex = thrown()
216
+ ex. message == ' User id must be non null'
208
217
}
209
218
210
219
def ' removeFromCollection() should throw exception when series id is null' () {
211
220
when :
212
221
service. removeFromCollection(Random . userId(), null )
213
222
then :
214
- thrown IllegalArgumentException
223
+ IllegalArgumentException ex = thrown()
224
+ ex. message == ' Series id must be non null'
215
225
}
216
226
217
227
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
@@ -241,7 +251,8 @@ class CollectionServiceImplTest extends Specification {
241
251
when :
242
252
service. isSeriesInCollection(Random . userId(), null )
243
253
then :
244
- thrown IllegalArgumentException
254
+ IllegalArgumentException ex = thrown()
255
+ ex. message == ' Series id must be non null'
245
256
}
246
257
247
258
def ' isSeriesInCollection() should return false for anonymous' () {
@@ -293,7 +304,8 @@ class CollectionServiceImplTest extends Specification {
293
304
when :
294
305
service. countUpdatedSince(null )
295
306
then :
296
- thrown IllegalArgumentException
307
+ IllegalArgumentException ex = thrown()
308
+ ex. message == ' Date must be non null'
297
309
}
298
310
299
311
def ' countUpdatedSince() should invoke dao, pass argument and return result from dao' () {
@@ -316,7 +328,8 @@ class CollectionServiceImplTest extends Specification {
316
328
when :
317
329
service. countStampsOf(null )
318
330
then :
319
- thrown IllegalArgumentException
331
+ IllegalArgumentException ex = thrown()
332
+ ex. message == ' Collection id must be non null'
320
333
}
321
334
322
335
def ' countStampsOf() should pass arguments to dao' () {
@@ -337,7 +350,8 @@ class CollectionServiceImplTest extends Specification {
337
350
when :
338
351
service. findRecentlyCreated(quantity)
339
352
then :
340
- thrown IllegalArgumentException
353
+ IllegalArgumentException ex = thrown()
354
+ ex. message == ' Quantity must be greater than 0'
341
355
where :
342
356
quantity | _
343
357
-1 | _
@@ -361,7 +375,8 @@ class CollectionServiceImplTest extends Specification {
361
375
when :
362
376
service. findSeriesInCollection(null , Random . lang())
363
377
then :
364
- thrown IllegalArgumentException
378
+ IllegalArgumentException ex = thrown()
379
+ ex. message == ' Collection id must be non null'
365
380
}
366
381
367
382
def ' findSeriesInCollection() should pass arguments to dao' () {
@@ -383,7 +398,8 @@ class CollectionServiceImplTest extends Specification {
383
398
when :
384
399
service. findBySlug(null )
385
400
then :
386
- thrown IllegalArgumentException
401
+ IllegalArgumentException ex = thrown()
402
+ ex. message == ' Collection slug must be non null'
387
403
}
388
404
389
405
def ' findBySlug() should invoke dao, pass argument and return result from dao' () {
0 commit comments