@@ -27,13 +27,14 @@ import ru.mystamps.web.dao.dto.LinkEntityDto
27
27
import ru.mystamps.web.tests.DateUtils
28
28
import ru.mystamps.web.util.SlugUtils
29
29
30
+ @SuppressWarnings ([' ClassJavadoc' , ' MethodName' , ' NoDef' , ' NoTabCharacter' , ' TrailingWhitespace' ])
30
31
class CategoryServiceImplTest extends Specification {
31
32
32
- private AddCategoryForm form
33
- private Integer userId = 123
33
+ private final Integer userId = 123
34
+ private final CategoryDao categoryDao = Mock ()
35
+ private final CategoryService service = new CategoryServiceImpl (categoryDao)
34
36
35
- private CategoryDao categoryDao = Mock ()
36
- private CategoryService service = new CategoryServiceImpl (categoryDao)
37
+ private AddCategoryForm form
37
38
38
39
def setup () {
39
40
form = new AddCategoryForm ()
@@ -92,6 +93,7 @@ class CategoryServiceImplTest extends Specification {
92
93
actualSlug == expectedSlug
93
94
}
94
95
96
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
95
97
def " add() should pass English category name to dao" () {
96
98
given :
97
99
String expectedCategoryName = ' Animals'
@@ -105,6 +107,7 @@ class CategoryServiceImplTest extends Specification {
105
107
}) >> 20
106
108
}
107
109
110
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
108
111
def " add() should pass Russian category name to dao" () {
109
112
given :
110
113
String expectedCategoryName = ' Животные'
@@ -127,9 +130,10 @@ class CategoryServiceImplTest extends Specification {
127
130
thrown IllegalArgumentException
128
131
}
129
132
133
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
130
134
def " add() should pass slug to dao" () {
131
135
given :
132
- String name = " -foo123 test_"
136
+ String name = ' -foo123 test_'
133
137
and :
134
138
String slug = SlugUtils . slugify(name)
135
139
and :
@@ -143,6 +147,7 @@ class CategoryServiceImplTest extends Specification {
143
147
}) >> 40
144
148
}
145
149
150
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
146
151
def " add() should assign created at to current date" () {
147
152
when :
148
153
service. add(form, userId)
@@ -153,6 +158,7 @@ class CategoryServiceImplTest extends Specification {
153
158
}) >> 50
154
159
}
155
160
161
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
156
162
def " add() should assign updated at to current date" () {
157
163
when :
158
164
service. add(form, userId)
@@ -163,6 +169,7 @@ class CategoryServiceImplTest extends Specification {
163
169
}) >> 60
164
170
}
165
171
172
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
166
173
def " add() should assign created by to user" () {
167
174
given :
168
175
Integer expectedUserId = 10
@@ -175,6 +182,7 @@ class CategoryServiceImplTest extends Specification {
175
182
}) >> 70
176
183
}
177
184
185
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
178
186
def " add() should assign updated by to user" () {
179
187
given :
180
188
Integer expectedUserId = 20
@@ -207,6 +215,7 @@ class CategoryServiceImplTest extends Specification {
207
215
}
208
216
209
217
@Unroll
218
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
210
219
def " findAllAsLinkEntities(String) should pass language '#expectedLanguage' to dao" (String expectedLanguage) {
211
220
when :
212
221
service. findAllAsLinkEntities(expectedLanguage)
@@ -238,6 +247,7 @@ class CategoryServiceImplTest extends Specification {
238
247
null | _
239
248
}
240
249
250
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
241
251
def " findOneAsLinkEntity() should pass arguments to dao" () {
242
252
given :
243
253
String expectedSlug = ' people'
@@ -288,6 +298,7 @@ class CategoryServiceImplTest extends Specification {
288
298
thrown IllegalArgumentException
289
299
}
290
300
301
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
291
302
def " countCategoriesOf() should pass arguments to dao" () {
292
303
given :
293
304
Integer expectedCollectionId = 10
@@ -320,6 +331,7 @@ class CategoryServiceImplTest extends Specification {
320
331
result == 2L
321
332
}
322
333
334
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
323
335
def " countByName() should pass category name to dao in lowercase" () {
324
336
when :
325
337
service. countByName(' Sport' )
@@ -350,6 +362,7 @@ class CategoryServiceImplTest extends Specification {
350
362
result == 2L
351
363
}
352
364
365
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
353
366
def " countByNameRu() should pass category name to dao in lowercase" () {
354
367
when :
355
368
service. countByNameRu(' Спорт' )
@@ -371,6 +384,7 @@ class CategoryServiceImplTest extends Specification {
371
384
thrown IllegalArgumentException
372
385
}
373
386
387
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
374
388
def " countAddedSince() should invoke dao, pass argument and return result from dao" () {
375
389
given :
376
390
Date expectedDate = new Date ()
@@ -398,6 +412,7 @@ class CategoryServiceImplTest extends Specification {
398
412
thrown IllegalArgumentException
399
413
}
400
414
415
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
401
416
def " getStatisticsOf() should pass arguments to dao" () {
402
417
given :
403
418
Integer expectedCollectionId = 15
0 commit comments