Skip to content

Commit 5e3fd61

Browse files
committed
Series import: recognize category/country with trailing comma.
Fix #816
1 parent 33082af commit 5e3fd61

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/ru/mystamps/web/service/SeriesInfoExtractorServiceImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected List<Integer> extractCategory(String fragment) {
7979

8080
log.debug("Determining category from a fragment: '{}'", fragment);
8181

82-
String[] candidates = StringUtils.split(fragment);
82+
String[] candidates = StringUtils.split(fragment, "\n\t ,");
8383
Set<String> uniqueCandidates = new HashSet<>();
8484
Collections.addAll(uniqueCandidates, candidates);
8585

@@ -112,7 +112,7 @@ protected List<Integer> extractCountry(String fragment) {
112112

113113
log.debug("Determining country from a fragment: '{}'", fragment);
114114

115-
String[] candidates = StringUtils.split(fragment);
115+
String[] candidates = StringUtils.split(fragment, "\n\t ,");
116116
Set<String> uniqueCandidates = new HashSet<>();
117117
Collections.addAll(uniqueCandidates, candidates);
118118

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
6161
def 'extractCategory() should try to search by category names'() {
6262
given:
6363
String fragment = 'Lorem ipsum dolor\tsit\namet,'
64-
Set<String> expectedCandidates = [ 'Lorem', 'ipsum', 'dolor', 'sit', 'amet,' ]
64+
Set<String> expectedCandidates = [ 'Lorem', 'ipsum', 'dolor', 'sit', 'amet' ]
6565
and:
6666
List<Integer> expectedResult = Random.listOfIntegers()
6767
when:
@@ -135,7 +135,7 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
135135
def 'extractCountry() should try to search by country names'() {
136136
given:
137137
String fragment = 'Lorem ipsum dolor\tsit\namet,'
138-
Set<String> expectedCandidates = [ 'Lorem', 'ipsum', 'dolor', 'sit', 'amet,' ]
138+
Set<String> expectedCandidates = [ 'Lorem', 'ipsum', 'dolor', 'sit', 'amet' ]
139139
and:
140140
List<Integer> expectedResult = Random.listOfIntegers()
141141
when:

0 commit comments

Comments
 (0)