Skip to content

Commit 55cf0f1

Browse files
committed
SeriesInfoExtractorServiceImplTest: simplify code by replacing closures with expected values.
No functional changes.
1 parent 1c0d64f commit 55cf0f1

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

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

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
5757
result.isEmpty()
5858
}
5959

60-
@SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword'])
6160
def 'extractCategory() should try to search by category names'() {
6261
given:
6362
String fragment = 'Lorem ipsum dolor\tsit\namet,'
@@ -67,26 +66,19 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
6766
when:
6867
List<Integer> result = service.extractCategory(fragment)
6968
then:
70-
1 * categoryService.findIdsByNames({ Set<String> candidates ->
71-
assert candidates == expectedCandidates
72-
return true
73-
}) >> expectedResult
69+
1 * categoryService.findIdsByNames(expectedCandidates) >> expectedResult
7470
and:
7571
result == expectedResult
7672
}
7773

78-
@SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword'])
7974
def 'extractCategory() should deduplicate candidates'() {
8075
given:
8176
String fragment = 'foo bar foo'
8277
Set<String> expectedCandidates = [ 'foo', 'bar' ]
8378
when:
8479
service.extractCategory(fragment)
8580
then:
86-
1 * categoryService.findIdsByNames({ Set<String> candidates ->
87-
assert candidates == expectedCandidates
88-
return true
89-
}) >> Random.listOfIntegers()
81+
1 * categoryService.findIdsByNames(expectedCandidates) >> Random.listOfIntegers()
9082
}
9183

9284
def 'extractCategory() should try to search category names with candidate as a prefix'() {
@@ -131,7 +123,6 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
131123
result.isEmpty()
132124
}
133125

134-
@SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword'])
135126
def 'extractCountry() should try to search by country names'() {
136127
given:
137128
String fragment = 'Lorem ipsum dolor\tsit\namet,'
@@ -141,26 +132,19 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
141132
when:
142133
List<Integer> result = service.extractCountry(fragment)
143134
then:
144-
1 * countryService.findIdsByNames({ Set<String> candidates ->
145-
assert candidates == expectedCandidates
146-
return true
147-
}) >> expectedResult
135+
1 * countryService.findIdsByNames(expectedCandidates) >> expectedResult
148136
and:
149137
result == expectedResult
150138
}
151139

152-
@SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword'])
153140
def 'extractCountry() should deduplicate candidates'() {
154141
given:
155142
String fragment = 'foo bar foo'
156143
Set<String> expectedCandidates = [ 'foo', 'bar' ]
157144
when:
158145
service.extractCountry(fragment)
159146
then:
160-
1 * countryService.findIdsByNames({ Set<String> candidates ->
161-
assert candidates == expectedCandidates
162-
return true
163-
}) >> Random.listOfIntegers()
147+
1 * countryService.findIdsByNames(expectedCandidates) >> Random.listOfIntegers()
164148
}
165149

166150
def 'extractCountry() should try to search country names with candidate as a prefix'() {

0 commit comments

Comments
 (0)