Skip to content

Commit 60584ba

Browse files
committed
SeriesServiceImpl.findBy(Collection): add unit tests.
Fix #36
1 parent ce39769 commit 60584ba

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,4 +864,48 @@ class SeriesServiceImplTest extends Specification {
864864
result == expectedResult
865865
}
866866

867+
//
868+
// Tests for findBy(Collection)
869+
//
870+
871+
def "findBy(Collection) should throw exception when collection is null"() {
872+
when:
873+
service.findBy(null as Collection, 'whatever')
874+
then:
875+
thrown IllegalArgumentException
876+
}
877+
878+
def "findBy(Collection) should throw exception when collection id is null"() {
879+
given:
880+
Collection collection = Mock()
881+
collection.getId() >> null
882+
when:
883+
service.findBy(collection, 'whatever')
884+
then:
885+
thrown IllegalArgumentException
886+
}
887+
888+
def "findBy(Collection) should pass arguments to dao"() {
889+
given:
890+
Integer expectedCollectionId = 16
891+
and:
892+
String expectedLang = 'expected'
893+
and:
894+
Collection expectedCollection = Mock()
895+
expectedCollection.getId() >> expectedCollectionId
896+
when:
897+
service.findBy(expectedCollection, expectedLang)
898+
then:
899+
1 * seriesDao.findByAsSeriesInfo(
900+
{ Integer collectionId ->
901+
assert expectedCollectionId == collectionId
902+
return true
903+
},
904+
{ String lang ->
905+
assert expectedLang == lang
906+
return true
907+
}
908+
) >> []
909+
}
910+
867911
}

0 commit comments

Comments
 (0)