Skip to content

Commit 5a47fc8

Browse files
committed
SeriesServiceImpl.findSeriesIdByScottNumber(): add unit tests.
1 parent 1090577 commit 5a47fc8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,37 @@ class SeriesServiceImplTest extends Specification {
749749
result == expectedResult
750750
}
751751

752+
//
753+
// Tests for findSeriesIdByScottNumber()
754+
//
755+
756+
@Unroll
757+
def "findSeriesIdByScottNumber() should throw exception for invalid argument '#scottNumberCode'"(String scottNumberCode) {
758+
when:
759+
service.findSeriesIdByScottNumber(scottNumberCode)
760+
then:
761+
thrown IllegalArgumentException
762+
where:
763+
scottNumberCode | _
764+
null | _
765+
'' | _
766+
' ' | _
767+
}
768+
769+
def "findSeriesIdByScottNumber() should pass argument to dao and return result"() {
770+
given:
771+
Optional<Integer> expectedResult = Optional.of(1);
772+
when:
773+
Optional<Integer> result = service.findSeriesIdByScottNumber('5');
774+
then:
775+
1 * jdbcSeriesDao.findSeriesIdByScottNumberCode({ String code ->
776+
assert code == '5'
777+
return true
778+
}) >> expectedResult
779+
and:
780+
result == expectedResult
781+
}
782+
752783
//
753784
// Tests for findByCategoryId()
754785
//

0 commit comments

Comments
 (0)