File tree 4 files changed +8
-22
lines changed
main/java/ru/mystamps/web
test/groovy/ru/mystamps/web/service
4 files changed +8
-22
lines changed Original file line number Diff line number Diff line change @@ -70,9 +70,9 @@ public String showInfo(
70
70
model .addAttribute ("seriesOfCollection" , seriesOfCollection );
71
71
72
72
if (seriesOfCollection .iterator ().hasNext ()) {
73
- // CheckStyle: ignore LineLength for next 1 line
73
+ // CheckStyle: ignore LineLength for next 2 line
74
74
model .addAttribute ("categoryCounter" , categoryService .countCategoriesOf (collection .getId ()));
75
- model .addAttribute ("countryCounter" , countryService .countCountriesOf (collection ));
75
+ model .addAttribute ("countryCounter" , countryService .countCountriesOf (collection . getId () ));
76
76
model .addAttribute ("seriesCounter" , seriesService .countSeriesOf (collectionId ));
77
77
model .addAttribute ("stampsCounter" , seriesService .countStampsOf (collectionId ));
78
78
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ public interface CountryService {
31
31
Iterable <SelectEntityDto > findAllAsSelectEntities (String lang );
32
32
Iterable <LinkEntityDto > findAllAsLinkEntities (String lang );
33
33
long countAll ();
34
- long countCountriesOf (Collection collection );
34
+ long countCountriesOf (Integer collectionId );
35
35
long countByName (String name );
36
36
long countByNameRu (String name );
37
37
Map <String , Integer > getStatisticsOf (Collection collection , String lang );
Original file line number Diff line number Diff line change @@ -101,11 +101,10 @@ public long countAll() {
101
101
102
102
@ Override
103
103
@ 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" );
107
106
108
- return countryDao .countCountriesOfCollection (collection . getId () );
107
+ return countryDao .countCountriesOfCollection (collectionId );
109
108
}
110
109
111
110
@ Override
Original file line number Diff line number Diff line change @@ -278,31 +278,18 @@ class CountryServiceImplTest extends Specification {
278
278
// Tests for countCountriesOf()
279
279
//
280
280
281
- def " countCountriesOf() should throw exception when collection is null" () {
282
- when :
283
- service. countCountriesOf(null )
284
- then :
285
- thrown IllegalArgumentException
286
- }
287
-
288
281
def " countCountriesOf() should throw exception when collection id is null" () {
289
- given :
290
- Collection collection = Mock ()
291
- collection. getId() >> null
292
282
when :
293
- service. countCountriesOf(collection )
283
+ service. countCountriesOf(null )
294
284
then :
295
285
thrown IllegalArgumentException
296
286
}
297
287
298
288
def " countCountriesOf() should pass arguments to dao" () {
299
289
given :
300
290
Integer expectedCollectionId = 9
301
- and :
302
- Collection expectedCollection = Mock ()
303
- expectedCollection. getId() >> expectedCollectionId
304
291
when :
305
- service. countCountriesOf(expectedCollection )
292
+ service. countCountriesOf(expectedCollectionId )
306
293
then :
307
294
1 * countryDao. countCountriesOfCollection({ Integer collectionId ->
308
295
assert expectedCollectionId == collectionId
You can’t perform that action at this time.
0 commit comments