Skip to content

Commit 348c79e

Browse files
committed
test(SeriesInfoExtractorServiceImpl.extractSellerGroup): add unit tests.
Fix #920 No functional changes.
1 parent dfebf4d commit 348c79e

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-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
@@ -318,7 +318,6 @@ public Integer extractSeller(String name, String url) {
318318
return null;
319319
}
320320

321-
// @todo #857 SeriesInfoExtractorServiceImpl.extractSellerGroup(): add unit tests
322321
public Integer extractSellerGroup(Integer id, String sellerUrl) {
323322
// we need a group ony for a new seller (id == null)
324323
if (id != null) {

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package ru.mystamps.web.service
1919

2020
import static io.qala.datagen.RandomElements.from
2121
import static io.qala.datagen.RandomShortApi.nullOrBlank
22+
import static io.qala.datagen.RandomShortApi.positiveInteger
2223
import static io.qala.datagen.RandomValue.between
2324

2425
import static ru.mystamps.web.service.SeriesInfoExtractorServiceImpl.MAX_SUPPORTED_RELEASE_YEAR
@@ -439,6 +440,39 @@ class SeriesInfoExtractorServiceImplTest extends Specification {
439440
Random.id() | _
440441
}
441442

443+
//
444+
// Tests for extractSellerGroup()
445+
//
446+
447+
def 'extractSellerGroup() should return null when id is not null'() {
448+
expect:
449+
service.extractSellerGroup(positiveInteger(), Random.url()) == null
450+
}
451+
452+
@Unroll
453+
def 'extractSellerGroup() should return null for invalid url or unknown group (#sellerUrl)'(String sellerUrl) {
454+
when:
455+
Integer groupId = service.extractSellerGroup(null, sellerUrl)
456+
then:
457+
groupId == null
458+
where:
459+
sellerUrl | _
460+
nullOrBlank() | _
461+
'localhost' | _
462+
'https://example.org' | _
463+
}
464+
465+
def 'extractSellerGroup() should return seller group id'() {
466+
given:
467+
Integer expectedGroupId = positiveInteger()
468+
when:
469+
Integer groupId = service.extractSellerGroup(null, 'https://test.ru/about/me')
470+
then:
471+
1 * participantService.findGroupIdByName('test.ru') >> expectedGroupId
472+
and:
473+
groupId == expectedGroupId
474+
}
475+
442476
//
443477
// Tests for extractSellerName()
444478
//

0 commit comments

Comments
 (0)