Skip to content

Commit 80509b3

Browse files
committed
CountryService.countCountriesOfCollection(): change argument from Collection to Integer.
Addressed to #120 No functional changes.
1 parent e7397b0 commit 80509b3

File tree

4 files changed

+8
-22
lines changed

4 files changed

+8
-22
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ public String showInfo(
7070
model.addAttribute("seriesOfCollection", seriesOfCollection);
7171

7272
if (seriesOfCollection.iterator().hasNext()) {
73-
// CheckStyle: ignore LineLength for next 1 line
73+
// CheckStyle: ignore LineLength for next 2 line
7474
model.addAttribute("categoryCounter", categoryService.countCategoriesOf(collection.getId()));
75-
model.addAttribute("countryCounter", countryService.countCountriesOf(collection));
75+
model.addAttribute("countryCounter", countryService.countCountriesOf(collection.getId()));
7676
model.addAttribute("seriesCounter", seriesService.countSeriesOf(collectionId));
7777
model.addAttribute("stampsCounter", seriesService.countStampsOf(collectionId));
7878

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public interface CountryService {
3131
Iterable<SelectEntityDto> findAllAsSelectEntities(String lang);
3232
Iterable<LinkEntityDto> findAllAsLinkEntities(String lang);
3333
long countAll();
34-
long countCountriesOf(Collection collection);
34+
long countCountriesOf(Integer collectionId);
3535
long countByName(String name);
3636
long countByNameRu(String name);
3737
Map<String, Integer> getStatisticsOf(Collection collection, String lang);

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,10 @@ public long countAll() {
101101

102102
@Override
103103
@Transactional(readOnly = true)
104-
public long countCountriesOf(Collection collection) {
105-
Validate.isTrue(collection != null, "Collection must be non null");
106-
Validate.isTrue(collection.getId() != null, "Collection id must be non null");
104+
public long countCountriesOf(Integer collectionId) {
105+
Validate.isTrue(collectionId != null, "Collection id must be non null");
107106

108-
return countryDao.countCountriesOfCollection(collection.getId());
107+
return countryDao.countCountriesOfCollection(collectionId);
109108
}
110109

111110
@Override

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

+2-15
Original file line numberDiff line numberDiff line change
@@ -278,31 +278,18 @@ class CountryServiceImplTest extends Specification {
278278
// Tests for countCountriesOf()
279279
//
280280

281-
def "countCountriesOf() should throw exception when collection is null"() {
282-
when:
283-
service.countCountriesOf(null)
284-
then:
285-
thrown IllegalArgumentException
286-
}
287-
288281
def "countCountriesOf() should throw exception when collection id is null"() {
289-
given:
290-
Collection collection = Mock()
291-
collection.getId() >> null
292282
when:
293-
service.countCountriesOf(collection)
283+
service.countCountriesOf(null)
294284
then:
295285
thrown IllegalArgumentException
296286
}
297287

298288
def "countCountriesOf() should pass arguments to dao"() {
299289
given:
300290
Integer expectedCollectionId = 9
301-
and:
302-
Collection expectedCollection = Mock()
303-
expectedCollection.getId() >> expectedCollectionId
304291
when:
305-
service.countCountriesOf(expectedCollection)
292+
service.countCountriesOf(expectedCollectionId)
306293
then:
307294
1 * countryDao.countCountriesOfCollection({ Integer collectionId ->
308295
assert expectedCollectionId == collectionId

0 commit comments

Comments
 (0)