Skip to content

Commit ce39769

Browse files
committed
SeriesServiceImpl.countStampsOf(): add unit tests.
Fix #55
1 parent 1b02799 commit ce39769

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,42 @@ class SeriesServiceImplTest extends Specification {
656656
}) >> 0L
657657
}
658658

659+
//
660+
// Tests for countStampsOf()
661+
//
662+
663+
def "countStampsOf() should throw exception when collection is null"() {
664+
when:
665+
service.countStampsOf(null)
666+
then:
667+
thrown IllegalArgumentException
668+
}
669+
670+
def "countStampsOf() should throw exception when collection id is null"() {
671+
given:
672+
Collection collection = Mock()
673+
collection.getId() >> null
674+
when:
675+
service.countStampsOf(collection)
676+
then:
677+
thrown IllegalArgumentException
678+
}
679+
680+
def "countStampsOf() should pass arguments to dao"() {
681+
given:
682+
Integer expectedCollectionId = 8
683+
and:
684+
Collection expectedCollection = Mock()
685+
expectedCollection.getId() >> expectedCollectionId
686+
when:
687+
service.countStampsOf(expectedCollection)
688+
then:
689+
1 * jdbcSeriesDao.countStampsOfCollection({ Integer collectionId ->
690+
assert expectedCollectionId == collectionId
691+
return true
692+
}) >> 0L
693+
}
694+
659695
//
660696
// Tests for countByMichelNumber()
661697
//

0 commit comments

Comments
 (0)