Skip to content

Commit 9421342

Browse files
committed
SeriesInfoExtractorServiceImpl.extractCurrency(): add unit tests.
Fix #840
1 parent 0f20aa0 commit 9421342

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ public BigDecimal extractPrice(String fragment) {
281281
}
282282
}
283283

284-
// @todo #695 SeriesInfoExtractorServiceImpl.extractCurrency(): add unit tests
285284
public String extractCurrency(String fragment) {
286285
if (StringUtils.isBlank(fragment)) {
287286
return null;

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,4 +309,33 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
309309
'part of word2000' | _
310310
}
311311

312+
//
313+
// Tests for extractCurrency()
314+
//
315+
316+
def 'extractCurrency() should return null when fragment is null, empty or blank'() {
317+
when:
318+
String result = service.extractCurrency(nullOrBlank())
319+
then:
320+
result == null
321+
}
322+
323+
def 'extractCurrency() should return null for unknown currency'() {
324+
given:
325+
String invalidCurrency = 'CAD'
326+
when:
327+
String result = service.extractCurrency(invalidCurrency)
328+
then:
329+
result == null
330+
}
331+
332+
def 'extractCurrency() should extract currency from a fragment'() {
333+
given:
334+
String validCurrency = Random.currency()
335+
when:
336+
String result = service.extractCurrency(validCurrency)
337+
then:
338+
result == validCurrency
339+
}
340+
312341
}

0 commit comments

Comments
 (0)