@@ -30,6 +30,7 @@ import org.slf4j.helpers.NOPLogger
30
30
import spock.lang.Specification
31
31
import spock.lang.Unroll
32
32
33
+ import ru.mystamps.web.tests.Random
33
34
import ru.mystamps.web.validation.ValidationRules
34
35
35
36
@SuppressWarnings ([' ClassJavadoc' , ' MethodName' , ' NoDef' , ' NoTabCharacter' , ' TrailingWhitespace' ])
@@ -56,6 +57,24 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
56
57
result. isEmpty()
57
58
}
58
59
60
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
61
+ def ' extractCategory() should try to search by category names' () {
62
+ given :
63
+ String fragment = ' Lorem ipsum dolor\t sit\n amet,'
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
+
59
78
//
60
79
// Tests for extractCountry()
61
80
//
@@ -69,6 +88,24 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
69
88
result. isEmpty()
70
89
}
71
90
91
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
92
+ def ' extractCountry() should try to search by country names' () {
93
+ given :
94
+ String fragment = ' Lorem ipsum dolor\t sit\n amet,'
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
+
72
109
//
73
110
// Tests for extractReleaseYear()
74
111
//
0 commit comments