Skip to content

Commit a576a93

Browse files
committed
CountryServiceImplTest: use a random value for user id instead of a constant.
Addressed to #300 No functional changes.
1 parent 81195ab commit a576a93

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ import ru.mystamps.web.dao.dto.AddCountryDbDto
2727
import ru.mystamps.web.controller.dto.AddCountryForm
2828
import ru.mystamps.web.dao.dto.LinkEntityDto
2929
import ru.mystamps.web.tests.DateUtils
30+
import ru.mystamps.web.tests.Random
3031
import ru.mystamps.web.util.SlugUtils
3132

3233
@SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace'])
3334
class CountryServiceImplTest extends Specification {
3435

35-
private static final Integer USER_ID = 321
36-
3736
private final CountryDao countryDao = Mock()
3837
private final CountryService service = new CountryServiceImpl(NOPLogger.NOP_LOGGER, countryDao)
3938

@@ -51,7 +50,7 @@ class CountryServiceImplTest extends Specification {
5150

5251
def "add() should throw exception when dto is null"() {
5352
when:
54-
service.add(null, USER_ID)
53+
service.add(null, Random.userId())
5554
then:
5655
thrown IllegalArgumentException
5756
}
@@ -60,7 +59,7 @@ class CountryServiceImplTest extends Specification {
6059
given:
6160
form.setName(null)
6261
when:
63-
service.add(form, USER_ID)
62+
service.add(form, Random.userId())
6463
then:
6564
thrown IllegalArgumentException
6665
}
@@ -82,7 +81,7 @@ class CountryServiceImplTest extends Specification {
8281
and:
8382
countryDao.add(_ as AddCountryDbDto) >> expectedId
8483
when:
85-
String actualSlug = service.add(form, USER_ID)
84+
String actualSlug = service.add(form, Random.userId())
8685
then:
8786
actualSlug == expectedSlug
8887
}
@@ -91,7 +90,7 @@ class CountryServiceImplTest extends Specification {
9190
given:
9291
form.setName(null)
9392
when:
94-
service.add(form, USER_ID)
93+
service.add(form, Random.userId())
9594
then:
9695
thrown IllegalArgumentException
9796
}
@@ -105,7 +104,7 @@ class CountryServiceImplTest extends Specification {
105104
and:
106105
form.setName(name)
107106
when:
108-
service.add(form, USER_ID)
107+
service.add(form, Random.userId())
109108
then:
110109
1 * countryDao.add({ AddCountryDbDto country ->
111110
assert country?.slug == slug

0 commit comments

Comments
 (0)