@@ -30,6 +30,7 @@ import ru.mystamps.web.dao.CollectionDao
30
30
import ru.mystamps.web.dao.dto.AddCollectionDbDto
31
31
import ru.mystamps.web.dao.dto.AddToCollectionDbDto
32
32
import ru.mystamps.web.dao.dto.CollectionInfoDto
33
+ import ru.mystamps.web.dao.dto.Currency
33
34
import ru.mystamps.web.tests.DateUtils
34
35
import ru.mystamps.web.tests.Random
35
36
import ru.mystamps.web.util.SlugUtils
@@ -147,15 +148,31 @@ class CollectionServiceImplTest extends Specification {
147
148
thrown IllegalArgumentException
148
149
}
149
150
151
+ def ' addToCollection() should throw exception when price is specified without currency' () {
152
+ given :
153
+ AddToCollectionForm dto = new AddToCollectionForm ()
154
+ dto. setPrice(Random . price())
155
+ dto. setNumberOfStamps(Random . quantity())
156
+ dto. setCurrency(null )
157
+ when :
158
+ service. addToCollection(Random . userId(), Random . id(), dto)
159
+ then :
160
+ thrown IllegalStateException
161
+ }
162
+
150
163
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
151
164
def ' addToCollection() should add series to collection and mark it as modified' () {
152
165
given :
153
166
Integer expectedUserId = Random . userId()
154
167
Integer expectedSeriesId = Random . id()
155
168
Integer expectedNumberOfStamps = Random . quantity()
169
+ BigDecimal expectedPrice = Random . price()
170
+ Currency expectedCurrency = Random . currency()
156
171
and :
157
172
AddToCollectionForm form = new AddToCollectionForm ()
158
173
form. setNumberOfStamps(expectedNumberOfStamps)
174
+ form. setPrice(expectedPrice)
175
+ form. setCurrency(expectedCurrency)
159
176
when :
160
177
service. addToCollection(expectedUserId, expectedSeriesId, form)
161
178
then :
0 commit comments