Skip to content

Commit df6c261

Browse files
committed
CategoryServiceImpl: rename a member.
No functional changes.
1 parent a167169 commit df6c261

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

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

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

48-
private final JdbcCategoryDao jdbcCategoryDao;
48+
private final JdbcCategoryDao categoryDao;
4949

5050
@Override
5151
@Transactional
@@ -74,7 +74,7 @@ public UrlEntityDto add(AddCategoryDto dto, User user) {
7474
category.setCreatedBy(user.getId());
7575
category.setUpdatedBy(user.getId());
7676

77-
Integer id = jdbcCategoryDao.add(category);
77+
Integer id = categoryDao.add(category);
7878
LOG.info("Category #{} has been created ({})", id, category);
7979

8080
return new UrlEntityDto(id, slug);
@@ -83,19 +83,19 @@ public UrlEntityDto add(AddCategoryDto dto, User user) {
8383
@Override
8484
@Transactional(readOnly = true)
8585
public Iterable<SelectEntityDto> findAllAsSelectEntities(String lang) {
86-
return jdbcCategoryDao.findAllAsSelectEntities(lang);
86+
return categoryDao.findAllAsSelectEntities(lang);
8787
}
8888

8989
@Override
9090
@Transactional(readOnly = true)
9191
public Iterable<LinkEntityDto> findAllAsLinkEntities(String lang) {
92-
return jdbcCategoryDao.findAllAsLinkEntities(lang);
92+
return categoryDao.findAllAsLinkEntities(lang);
9393
}
9494

9595
@Override
9696
@Transactional(readOnly = true)
9797
public long countAll() {
98-
return jdbcCategoryDao.countAll();
98+
return categoryDao.countAll();
9999
}
100100

101101
@Override
@@ -104,21 +104,21 @@ public long countCategoriesOf(Collection collection) {
104104
Validate.isTrue(collection != null, "Collection must be non null");
105105
Validate.isTrue(collection.getId() != null, "Collection id must be non null");
106106

107-
return jdbcCategoryDao.countCategoriesOfCollection(collection.getId());
107+
return categoryDao.countCategoriesOfCollection(collection.getId());
108108
}
109109

110110
@Override
111111
@Transactional(readOnly = true)
112112
public long countByName(String name) {
113113
Validate.isTrue(name != null, "Name should be non null");
114-
return jdbcCategoryDao.countByName(name);
114+
return categoryDao.countByName(name);
115115
}
116116

117117
@Override
118118
@Transactional(readOnly = true)
119119
public long countByNameRu(String name) {
120120
Validate.isTrue(name != null, "Name on Russian should be non null");
121-
return jdbcCategoryDao.countByNameRu(name);
121+
return categoryDao.countByNameRu(name);
122122
}
123123

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

130-
return jdbcCategoryDao.getStatisticsOf(collection.getId(), lang);
130+
return categoryDao.getStatisticsOf(collection.getId(), lang);
131131
}
132132

133133
}

src/test/groovy/ru/mystamps/web/service/CategoryServiceImplTest.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.JdbcCategoryDao
2424
import ru.mystamps.web.dao.dto.AddCategoryDbDto
25-
import ru.mystamps.web.entity.Category
2625
import ru.mystamps.web.entity.Collection
2726
import ru.mystamps.web.entity.User
2827
import ru.mystamps.web.model.AddCategoryForm
@@ -37,8 +36,8 @@ class CategoryServiceImplTest extends Specification {
3736
private AddCategoryForm form
3837
private User user
3938

40-
private JdbcCategoryDao jdbcCategoryDao = Mock()
41-
private CategoryService service = new CategoryServiceImpl(jdbcCategoryDao)
39+
private JdbcCategoryDao categoryDao = Mock()
40+
private CategoryService service = new CategoryServiceImpl(categoryDao)
4241

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

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

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

0 commit comments

Comments
 (0)