Skip to content

Commit cde756b

Browse files
committed
CollectionServiceImplTest: propagate Random.userId().
Addressed to #300 No functional changes.
1 parent 410cf50 commit cde756b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

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

+12-11
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import ru.mystamps.web.dao.CollectionDao
2626
import ru.mystamps.web.dao.dto.AddCollectionDbDto
2727
import ru.mystamps.web.dao.dto.CollectionInfoDto
2828
import ru.mystamps.web.tests.DateUtils
29+
import ru.mystamps.web.tests.Random
2930
import ru.mystamps.web.util.SlugUtils
3031

3132
@SuppressWarnings(['ClassJavadoc', 'MethodName', 'NoDef', 'NoTabCharacter', 'TrailingWhitespace'])
@@ -54,23 +55,23 @@ class CollectionServiceImplTest extends Specification {
5455
@SuppressWarnings('FactoryMethodName')
5556
def 'createCollection() should throw exception when owner login is null'() {
5657
when:
57-
service.createCollection(123, null)
58+
service.createCollection(Random.userId(), null)
5859
then:
5960
thrown IllegalArgumentException
6061
}
6162

6263
@SuppressWarnings('FactoryMethodName')
6364
def 'createCollection() should throw exception when owner login can\'t be converted to slug'() {
6465
when:
65-
service.createCollection(123, '')
66+
service.createCollection(Random.userId(), '')
6667
then:
6768
thrown IllegalArgumentException
6869
}
6970

7071
@SuppressWarnings(['ClosureAsLastMethodParameter', 'FactoryMethodName', 'UnnecessaryReturnKeyword'])
7172
def 'createCollection() should pass owner id to dao'() {
7273
given:
73-
Integer expectedOwnerId = 123
74+
Integer expectedOwnerId = Random.userId()
7475
when:
7576
service.createCollection(expectedOwnerId, 'test')
7677
then:
@@ -87,7 +88,7 @@ class CollectionServiceImplTest extends Specification {
8788
and:
8889
String expectedSlug = SlugUtils.slugify(ownerLogin)
8990
when:
90-
service.createCollection(123, ownerLogin)
91+
service.createCollection(Random.userId(), ownerLogin)
9192
then:
9293
1 * collectionDao.add({ AddCollectionDbDto collection ->
9394
assert collection?.slug == expectedSlug
@@ -98,7 +99,7 @@ class CollectionServiceImplTest extends Specification {
9899
@SuppressWarnings(['ClosureAsLastMethodParameter', 'FactoryMethodName', 'UnnecessaryReturnKeyword'])
99100
def 'createCollection() should assign updated at to current date'() {
100101
when:
101-
service.createCollection(123, 'any-login')
102+
service.createCollection(Random.userId(), 'any-login')
102103
then:
103104
1 * collectionDao.add({ AddCollectionDbDto collection ->
104105
assert DateUtils.roughlyEqual(collection?.updatedAt, new Date())
@@ -119,15 +120,15 @@ class CollectionServiceImplTest extends Specification {
119120

120121
def 'addToCollection() should throw exception when series id is null'() {
121122
when:
122-
service.addToCollection(123, null)
123+
service.addToCollection(Random.userId(), null)
123124
then:
124125
thrown IllegalArgumentException
125126
}
126127

127128
@SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword'])
128129
def 'addToCollection() should add series to collection and mark it as modified'() {
129130
given:
130-
Integer expectedUserId = 123
131+
Integer expectedUserId = Random.userId()
131132
Integer expectedSeriesId = 456
132133
when:
133134
service.addToCollection(expectedUserId, expectedSeriesId)
@@ -162,15 +163,15 @@ class CollectionServiceImplTest extends Specification {
162163

163164
def 'removeFromCollection() should throw exception when series id is null'() {
164165
when:
165-
service.removeFromCollection(456, null)
166+
service.removeFromCollection(Random.userId(), null)
166167
then:
167168
thrown IllegalArgumentException
168169
}
169170

170171
@SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword'])
171172
def 'removeFromCollection() should remove series from collection and mark it as modified'() {
172173
given:
173-
Integer expectedUserId = 123
174+
Integer expectedUserId = Random.userId()
174175
Integer expectedSeriesId = 456
175176
when:
176177
service.removeFromCollection(expectedUserId, expectedSeriesId)
@@ -198,7 +199,7 @@ class CollectionServiceImplTest extends Specification {
198199

199200
def 'isSeriesInCollection() should throw exception when series id is null'() {
200201
when:
201-
service.isSeriesInCollection(100, null)
202+
service.isSeriesInCollection(Random.userId(), null)
202203
then:
203204
thrown IllegalArgumentException
204205
}
@@ -217,7 +218,7 @@ class CollectionServiceImplTest extends Specification {
217218
@SuppressWarnings(['ClosureAsLastMethodParameter', 'UnnecessaryReturnKeyword'])
218219
def 'isSeriesInCollection() should pass arguments to dao'() {
219220
given:
220-
Integer expectedUserId = 123
221+
Integer expectedUserId = Random.userId()
221222
and:
222223
Integer expectedSeriesId = 456
223224
and:

0 commit comments

Comments
 (0)