@@ -22,7 +22,6 @@ import spock.lang.Unroll
22
22
23
23
import ru.mystamps.web.dao.JdbcCountryDao
24
24
import ru.mystamps.web.dao.dto.AddCountryDbDto
25
- import ru.mystamps.web.entity.Country
26
25
import ru.mystamps.web.entity.Collection
27
26
import ru.mystamps.web.entity.User
28
27
import ru.mystamps.web.model.AddCountryForm
@@ -37,8 +36,8 @@ class CountryServiceImplTest extends Specification {
37
36
private AddCountryForm form
38
37
private User user
39
38
40
- private JdbcCountryDao jdbcCountryDao = Mock ()
41
- private CountryService service = new CountryServiceImpl (jdbcCountryDao )
39
+ private JdbcCountryDao countryDao = Mock ()
40
+ private CountryService service = new CountryServiceImpl (countryDao )
42
41
43
42
def setup () {
44
43
form = new AddCountryForm ()
@@ -92,7 +91,7 @@ class CountryServiceImplTest extends Specification {
92
91
and :
93
92
String expectedSlug = ' example-country'
94
93
and :
95
- jdbcCountryDao . add(_ as AddCountryDbDto ) >> expectedId
94
+ countryDao . add(_ as AddCountryDbDto ) >> expectedId
96
95
and :
97
96
UrlEntityDto expected = new UrlEntityDto (expectedId, expectedSlug)
98
97
when :
@@ -108,7 +107,7 @@ class CountryServiceImplTest extends Specification {
108
107
when :
109
108
service. add(form, user)
110
109
then :
111
- 1 * jdbcCountryDao . add({ AddCountryDbDto country ->
110
+ 1 * countryDao . add({ AddCountryDbDto country ->
112
111
assert country?. name == expectedCountryName
113
112
return true
114
113
}) >> 20
@@ -121,7 +120,7 @@ class CountryServiceImplTest extends Specification {
121
120
when :
122
121
service. add(form, user)
123
122
then :
124
- 1 * jdbcCountryDao . add({ AddCountryDbDto country ->
123
+ 1 * countryDao . add({ AddCountryDbDto country ->
125
124
assert country?. nameRu == expectedCountryName
126
125
return true
127
126
}) >> 30
@@ -146,7 +145,7 @@ class CountryServiceImplTest extends Specification {
146
145
when :
147
146
service. add(form, user)
148
147
then :
149
- 1 * jdbcCountryDao . add({ AddCountryDbDto country ->
148
+ 1 * countryDao . add({ AddCountryDbDto country ->
150
149
assert country?. slug == slug
151
150
return true
152
151
}) >> 40
@@ -156,7 +155,7 @@ class CountryServiceImplTest extends Specification {
156
155
when :
157
156
service. add(form, user)
158
157
then :
159
- 1 * jdbcCountryDao . add({ AddCountryDbDto country ->
158
+ 1 * countryDao . add({ AddCountryDbDto country ->
160
159
assert DateUtils . roughlyEqual(country?. createdAt, new Date ())
161
160
return true
162
161
}) >> 50
@@ -166,7 +165,7 @@ class CountryServiceImplTest extends Specification {
166
165
when :
167
166
service. add(form, user)
168
167
then :
169
- 1 * jdbcCountryDao . add({ AddCountryDbDto country ->
168
+ 1 * countryDao . add({ AddCountryDbDto country ->
170
169
assert DateUtils . roughlyEqual(country?. updatedAt, new Date ())
171
170
return true
172
171
}) >> 60
@@ -176,7 +175,7 @@ class CountryServiceImplTest extends Specification {
176
175
when :
177
176
service. add(form, user)
178
177
then :
179
- 1 * jdbcCountryDao . add({ AddCountryDbDto country ->
178
+ 1 * countryDao . add({ AddCountryDbDto country ->
180
179
assert country?. createdBy == user. id
181
180
return true
182
181
}) >> 70
@@ -186,7 +185,7 @@ class CountryServiceImplTest extends Specification {
186
185
when :
187
186
service. add(form, user)
188
187
then :
189
- 1 * jdbcCountryDao . add({ AddCountryDbDto country ->
188
+ 1 * countryDao . add({ AddCountryDbDto country ->
190
189
assert country?. updatedBy == user. id
191
190
return true
192
191
}) >> 80
@@ -204,7 +203,7 @@ class CountryServiceImplTest extends Specification {
204
203
and :
205
204
List<SelectEntityDto > expectedCountries = [ country1, country2 ]
206
205
and :
207
- jdbcCountryDao . findAllAsSelectEntities(_ as String ) >> expectedCountries
206
+ countryDao . findAllAsSelectEntities(_ as String ) >> expectedCountries
208
207
when :
209
208
Iterable<SelectEntityDto > resultCountries = service. findAllAsSelectEntities(' de' )
210
209
then :
@@ -216,7 +215,7 @@ class CountryServiceImplTest extends Specification {
216
215
when :
217
216
service. findAllAsSelectEntities(expectedLanguage)
218
217
then :
219
- 1 * jdbcCountryDao . findAllAsSelectEntities({ String language ->
218
+ 1 * countryDao . findAllAsSelectEntities({ String language ->
220
219
assert language == expectedLanguage
221
220
return true
222
221
})
@@ -238,7 +237,7 @@ class CountryServiceImplTest extends Specification {
238
237
and :
239
238
List<LinkEntityDto > expectedCountries = [ country1, country2 ]
240
239
and :
241
- jdbcCountryDao . findAllAsLinkEntities(_ as String ) >> expectedCountries
240
+ countryDao . findAllAsLinkEntities(_ as String ) >> expectedCountries
242
241
when :
243
242
Iterable<LinkEntityDto > resultCountries = service. findAllAsLinkEntities(' de' )
244
243
then :
@@ -250,7 +249,7 @@ class CountryServiceImplTest extends Specification {
250
249
when :
251
250
service. findAllAsLinkEntities(expectedLanguage)
252
251
then :
253
- 1 * jdbcCountryDao . findAllAsLinkEntities({ String language ->
252
+ 1 * countryDao . findAllAsLinkEntities({ String language ->
254
253
assert language == expectedLanguage
255
254
return true
256
255
})
@@ -270,7 +269,7 @@ class CountryServiceImplTest extends Specification {
270
269
when :
271
270
long result = service. countAll()
272
271
then :
273
- 1 * jdbcCountryDao . countAll() >> expectedResult
272
+ 1 * countryDao . countAll() >> expectedResult
274
273
and :
275
274
result == expectedResult
276
275
}
@@ -305,7 +304,7 @@ class CountryServiceImplTest extends Specification {
305
304
when :
306
305
service. countCountriesOf(expectedCollection)
307
306
then :
308
- 1 * jdbcCountryDao . countCountriesOfCollection({ Integer collectionId ->
307
+ 1 * countryDao . countCountriesOfCollection({ Integer collectionId ->
309
308
assert expectedCollectionId == collectionId
310
309
return true
311
310
}) >> 0L
@@ -324,7 +323,7 @@ class CountryServiceImplTest extends Specification {
324
323
325
324
def " countByName() should call dao" () {
326
325
given :
327
- jdbcCountryDao . countByName(_ as String ) >> 2L
326
+ countryDao . countByName(_ as String ) >> 2L
328
327
when :
329
328
long result = service. countByName(' Any name here' )
330
329
then :
@@ -335,7 +334,7 @@ class CountryServiceImplTest extends Specification {
335
334
when :
336
335
service. countByName(' Canada' )
337
336
then :
338
- 1 * jdbcCountryDao . countByName({ String name ->
337
+ 1 * countryDao . countByName({ String name ->
339
338
assert name == ' Canada'
340
339
return true
341
340
})
@@ -354,7 +353,7 @@ class CountryServiceImplTest extends Specification {
354
353
355
354
def " countByNameRu() should call dao" () {
356
355
given :
357
- jdbcCountryDao . countByNameRu(_ as String ) >> 2L
356
+ countryDao . countByNameRu(_ as String ) >> 2L
358
357
when :
359
358
long result = service. countByNameRu(' Any name here' )
360
359
then :
@@ -365,7 +364,7 @@ class CountryServiceImplTest extends Specification {
365
364
when :
366
365
service. countByNameRu(' Канада' )
367
366
then :
368
- 1 * jdbcCountryDao . countByNameRu({ String name ->
367
+ 1 * countryDao . countByNameRu({ String name ->
369
368
assert name == ' Канада'
370
369
return true
371
370
})
@@ -403,7 +402,7 @@ class CountryServiceImplTest extends Specification {
403
402
when :
404
403
service. getStatisticsOf(expectedCollection, expectedLang)
405
404
then :
406
- 1 * jdbcCountryDao . getStatisticsOf(
405
+ 1 * countryDao . getStatisticsOf(
407
406
{ Integer collectionId ->
408
407
assert expectedCollectionId == collectionId
409
408
return true
0 commit comments