@@ -133,21 +133,15 @@ class CollectionServiceImplTest extends Specification {
133
133
when :
134
134
service. addToCollection(expectedUserId, expectedSeriesId)
135
135
then :
136
- 1 * collectionDao. addSeriesToUserCollection({ Integer userId ->
137
- assert userId == expectedUserId
138
- return true
139
- }, { Integer seriesId ->
140
- assert seriesId == expectedSeriesId
141
- return true
142
- })
136
+ 1 * collectionDao. addSeriesToUserCollection(expectedUserId, expectedSeriesId)
143
137
and :
144
- 1 * collectionDao. markAsModified({ Integer userId ->
145
- assert userId == expectedUserId
146
- return true
147
- }, { Date updatedAt ->
148
- assert DateUtils . roughlyEqual(updatedAt, new Date ())
149
- return true
150
- } )
138
+ 1 * collectionDao. markAsModified(
139
+ expectedUserId,
140
+ { Date updatedAt ->
141
+ assert DateUtils . roughlyEqual(updatedAt, new Date ())
142
+ return true
143
+ }
144
+ )
151
145
}
152
146
153
147
//
@@ -176,21 +170,15 @@ class CollectionServiceImplTest extends Specification {
176
170
when :
177
171
service. removeFromCollection(expectedUserId, expectedSeriesId)
178
172
then :
179
- 1 * collectionDao. removeSeriesFromUserCollection({ Integer userId ->
180
- assert userId == expectedUserId
181
- return true
182
- }, { Integer seriesId ->
183
- assert seriesId == expectedSeriesId
184
- return true
185
- })
173
+ 1 * collectionDao. removeSeriesFromUserCollection(expectedUserId, expectedSeriesId)
186
174
and :
187
- 1 * collectionDao. markAsModified({ Integer userId ->
188
- assert userId == expectedUserId
189
- return true
190
- }, { Date updatedAt ->
191
- assert DateUtils . roughlyEqual(updatedAt, new Date ())
192
- return true
193
- } )
175
+ 1 * collectionDao. markAsModified(
176
+ expectedUserId,
177
+ { Date updatedAt ->
178
+ assert DateUtils . roughlyEqual(updatedAt, new Date ())
179
+ return true
180
+ }
181
+ )
194
182
}
195
183
196
184
//
@@ -215,7 +203,6 @@ class CollectionServiceImplTest extends Specification {
215
203
0 * collectionDao. isSeriesInUserCollection(_ as Integer , _ as Integer )
216
204
}
217
205
218
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
219
206
def ' isSeriesInCollection() should pass arguments to dao' () {
220
207
given :
221
208
Integer expectedUserId = Random . userId()
@@ -226,13 +213,7 @@ class CollectionServiceImplTest extends Specification {
226
213
when :
227
214
boolean serviceResult = service. isSeriesInCollection(expectedUserId, expectedSeriesId)
228
215
then :
229
- 1 * collectionDao. isSeriesInUserCollection({ Integer userId ->
230
- assert userId == expectedUserId
231
- return true
232
- }, { Integer seriesId ->
233
- assert seriesId == expectedSeriesId
234
- return true
235
- }) >> expectedResult
216
+ 1 * collectionDao. isSeriesInUserCollection(expectedUserId, expectedSeriesId) >> expectedResult
236
217
and :
237
218
serviceResult == expectedResult
238
219
}
@@ -263,18 +244,14 @@ class CollectionServiceImplTest extends Specification {
263
244
thrown IllegalArgumentException
264
245
}
265
246
266
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
267
247
def ' countUpdatedSince() should invoke dao, pass argument and return result from dao' () {
268
248
given :
269
249
Date expectedDate = new Date ()
270
250
long expectedResult = 47
271
251
when :
272
252
long result = service. countUpdatedSince(expectedDate)
273
253
then :
274
- 1 * collectionDao. countUpdatedSince({ Date date ->
275
- assert date == expectedDate
276
- return true
277
- }) >> expectedResult
254
+ 1 * collectionDao. countUpdatedSince(expectedDate) >> expectedResult
278
255
and :
279
256
result == expectedResult
280
257
}
@@ -295,17 +272,13 @@ class CollectionServiceImplTest extends Specification {
295
272
0 | _
296
273
}
297
274
298
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
299
275
def ' findRecentlyCreated() should pass arguments to dao' () {
300
276
given :
301
277
int expectedQuantity = 4
302
278
when :
303
279
service. findRecentlyCreated(expectedQuantity)
304
280
then :
305
- 1 * collectionDao. findLastCreated({ int quantity ->
306
- assert expectedQuantity == quantity
307
- return true
308
- }) >> []
281
+ 1 * collectionDao. findLastCreated(expectedQuantity) >> []
309
282
}
310
283
311
284
//
@@ -319,7 +292,6 @@ class CollectionServiceImplTest extends Specification {
319
292
thrown IllegalArgumentException
320
293
}
321
294
322
- @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
323
295
def ' findBySlug() should invoke dao, pass argument and return result from dao' () {
324
296
given :
325
297
String expectedSlug = ' cuba'
@@ -328,10 +300,7 @@ class CollectionServiceImplTest extends Specification {
328
300
when :
329
301
CollectionInfoDto result = service. findBySlug(expectedSlug)
330
302
then :
331
- 1 * collectionDao. findCollectionInfoBySlug({ String slug ->
332
- assert slug == expectedSlug
333
- return true
334
- }) >> expectedResult
303
+ 1 * collectionDao. findCollectionInfoBySlug(expectedSlug) >> expectedResult
335
304
and :
336
305
result == expectedResult
337
306
}
0 commit comments