Skip to content

Commit fdca673

Browse files
committed
SeriesInfoExtractorServiceImpl.extractQuantity(): add unit tests.
Fix #788
1 parent 1492b5f commit fdca673

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

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

-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ protected Integer extractReleaseYear(String fragment) {
198198
return null;
199199
}
200200

201-
// @todo #781 SeriesInfoExtractorServiceImpl.extractQuantity(): add unit tests
202201
// @todo #781 SeriesInfoExtractorServiceImpl.extractQuantity() respect MAX_STAMPS_IN_SERIES
203202
protected Integer extractQuantity(String fragment) {
204203
if (StringUtils.isBlank(fragment)) {

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

+28
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,34 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
309309
'part of word2000' | _
310310
}
311311

312+
//
313+
// Tests for extractQuantity()
314+
//
315+
316+
def 'extractQuantity() should return null when fragment is null, empty or blank'() {
317+
expect:
318+
service.extractQuantity(nullOrBlank()) == null
319+
}
320+
321+
def 'extractQuantity() should return null for invalid price'() {
322+
expect:
323+
service.extractQuantity('0 марок') == null
324+
}
325+
326+
@Unroll
327+
def 'extractQuantity() should extract quantity from "#fragment"'(String fragment, Integer expectedQuantity) {
328+
expect:
329+
service.extractQuantity(fragment) == expectedQuantity
330+
where:
331+
fragment || expectedQuantity
332+
'5 марок' || 5
333+
'5 МАРОК' || 5
334+
'22 марки' || 22
335+
'13 беззубцовые марок' || 13
336+
'4 беззубцовые марки' || 4
337+
'32 БЕЗЗУБЦОВЫЕ МАРКИ' || 32
338+
}
339+
312340
//
313341
// Tests for extractSeller()
314342
//

0 commit comments

Comments
 (0)