Skip to content

Commit 2b83255

Browse files
committed
SeriesInfoExtractorServiceImpl.extractSeller(): add unit tests.
Fix #836
1 parent cc0b436 commit 2b83255

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

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

-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ protected Boolean extractPerforated(String fragment) {
240240
return null;
241241
}
242242

243-
// @todo #695 SeriesInfoExtractorServiceImpl.extractSeller(): add unit tests
244243
public Integer extractSeller(String name, String url) {
245244
if (StringUtils.isBlank(name) || StringUtils.isBlank(url)) {
246245
return null;

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

+35
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,41 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
308308
'test/2000' | _
309309
'part of word2000' | _
310310
}
311+
312+
//
313+
// Tests for extractSeller()
314+
//
315+
316+
def 'extractSeller() should return null when name is null, empty or blank'() {
317+
when:
318+
String result = service.extractSeller(nullOrBlank(), Random.url())
319+
then:
320+
result == null
321+
}
322+
323+
def 'extractSeller() should return null when url is null, empty or blank'() {
324+
when:
325+
String result = service.extractSeller(Random.sellerName(), nullOrBlank())
326+
then:
327+
result == null
328+
}
329+
330+
@Unroll
331+
def 'extractSeller() should invoke dao and return its result (#expectedResult)'(Integer expectedResult) {
332+
given:
333+
String expectedName = Random.sellerName()
334+
String expectedUrl = Random.url()
335+
when:
336+
Integer result = service.extractSeller(expectedName, expectedUrl)
337+
then:
338+
1 * transactionParticipantService.findSellerId(expectedName, expectedUrl) >> expectedResult
339+
and:
340+
result == expectedResult
341+
where:
342+
expectedResult | _
343+
null | _
344+
Random.id() | _
345+
}
311346

312347
//
313348
// Tests for extractPrice()

0 commit comments

Comments
 (0)