Skip to content

Commit 22e533c

Browse files
committed
CountryServiceImpl: rename a member.
No functional changes.
1 parent df6c261 commit 22e533c

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

src/main/java/ru/mystamps/web/service/CountryServiceImpl.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
public class CountryServiceImpl implements CountryService {
4646
private static final Logger LOG = LoggerFactory.getLogger(CountryServiceImpl.class);
4747

48-
private final JdbcCountryDao jdbcCountryDao;
48+
private final JdbcCountryDao countryDao;
4949

5050
@Override
5151
@Transactional
@@ -74,7 +74,7 @@ public UrlEntityDto add(AddCountryDto dto, User user) {
7474
country.setUpdatedAt(now);
7575
country.setUpdatedBy(user.getId());
7676

77-
Integer id = jdbcCountryDao.add(country);
77+
Integer id = countryDao.add(country);
7878

7979
LOG.info("Country #{} has been created ({})", id, country);
8080

@@ -84,19 +84,19 @@ public UrlEntityDto add(AddCountryDto dto, User user) {
8484
@Override
8585
@Transactional(readOnly = true)
8686
public Iterable<SelectEntityDto> findAllAsSelectEntities(String lang) {
87-
return jdbcCountryDao.findAllAsSelectEntities(lang);
87+
return countryDao.findAllAsSelectEntities(lang);
8888
}
8989

9090
@Override
9191
@Transactional(readOnly = true)
9292
public Iterable<LinkEntityDto> findAllAsLinkEntities(String lang) {
93-
return jdbcCountryDao.findAllAsLinkEntities(lang);
93+
return countryDao.findAllAsLinkEntities(lang);
9494
}
9595

9696
@Override
9797
@Transactional(readOnly = true)
9898
public long countAll() {
99-
return jdbcCountryDao.countAll();
99+
return countryDao.countAll();
100100
}
101101

102102
@Override
@@ -105,21 +105,21 @@ public long countCountriesOf(Collection collection) {
105105
Validate.isTrue(collection != null, "Collection must be non null");
106106
Validate.isTrue(collection.getId() != null, "Collection id must be non null");
107107

108-
return jdbcCountryDao.countCountriesOfCollection(collection.getId());
108+
return countryDao.countCountriesOfCollection(collection.getId());
109109
}
110110

111111
@Override
112112
@Transactional(readOnly = true)
113113
public long countByName(String name) {
114114
Validate.isTrue(name != null, "Name should be non null");
115-
return jdbcCountryDao.countByName(name);
115+
return countryDao.countByName(name);
116116
}
117117

118118
@Override
119119
@Transactional(readOnly = true)
120120
public long countByNameRu(String name) {
121121
Validate.isTrue(name != null, "Name on Russian should be non null");
122-
return jdbcCountryDao.countByNameRu(name);
122+
return countryDao.countByNameRu(name);
123123
}
124124

125125
@Override
@@ -128,7 +128,7 @@ public Map<String, Integer> getStatisticsOf(Collection collection, String lang)
128128
Validate.isTrue(collection != null, "Collection must be non null");
129129
Validate.isTrue(collection.getId() != null, "Collection id must be non null");
130130

131-
return jdbcCountryDao.getStatisticsOf(collection.getId(), lang);
131+
return countryDao.getStatisticsOf(collection.getId(), lang);
132132
}
133133

134134
}

src/test/groovy/ru/mystamps/web/service/CountryServiceImplTest.groovy

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import spock.lang.Unroll
2222

2323
import ru.mystamps.web.dao.JdbcCountryDao
2424
import ru.mystamps.web.dao.dto.AddCountryDbDto
25-
import ru.mystamps.web.entity.Country
2625
import ru.mystamps.web.entity.Collection
2726
import ru.mystamps.web.entity.User
2827
import ru.mystamps.web.model.AddCountryForm
@@ -37,8 +36,8 @@ class CountryServiceImplTest extends Specification {
3736
private AddCountryForm form
3837
private User user
3938

40-
private JdbcCountryDao jdbcCountryDao = Mock()
41-
private CountryService service = new CountryServiceImpl(jdbcCountryDao)
39+
private JdbcCountryDao countryDao = Mock()
40+
private CountryService service = new CountryServiceImpl(countryDao)
4241

4342
def setup() {
4443
form = new AddCountryForm()
@@ -92,7 +91,7 @@ class CountryServiceImplTest extends Specification {
9291
and:
9392
String expectedSlug = 'example-country'
9493
and:
95-
jdbcCountryDao.add(_ as AddCountryDbDto) >> expectedId
94+
countryDao.add(_ as AddCountryDbDto) >> expectedId
9695
and:
9796
UrlEntityDto expected = new UrlEntityDto(expectedId, expectedSlug)
9897
when:
@@ -108,7 +107,7 @@ class CountryServiceImplTest extends Specification {
108107
when:
109108
service.add(form, user)
110109
then:
111-
1 * jdbcCountryDao.add({ AddCountryDbDto country ->
110+
1 * countryDao.add({ AddCountryDbDto country ->
112111
assert country?.name == expectedCountryName
113112
return true
114113
}) >> 20
@@ -121,7 +120,7 @@ class CountryServiceImplTest extends Specification {
121120
when:
122121
service.add(form, user)
123122
then:
124-
1 * jdbcCountryDao.add({ AddCountryDbDto country ->
123+
1 * countryDao.add({ AddCountryDbDto country ->
125124
assert country?.nameRu == expectedCountryName
126125
return true
127126
}) >> 30
@@ -146,7 +145,7 @@ class CountryServiceImplTest extends Specification {
146145
when:
147146
service.add(form, user)
148147
then:
149-
1 * jdbcCountryDao.add({ AddCountryDbDto country ->
148+
1 * countryDao.add({ AddCountryDbDto country ->
150149
assert country?.slug == slug
151150
return true
152151
}) >> 40
@@ -156,7 +155,7 @@ class CountryServiceImplTest extends Specification {
156155
when:
157156
service.add(form, user)
158157
then:
159-
1 * jdbcCountryDao.add({ AddCountryDbDto country ->
158+
1 * countryDao.add({ AddCountryDbDto country ->
160159
assert DateUtils.roughlyEqual(country?.createdAt, new Date())
161160
return true
162161
}) >> 50
@@ -166,7 +165,7 @@ class CountryServiceImplTest extends Specification {
166165
when:
167166
service.add(form, user)
168167
then:
169-
1 * jdbcCountryDao.add({ AddCountryDbDto country ->
168+
1 * countryDao.add({ AddCountryDbDto country ->
170169
assert DateUtils.roughlyEqual(country?.updatedAt, new Date())
171170
return true
172171
}) >> 60
@@ -176,7 +175,7 @@ class CountryServiceImplTest extends Specification {
176175
when:
177176
service.add(form, user)
178177
then:
179-
1 * jdbcCountryDao.add({ AddCountryDbDto country ->
178+
1 * countryDao.add({ AddCountryDbDto country ->
180179
assert country?.createdBy == user.id
181180
return true
182181
}) >> 70
@@ -186,7 +185,7 @@ class CountryServiceImplTest extends Specification {
186185
when:
187186
service.add(form, user)
188187
then:
189-
1 * jdbcCountryDao.add({ AddCountryDbDto country ->
188+
1 * countryDao.add({ AddCountryDbDto country ->
190189
assert country?.updatedBy == user.id
191190
return true
192191
}) >> 80
@@ -204,7 +203,7 @@ class CountryServiceImplTest extends Specification {
204203
and:
205204
List<SelectEntityDto> expectedCountries = [ country1, country2 ]
206205
and:
207-
jdbcCountryDao.findAllAsSelectEntities(_ as String) >> expectedCountries
206+
countryDao.findAllAsSelectEntities(_ as String) >> expectedCountries
208207
when:
209208
Iterable<SelectEntityDto> resultCountries = service.findAllAsSelectEntities('de')
210209
then:
@@ -216,7 +215,7 @@ class CountryServiceImplTest extends Specification {
216215
when:
217216
service.findAllAsSelectEntities(expectedLanguage)
218217
then:
219-
1 * jdbcCountryDao.findAllAsSelectEntities({ String language ->
218+
1 * countryDao.findAllAsSelectEntities({ String language ->
220219
assert language == expectedLanguage
221220
return true
222221
})
@@ -238,7 +237,7 @@ class CountryServiceImplTest extends Specification {
238237
and:
239238
List<LinkEntityDto> expectedCountries = [ country1, country2 ]
240239
and:
241-
jdbcCountryDao.findAllAsLinkEntities(_ as String) >> expectedCountries
240+
countryDao.findAllAsLinkEntities(_ as String) >> expectedCountries
242241
when:
243242
Iterable<LinkEntityDto> resultCountries = service.findAllAsLinkEntities('de')
244243
then:
@@ -250,7 +249,7 @@ class CountryServiceImplTest extends Specification {
250249
when:
251250
service.findAllAsLinkEntities(expectedLanguage)
252251
then:
253-
1 * jdbcCountryDao.findAllAsLinkEntities({ String language ->
252+
1 * countryDao.findAllAsLinkEntities({ String language ->
254253
assert language == expectedLanguage
255254
return true
256255
})
@@ -270,7 +269,7 @@ class CountryServiceImplTest extends Specification {
270269
when:
271270
long result = service.countAll()
272271
then:
273-
1 * jdbcCountryDao.countAll() >> expectedResult
272+
1 * countryDao.countAll() >> expectedResult
274273
and:
275274
result == expectedResult
276275
}
@@ -305,7 +304,7 @@ class CountryServiceImplTest extends Specification {
305304
when:
306305
service.countCountriesOf(expectedCollection)
307306
then:
308-
1 * jdbcCountryDao.countCountriesOfCollection({ Integer collectionId ->
307+
1 * countryDao.countCountriesOfCollection({ Integer collectionId ->
309308
assert expectedCollectionId == collectionId
310309
return true
311310
}) >> 0L
@@ -324,7 +323,7 @@ class CountryServiceImplTest extends Specification {
324323

325324
def "countByName() should call dao"() {
326325
given:
327-
jdbcCountryDao.countByName(_ as String) >> 2L
326+
countryDao.countByName(_ as String) >> 2L
328327
when:
329328
long result = service.countByName('Any name here')
330329
then:
@@ -335,7 +334,7 @@ class CountryServiceImplTest extends Specification {
335334
when:
336335
service.countByName('Canada')
337336
then:
338-
1 * jdbcCountryDao.countByName({ String name ->
337+
1 * countryDao.countByName({ String name ->
339338
assert name == 'Canada'
340339
return true
341340
})
@@ -354,7 +353,7 @@ class CountryServiceImplTest extends Specification {
354353

355354
def "countByNameRu() should call dao"() {
356355
given:
357-
jdbcCountryDao.countByNameRu(_ as String) >> 2L
356+
countryDao.countByNameRu(_ as String) >> 2L
358357
when:
359358
long result = service.countByNameRu('Any name here')
360359
then:
@@ -365,7 +364,7 @@ class CountryServiceImplTest extends Specification {
365364
when:
366365
service.countByNameRu('Канада')
367366
then:
368-
1 * jdbcCountryDao.countByNameRu({ String name ->
367+
1 * countryDao.countByNameRu({ String name ->
369368
assert name == 'Канада'
370369
return true
371370
})
@@ -403,7 +402,7 @@ class CountryServiceImplTest extends Specification {
403402
when:
404403
service.getStatisticsOf(expectedCollection, expectedLang)
405404
then:
406-
1 * jdbcCountryDao.getStatisticsOf(
405+
1 * countryDao.getStatisticsOf(
407406
{ Integer collectionId ->
408407
assert expectedCollectionId == collectionId
409408
return true

0 commit comments

Comments
 (0)