File tree 4 files changed +11
-12
lines changed
main/java/ru/mystamps/web
test/groovy/ru/mystamps/web/service 4 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,8 @@ public String showInfo(
103
103
model .addAttribute ("category" , category );
104
104
105
105
String lang = LocaleUtils .getLanguageOrNull (userLocale );
106
- model .addAttribute ("seriesOfCategory" , seriesService .findBy (category , lang ));
106
+ Integer categoryId = category .getId ();
107
+ model .addAttribute ("seriesOfCategory" , seriesService .findByCategoryId (categoryId , lang ));
107
108
108
109
return "category/info" ;
109
110
}
Original file line number Diff line number Diff line change 19
19
20
20
import java .util .Optional ;
21
21
22
- import ru .mystamps .web .entity .Category ;
23
22
import ru .mystamps .web .entity .Collection ;
24
23
import ru .mystamps .web .entity .Country ;
25
24
import ru .mystamps .web .entity .Series ;
@@ -49,7 +48,7 @@ public interface SeriesService {
49
48
Optional <Integer > findSeriesIdByYvertNumber (String yvertNumberCode );
50
49
Optional <Integer > findSeriesIdByGibbonsNumber (String gibbonsNumberCode );
51
50
52
- Iterable <SeriesInfoDto > findBy ( Category category , String lang );
51
+ Iterable <SeriesInfoDto > findByCategoryId ( Integer categoryId , String lang );
53
52
Iterable <SeriesInfoDto > findBy (Country country , String lang );
54
53
Iterable <SeriesInfoDto > findBy (Collection collection , String lang );
55
54
Iterable <SeriesInfoDto > findRecentlyAdded (int quantity , String lang );
Original file line number Diff line number Diff line change 34
34
35
35
import ru .mystamps .web .dao .JdbcSeriesDao ;
36
36
import ru .mystamps .web .dao .SeriesDao ;
37
- import ru .mystamps .web .entity .Category ;
38
37
import ru .mystamps .web .entity .Country ;
39
38
import ru .mystamps .web .entity .Collection ;
40
39
import ru .mystamps .web .entity .Currency ;
@@ -255,10 +254,10 @@ public Optional<Integer> findSeriesIdByGibbonsNumber(String gibbonsNumberCode) {
255
254
256
255
@ Override
257
256
@ Transactional (readOnly = true )
258
- public Iterable <SeriesInfoDto > findBy ( Category category , String lang ) {
259
- Validate .isTrue (category != null , "Category must be non null" );
257
+ public Iterable <SeriesInfoDto > findByCategoryId ( Integer categoryId , String lang ) {
258
+ Validate .isTrue (categoryId != null , "Category id must be non null" );
260
259
261
- return jdbcSeriesDao .findByCategoryIdAsSeriesInfo (category . getId () , lang );
260
+ return jdbcSeriesDao .findByCategoryIdAsSeriesInfo (categoryId , lang );
262
261
}
263
262
264
263
@ Override
Original file line number Diff line number Diff line change @@ -720,25 +720,25 @@ class SeriesServiceImplTest extends Specification {
720
720
}
721
721
722
722
//
723
- // Tests for findBy(Category )
723
+ // Tests for findByCategoryId( )
724
724
//
725
725
726
- def " findBy(Category ) should throw exception if category is null" () {
726
+ def " findByCategoryId( ) should throw exception if category id is null" () {
727
727
when :
728
- service. findBy (null as Category , ' any' )
728
+ service. findByCategoryId (null , ' any' )
729
729
then :
730
730
thrown IllegalArgumentException
731
731
}
732
732
733
- def " findBy(Category ) should call dao and return result" () {
733
+ def " findByCategoryId( ) should call dao and return result" () {
734
734
given :
735
735
Category expectedCategory = TestObjects . createCategory()
736
736
and :
737
737
Iterable<Category > expectedResult = [ expectedCategory ]
738
738
and :
739
739
jdbcSeriesDao. findByCategoryIdAsSeriesInfo(_ as Integer , _ as String ) >> expectedResult
740
740
when :
741
- Iterable<Category > result = service. findBy(expectedCategory , ' any' )
741
+ Iterable<Category > result = service. findByCategoryId( 10 , ' any' )
742
742
then :
743
743
result == expectedResult
744
744
}
You can’t perform that action at this time.
0 commit comments