Skip to content

Commit 6091f30

Browse files
committed
SeriesInfoExtractorServiceImplTest: add more unit tests.
Addressed to #686 No functional changes.
1 parent eac644c commit 6091f30

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

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

+37
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import org.slf4j.helpers.NOPLogger
3030
import spock.lang.Specification
3131
import spock.lang.Unroll
3232

33+
import ru.mystamps.web.tests.Random
3334
import ru.mystamps.web.validation.ValidationRules
3435

3536
@SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace'])
@@ -56,6 +57,24 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
5657
result.isEmpty()
5758
}
5859

60+
@SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword'])
61+
def 'extractCategory() should try to search by category names'() {
62+
given:
63+
String fragment = 'Lorem ipsum dolor\tsit\namet,'
64+
Set<String> expectedCandidates = [ 'Lorem', 'ipsum', 'dolor', 'sit', 'amet,']
65+
and:
66+
List<Integer> expectedResult = Random.listOfIntegers()
67+
when:
68+
List<Integer> result = service.extractCategory(fragment)
69+
then:
70+
1 * categoryService.findIdsByNames({ Set<String> candidates ->
71+
assert candidates == expectedCandidates
72+
return true
73+
}) >> expectedResult
74+
and:
75+
result == expectedResult
76+
}
77+
5978
//
6079
// Tests for extractCountry()
6180
//
@@ -69,6 +88,24 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
6988
result.isEmpty()
7089
}
7190

91+
@SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword'])
92+
def 'extractCountry() should try to search by country names'() {
93+
given:
94+
String fragment = 'Lorem ipsum dolor\tsit\namet,'
95+
Set<String> expectedCandidates = [ 'Lorem', 'ipsum', 'dolor', 'sit', 'amet,']
96+
and:
97+
List<Integer> expectedResult = Random.listOfIntegers()
98+
when:
99+
List<Integer> result = service.extractCountry(fragment)
100+
then:
101+
1 * countryService.findIdsByNames({ Set<String> candidates ->
102+
assert candidates == expectedCandidates
103+
return true
104+
}) >> expectedResult
105+
and:
106+
result == expectedResult
107+
}
108+
72109
//
73110
// Tests for extractReleaseYear()
74111
//

0 commit comments

Comments
 (0)