Skip to content

Commit 39269f5

Browse files
committed
SeriesService.countStampsOf(): change argument from Collection to Integer.
Addressed to #120 No functional changes.
1 parent 2c0fda1 commit 39269f5

File tree

4 files changed

+7
-21
lines changed

4 files changed

+7
-21
lines changed

src/main/java/ru/mystamps/web/controller/CollectionController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public String showInfo(
7272
model.addAttribute("categoryCounter", categoryService.countCategoriesOf(collection));
7373
model.addAttribute("countryCounter", countryService.countCountriesOf(collection));
7474
model.addAttribute("seriesCounter", seriesService.countSeriesOf(collectionId));
75-
model.addAttribute("stampsCounter", seriesService.countStampsOf(collection));
75+
model.addAttribute("stampsCounter", seriesService.countStampsOf(collectionId));
7676

7777
model.addAttribute(
7878
"statOfCollectionByCategories",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public interface SeriesService {
3737
long countAll();
3838
long countAllStamps();
3939
long countSeriesOf(Integer collectionId);
40-
long countStampsOf(Collection collection);
40+
long countStampsOf(Integer collectionId);
4141

4242
long countByMichelNumber(String michelNumberCode);
4343
long countByScottNumber(String scottNumberCode);

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,10 @@ public long countSeriesOf(Integer collectionId) {
169169

170170
@Override
171171
@Transactional(readOnly = true)
172-
public long countStampsOf(Collection collection) {
173-
Validate.isTrue(collection != null, "Collection must be non null");
174-
Validate.isTrue(collection.getId() != null, "Collection id must be non null");
172+
public long countStampsOf(Integer collectionId) {
173+
Validate.isTrue(collectionId != null, "Collection id must be non null");
175174

176-
return jdbcSeriesDao.countStampsOfCollection(collection.getId());
175+
return jdbcSeriesDao.countStampsOfCollection(collectionId);
177176
}
178177

179178
@Override

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -576,31 +576,18 @@ class SeriesServiceImplTest extends Specification {
576576
// Tests for countStampsOf()
577577
//
578578

579-
def "countStampsOf() should throw exception when collection is null"() {
579+
def "countStampsOf() should throw exception when argument is null"() {
580580
when:
581581
service.countStampsOf(null)
582582
then:
583583
thrown IllegalArgumentException
584584
}
585585

586-
def "countStampsOf() should throw exception when collection id is null"() {
587-
given:
588-
Collection collection = Mock()
589-
collection.getId() >> null
590-
when:
591-
service.countStampsOf(collection)
592-
then:
593-
thrown IllegalArgumentException
594-
}
595-
596586
def "countStampsOf() should pass arguments to dao"() {
597587
given:
598588
Integer expectedCollectionId = 8
599-
and:
600-
Collection expectedCollection = Mock()
601-
expectedCollection.getId() >> expectedCollectionId
602589
when:
603-
service.countStampsOf(expectedCollection)
590+
service.countStampsOf(expectedCollectionId)
604591
then:
605592
1 * jdbcSeriesDao.countStampsOfCollection({ Integer collectionId ->
606593
assert expectedCollectionId == collectionId

0 commit comments

Comments
 (0)