Skip to content

Commit 2e9e7c3

Browse files
committed
DatabaseImagePersistenceStrategy.savePreview(): add unit test.
Fix #575
1 parent e9b8a26 commit 2e9e7c3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,27 @@ class DatabaseImagePersistenceStrategyTest extends Specification {
6969
})
7070
}
7171

72+
//
73+
// Tests for savePreview()
74+
//
75+
76+
@SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword'])
77+
def "savePreview() should pass dto to image data dao"() {
78+
given:
79+
Integer expectedImageId = imageInfoDto.id
80+
and:
81+
byte[] expectedContent = 'test'.bytes
82+
when:
83+
strategy.savePreview(expectedContent, imageInfoDto)
84+
then:
85+
1 * imageDataDao.add({ AddImageDataDbDto imageData ->
86+
assert imageData?.imageId == expectedImageId
87+
assert imageData?.content == expectedContent
88+
assert imageData?.preview == true
89+
return true
90+
})
91+
}
92+
7293
//
7394
// Tests for get()
7495
//

0 commit comments

Comments
 (0)