File tree 1 file changed +31
-0
lines changed
src/test/groovy/ru/mystamps/web/service
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import spock.lang.Unroll
23
23
import ru.mystamps.web.dao.UsersActivationDao
24
24
import ru.mystamps.web.dao.dto.AddUsersActivationDbDto
25
25
import ru.mystamps.web.dao.dto.UsersActivationDto
26
+ import ru.mystamps.web.dao.dto.UsersActivationFullDto
26
27
import ru.mystamps.web.model.RegisterAccountForm
27
28
import ru.mystamps.web.service.dto.SendUsersActivationDto
28
29
import ru.mystamps.web.tests.DateUtils
@@ -245,6 +246,36 @@ class UsersActivationServiceImplTest extends Specification {
245
246
result == expectedResult
246
247
}
247
248
249
+ //
250
+ // Tests for findOlderThan()
251
+ //
252
+
253
+ def " findOlderThan() should throw exception when days are less than zero" () {
254
+ when :
255
+ service. findOlderThan(-1 )
256
+ then :
257
+ thrown IllegalArgumentException
258
+ }
259
+
260
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
261
+ def " findOlderThan() should invoke dao, pass changed date and return the result" () {
262
+ given :
263
+ int days = 4
264
+ and :
265
+ Date expectedDate = new Date () - days
266
+ and :
267
+ List<UsersActivationFullDto > expectedResult = [ TestObjects . createUsersActivationFullDto() ]
268
+ when :
269
+ List<UsersActivationFullDto > result = service. findOlderThan(days)
270
+ then :
271
+ 1 * usersActivationDao. findOlderThan({ Date date ->
272
+ assert DateUtils . roughlyEqual(date, expectedDate)
273
+ return true
274
+ }) >> expectedResult
275
+ and :
276
+ result == expectedResult
277
+ }
278
+
248
279
//
249
280
// Tests for remove()
250
281
//
You can’t perform that action at this time.
0 commit comments