@@ -32,6 +32,7 @@ import static io.qala.datagen.RandomShortApi.bool
32
32
import static io.qala.datagen.RandomShortApi.nullOr
33
33
import static io.qala.datagen.RandomShortApi.positiveInteger
34
34
import static io.qala.datagen.RandomShortApi.positiveLong
35
+ import static io.qala.datagen.RandomShortApi.sample
35
36
36
37
@SuppressWarnings ([
37
38
' ClassJavadoc' ,
@@ -467,6 +468,44 @@ class SeriesServiceImplTest extends Specification {
467
468
ex. message == ' oops'
468
469
}
469
470
471
+ //
472
+ // Tests for addComment()
473
+ //
474
+
475
+ def ' addComment() should throw exception when series id is null' () {
476
+ when :
477
+ service. addComment(null , null )
478
+ then :
479
+ IllegalArgumentException ex = thrown()
480
+ ex. message == ' Series id must be non null'
481
+ }
482
+
483
+ def ' addComment() should throw exception when comment is null' () {
484
+ when :
485
+ service. addComment(Random . id(), null )
486
+ then :
487
+ IllegalArgumentException ex = thrown()
488
+ ex. message == ' Comment must be non null'
489
+ }
490
+
491
+ def ' addComment() should throw exception when comment is empty or blank' () {
492
+ when :
493
+ service. addComment(Random . id(), sample(' ' , ' ' ))
494
+ then :
495
+ IllegalArgumentException ex = thrown()
496
+ ex. message == ' Comment must be non empty'
497
+ }
498
+
499
+ def ' addComment() should pass parameters to seried dao' () {
500
+ given :
501
+ Integer expectedSeriesId = Random . id()
502
+ String expectedComment = ' this is important'
503
+ when :
504
+ service. addComment(expectedSeriesId, expectedComment)
505
+ then :
506
+ 1 * seriesDao. addComment(expectedSeriesId, expectedComment)
507
+ }
508
+
470
509
//
471
510
// Tests for addImageToSeries()
472
511
//
0 commit comments