Skip to content

Commit c6aec5b

Browse files
committed
SeriesService.findBy(Country): renamed to findByCountryId() to replace usage of Country entity.
Addressed to #120 No functional changes.
1 parent 6f8f655 commit c6aec5b

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public String showInfo(
103103
model.addAttribute("country", country);
104104

105105
String lang = LocaleUtils.getLanguageOrNull(userLocale);
106-
model.addAttribute("seriesOfCountry", seriesService.findBy(country, lang));
106+
Integer countryId = country.getId();
107+
model.addAttribute("seriesOfCountry", seriesService.findByCountryId(countryId, lang));
107108

108109
return "country/info";
109110
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import java.util.Optional;
2121

22-
import ru.mystamps.web.entity.Country;
2322
import ru.mystamps.web.entity.Series;
2423
import ru.mystamps.web.entity.User;
2524
import ru.mystamps.web.service.dto.AddImageDto;
@@ -48,7 +47,7 @@ public interface SeriesService {
4847
Optional<Integer> findSeriesIdByGibbonsNumber(String gibbonsNumberCode);
4948

5049
Iterable<SeriesInfoDto> findByCategoryId(Integer categoryId, String lang);
51-
Iterable<SeriesInfoDto> findBy(Country country, String lang);
50+
Iterable<SeriesInfoDto> findByCountryId(Integer countryId, String lang);
5251
Iterable<SeriesInfoDto> findByCollectionId(Integer collectionId, String lang);
5352
Iterable<SeriesInfoDto> findRecentlyAdded(int quantity, String lang);
5453
Iterable<SitemapInfoDto> findAllForSitemap();

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
import ru.mystamps.web.dao.JdbcSeriesDao;
3636
import ru.mystamps.web.dao.SeriesDao;
37-
import ru.mystamps.web.entity.Country;
3837
import ru.mystamps.web.entity.Currency;
3938
import ru.mystamps.web.entity.GibbonsCatalog;
4039
import ru.mystamps.web.entity.Image;
@@ -261,10 +260,10 @@ public Iterable<SeriesInfoDto> findByCategoryId(Integer categoryId, String lang)
261260

262261
@Override
263262
@Transactional(readOnly = true)
264-
public Iterable<SeriesInfoDto> findBy(Country country, String lang) {
265-
Validate.isTrue(country != null, "Country must be non null");
263+
public Iterable<SeriesInfoDto> findByCountryId(Integer countryId, String lang) {
264+
Validate.isTrue(countryId != null, "Country id must be non null");
266265

267-
return jdbcSeriesDao.findByCountryIdAsSeriesInfo(country.getId(), lang);
266+
return jdbcSeriesDao.findByCountryIdAsSeriesInfo(countryId, lang);
268267
}
269268

270269
@Override

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,25 +743,25 @@ class SeriesServiceImplTest extends Specification {
743743
}
744744

745745
//
746-
// Tests for findBy(Country)
746+
// Tests for findByCountryId()
747747
//
748748

749-
def "findBy(Country) should throw exception if country is null"() {
749+
def "findByCountryId() should throw exception if country id is null"() {
750750
when:
751-
service.findBy(null as Country, 'any')
751+
service.findByCountryId(null, 'any')
752752
then:
753753
thrown IllegalArgumentException
754754
}
755755

756-
def "findBy(Country) should call dao and return result"() {
756+
def "findByCountryId() should call dao and return result"() {
757757
given:
758758
Country expectedCountry = TestObjects.createCountry()
759759
and:
760760
Iterable<Country> expectedResult = [ expectedCountry ]
761761
and:
762762
jdbcSeriesDao.findByCountryIdAsSeriesInfo(_ as Integer, _ as String) >> expectedResult
763763
when:
764-
Iterable<Country> result = service.findBy(expectedCountry, 'any')
764+
Iterable<Country> result = service.findByCountryId(20, 'any')
765765
then:
766766
result == expectedResult
767767
}

0 commit comments

Comments
 (0)