Skip to content

Commit 14e11e3

Browse files
committedAug 29, 2017
DatabaseImagePersistenceStrategy.getPreview(): add unit tests.
Fix #576 No functional changes.
1 parent 707a25a commit 14e11e3

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
 

‎src/test/groovy/ru/mystamps/web/service/DatabaseImagePersistenceStrategyTest.groovy

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,36 @@ class DatabaseImagePersistenceStrategyTest extends Specification {
127127
result == expectedImageDto
128128
}
129129

130+
//
131+
// Tests for getPreview()
132+
//
133+
134+
def 'getPreview() should return null when image data dao returned null'() {
135+
given:
136+
imageDataDao.findByImageId(_ as Integer, _ as Boolean) >> null
137+
when:
138+
ImageDto result = strategy.getPreview(imageInfoDto)
139+
then:
140+
result == null
141+
}
142+
143+
def 'getPreview() should return result of image data dao'() {
144+
given:
145+
Integer expectedImageId = imageInfoDto.id
146+
and:
147+
ImageDto expectedImageDto = TestObjects.createDbImageDto()
148+
when:
149+
ImageDto result = strategy.getPreview(imageInfoDto)
150+
then:
151+
1 * imageDataDao.findByImageId({ Integer imageId ->
152+
assert imageId == expectedImageId
153+
return true
154+
}, { Boolean preview ->
155+
assert preview == true
156+
return true
157+
}) >> expectedImageDto
158+
and:
159+
result == expectedImageDto
160+
}
161+
130162
}

0 commit comments

Comments
 (0)