Skip to content

Commit 2519677

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

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
@@ -780,6 +780,37 @@ class SeriesServiceImplTest extends Specification {
780780
result == expectedResult
781781
}
782782

783+
//
784+
// Tests for findSeriesIdByYvertNumber()
785+
//
786+
787+
@Unroll
788+
def "findSeriesIdByYvertNumber() should throw exception for invalid argument '#yvertNumberCode'"(String yvertNumberCode) {
789+
when:
790+
service.findSeriesIdByYvertNumber(yvertNumberCode)
791+
then:
792+
thrown IllegalArgumentException
793+
where:
794+
yvertNumberCode | _
795+
null | _
796+
'' | _
797+
' ' | _
798+
}
799+
800+
def "findSeriesIdByYvertNumber() should pass argument to dao and return result"() {
801+
given:
802+
Optional<Integer> expectedResult = Optional.of(1);
803+
when:
804+
Optional<Integer> result = service.findSeriesIdByYvertNumber('5');
805+
then:
806+
1 * jdbcSeriesDao.findSeriesIdByYvertNumberCode({ String code ->
807+
assert code == '5'
808+
return true
809+
}) >> expectedResult
810+
and:
811+
result == expectedResult
812+
}
813+
783814
//
784815
// Tests for findByCategoryId()
785816
//

0 commit comments

Comments
 (0)