Skip to content

Commit fc74709

Browse files
committed
SeriesServiceImpl.findSeriesIdByGibbonsNumber(): add unit tests.
1 parent 2519677 commit fc74709

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
@@ -811,6 +811,37 @@ class SeriesServiceImplTest extends Specification {
811811
result == expectedResult
812812
}
813813

814+
//
815+
// Tests for findSeriesIdByGibbonsNumber()
816+
//
817+
818+
@Unroll
819+
def "findSeriesIdByGibbonsNumber() should throw exception for invalid argument '#gibbonsNumberCode'"(String gibbonsNumberCode) {
820+
when:
821+
service.findSeriesIdByGibbonsNumber(gibbonsNumberCode)
822+
then:
823+
thrown IllegalArgumentException
824+
where:
825+
gibbonsNumberCode | _
826+
null | _
827+
'' | _
828+
' ' | _
829+
}
830+
831+
def "findSeriesIdByGibbonsNumber() should pass argument to dao and return result"() {
832+
given:
833+
Optional<Integer> expectedResult = Optional.of(1);
834+
when:
835+
Optional<Integer> result = service.findSeriesIdByGibbonsNumber('5');
836+
then:
837+
1 * jdbcSeriesDao.findSeriesIdByGibbonsNumberCode({ String code ->
838+
assert code == '5'
839+
return true
840+
}) >> expectedResult
841+
and:
842+
result == expectedResult
843+
}
844+
814845
//
815846
// Tests for findByCategoryId()
816847
//

0 commit comments

Comments
 (0)