Skip to content

Commit c153909

Browse files
committed
DatabaseImagePersistenceStrategyTest: simplify code by replacing closures with expected values.
No functional changes.
1 parent fd2d107 commit c153909

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

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

+2-16
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ class DatabaseImagePersistenceStrategyTest extends Specification {
115115
result == null
116116
}
117117

118-
@SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword'])
119118
def "get() should return result from image data dao"() {
120119
given:
121120
Integer expectedImageId = imageInfoDto.id
@@ -124,13 +123,7 @@ class DatabaseImagePersistenceStrategyTest extends Specification {
124123
when:
125124
ImageDto result = strategy.get(imageInfoDto)
126125
then:
127-
1 * imageDataDao.findByImageId({ Integer imageId ->
128-
assert imageId == expectedImageId
129-
return true
130-
}, { Boolean preview ->
131-
assert preview == false
132-
return true
133-
}) >> expectedImageDto
126+
1 * imageDataDao.findByImageId(expectedImageId, false) >> expectedImageDto
134127
and:
135128
result == expectedImageDto
136129
}
@@ -148,7 +141,6 @@ class DatabaseImagePersistenceStrategyTest extends Specification {
148141
result == null
149142
}
150143

151-
@SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword'])
152144
def 'getPreview() should return result of image data dao'() {
153145
given:
154146
Integer expectedImageId = imageInfoDto.id
@@ -157,13 +149,7 @@ class DatabaseImagePersistenceStrategyTest extends Specification {
157149
when:
158150
ImageDto result = strategy.getPreview(imageInfoDto)
159151
then:
160-
1 * imageDataDao.findByImageId({ Integer imageId ->
161-
assert imageId == expectedImageId
162-
return true
163-
}, { Boolean preview ->
164-
assert preview == true
165-
return true
166-
}) >> expectedImageDto
152+
1 * imageDataDao.findByImageId(expectedImageId, true) >> expectedImageDto
167153
and:
168154
result == expectedImageDto
169155
}

0 commit comments

Comments
 (0)