@@ -591,11 +591,64 @@ class SeriesServiceImplTest extends Specification {
591
591
// Tests for addImageToSeries()
592
592
//
593
593
594
+ def " addImageToSeries() should throw exception when dto is null" () {
595
+ when :
596
+ service. addImageToSeries(null , 111 , 222 )
597
+ then :
598
+ thrown IllegalArgumentException
599
+ }
600
+
601
+ def " addImageToSeries() should throw exception when series id is null" () {
602
+ when :
603
+ service. addImageToSeries(imageForm, null , 222 )
604
+ then :
605
+ thrown IllegalArgumentException
606
+ }
607
+
608
+ def " addImageToSeries() should throw exception when user id is null" () {
609
+ when :
610
+ service. addImageToSeries(imageForm, 111 , null )
611
+ then :
612
+ thrown IllegalArgumentException
613
+ }
614
+
594
615
@SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
595
- def " addImageToSeries() should call dao and pass series id, current date and user id to it" () {
616
+ def " addImageToSeries() should save image" () {
617
+ given :
618
+ imageForm. setImage(multipartFile)
619
+ when :
620
+ service. addImageToSeries(imageForm, 111 , 222 )
621
+ then :
622
+ 1 * imageService. save({ MultipartFile passedFile ->
623
+ assert passedFile == multipartFile
624
+ return true
625
+ }) >> ANY_IMAGE_ID
626
+ }
627
+
628
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
629
+ def " addImageToSeries() should add image to series" () {
596
630
given :
597
631
Integer expectedSeriesId = 123
632
+ Integer expectedUserId = 321
633
+ Integer expectedImageId = 456
634
+ when :
635
+ service. addImageToSeries(imageForm, expectedSeriesId, expectedUserId)
636
+ then :
637
+ imageService. save(_) >> expectedImageId
598
638
and :
639
+ 1 * imageService. addToSeries({ Integer seriesId ->
640
+ assert seriesId == expectedSeriesId
641
+ return true
642
+ }, { Integer imageId ->
643
+ assert imageId == expectedImageId
644
+ return true
645
+ })
646
+ }
647
+
648
+ @SuppressWarnings ([' ClosureAsLastMethodParameter' , ' UnnecessaryReturnKeyword' ])
649
+ def " addImageToSeries() should mark series as modified" () {
650
+ given :
651
+ Integer expectedSeriesId = 123
599
652
Integer expectedUserId = 321
600
653
when :
601
654
service. addImageToSeries(imageForm, expectedSeriesId, expectedUserId)
0 commit comments