@@ -26,6 +26,7 @@ import ru.mystamps.web.dao.CollectionDao
26
26
import ru.mystamps.web.dao.dto.AddCollectionDbDto
27
27
import ru.mystamps.web.dao.dto.CollectionInfoDto
28
28
import ru.mystamps.web.tests.DateUtils
29
+ import ru.mystamps.web.tests.Random
29
30
import ru.mystamps.web.util.SlugUtils
30
31
31
32
@SuppressWarnings ([' ClassJavadoc' , ' MethodName' , ' NoDef' , ' NoTabCharacter' , ' TrailingWhitespace' ])
@@ -54,23 +55,23 @@ class CollectionServiceImplTest extends Specification {
54
55
@SuppressWarnings (' FactoryMethodName' )
55
56
def ' createCollection() should throw exception when owner login is null' () {
56
57
when :
57
- service. createCollection(123 , null )
58
+ service. createCollection(Random . userId() , null )
58
59
then :
59
60
thrown IllegalArgumentException
60
61
}
61
62
62
63
@SuppressWarnings (' FactoryMethodName' )
63
64
def ' createCollection() should throw exception when owner login can\' t be converted to slug' () {
64
65
when :
65
- service. createCollection(123 , ' ' )
66
+ service. createCollection(Random . userId() , ' ' )
66
67
then :
67
68
thrown IllegalArgumentException
68
69
}
69
70
70
71
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' FactoryMethodName' , ' UnnecessaryReturnKeyword' ])
71
72
def ' createCollection() should pass owner id to dao' () {
72
73
given :
73
- Integer expectedOwnerId = 123
74
+ Integer expectedOwnerId = Random . userId()
74
75
when :
75
76
service. createCollection(expectedOwnerId, ' test' )
76
77
then :
@@ -87,7 +88,7 @@ class CollectionServiceImplTest extends Specification {
87
88
and :
88
89
String expectedSlug = SlugUtils . slugify(ownerLogin)
89
90
when :
90
- service. createCollection(123 , ownerLogin)
91
+ service. createCollection(Random . userId() , ownerLogin)
91
92
then :
92
93
1 * collectionDao. add({ AddCollectionDbDto collection ->
93
94
assert collection?. slug == expectedSlug
@@ -98,7 +99,7 @@ class CollectionServiceImplTest extends Specification {
98
99
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' FactoryMethodName' , ' UnnecessaryReturnKeyword' ])
99
100
def ' createCollection() should assign updated at to current date' () {
100
101
when :
101
- service. createCollection(123 , ' any-login' )
102
+ service. createCollection(Random . userId() , ' any-login' )
102
103
then :
103
104
1 * collectionDao. add({ AddCollectionDbDto collection ->
104
105
assert DateUtils . roughlyEqual(collection?. updatedAt, new Date ())
@@ -119,15 +120,15 @@ class CollectionServiceImplTest extends Specification {
119
120
120
121
def ' addToCollection() should throw exception when series id is null' () {
121
122
when :
122
- service. addToCollection(123 , null )
123
+ service. addToCollection(Random . userId() , null )
123
124
then :
124
125
thrown IllegalArgumentException
125
126
}
126
127
127
128
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
128
129
def ' addToCollection() should add series to collection and mark it as modified' () {
129
130
given :
130
- Integer expectedUserId = 123
131
+ Integer expectedUserId = Random . userId()
131
132
Integer expectedSeriesId = 456
132
133
when :
133
134
service. addToCollection(expectedUserId, expectedSeriesId)
@@ -162,15 +163,15 @@ class CollectionServiceImplTest extends Specification {
162
163
163
164
def ' removeFromCollection() should throw exception when series id is null' () {
164
165
when :
165
- service. removeFromCollection(456 , null )
166
+ service. removeFromCollection(Random . userId() , null )
166
167
then :
167
168
thrown IllegalArgumentException
168
169
}
169
170
170
171
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
171
172
def ' removeFromCollection() should remove series from collection and mark it as modified' () {
172
173
given :
173
- Integer expectedUserId = 123
174
+ Integer expectedUserId = Random . userId()
174
175
Integer expectedSeriesId = 456
175
176
when :
176
177
service. removeFromCollection(expectedUserId, expectedSeriesId)
@@ -198,7 +199,7 @@ class CollectionServiceImplTest extends Specification {
198
199
199
200
def ' isSeriesInCollection() should throw exception when series id is null' () {
200
201
when :
201
- service. isSeriesInCollection(100 , null )
202
+ service. isSeriesInCollection(Random . userId() , null )
202
203
then :
203
204
thrown IllegalArgumentException
204
205
}
@@ -217,7 +218,7 @@ class CollectionServiceImplTest extends Specification {
217
218
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
218
219
def ' isSeriesInCollection() should pass arguments to dao' () {
219
220
given :
220
- Integer expectedUserId = 123
221
+ Integer expectedUserId = Random . userId()
221
222
and :
222
223
Integer expectedSeriesId = 456
223
224
and :
0 commit comments