Skip to content

Commit 1090577

Browse files
committed
SeriesServiceImpl.findSeriesIdByMichelNumber(): add unit tests.
1 parent 2a9b6a7 commit 1090577

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
@@ -718,6 +718,37 @@ class SeriesServiceImplTest extends Specification {
718718
result == expectedResult
719719
}
720720

721+
//
722+
// Tests for findSeriesIdByMichelNumber()
723+
//
724+
725+
@Unroll
726+
def "findSeriesIdByMichelNumber() should throw exception for invalid argument '#michelNumberCode'"(String michelNumberCode) {
727+
when:
728+
service.findSeriesIdByMichelNumber(michelNumberCode)
729+
then:
730+
thrown IllegalArgumentException
731+
where:
732+
michelNumberCode | _
733+
null | _
734+
'' | _
735+
' ' | _
736+
}
737+
738+
def "findSeriesIdByMichelNumber() should pass argument to dao and return result"() {
739+
given:
740+
Optional<Integer> expectedResult = Optional.of(1);
741+
when:
742+
Optional<Integer> result = service.findSeriesIdByMichelNumber('5');
743+
then:
744+
1 * jdbcSeriesDao.findSeriesIdByMichelNumberCode({ String code ->
745+
assert code == '5'
746+
return true
747+
}) >> expectedResult
748+
and:
749+
result == expectedResult
750+
}
751+
721752
//
722753
// Tests for findByCategoryId()
723754
//

0 commit comments

Comments
 (0)