File tree Expand file tree Collapse file tree
main/kotlin/me/proxer/library/api/comment Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ class UpdateCommentEndpoint internal constructor(
4141 * Sets the rating for the comment. Must be between 0 and 10, while 0 means no rating is given by the user.
4242 */
4343 fun rating (rating : Int? ): UpdateCommentEndpoint {
44- require(rating in 0 .. 10 ) {
44+ require(rating == null || rating in 0 .. 10 ) {
4545 " The rating must be between 0 and 10."
4646 }
4747
@@ -65,7 +65,7 @@ class UpdateCommentEndpoint internal constructor(
6565 /* *
6666 * Sets the content of the comment. May contain BBCode tags and can be empty.
6767 */
68- fun comment (comment : String ): UpdateCommentEndpoint {
68+ fun comment (comment : String? ): UpdateCommentEndpoint {
6969 return this .apply { this .comment = comment }
7070 }
7171
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import me.proxer.library.runRequest
66import org.amshove.kluent.invoking
77import org.amshove.kluent.shouldBeNull
88import org.amshove.kluent.shouldEqual
9+ import org.amshove.kluent.shouldNotThrow
910import org.amshove.kluent.shouldThrow
1011import org.junit.jupiter.api.Test
1112import org.junit.jupiter.params.ParameterizedTest
@@ -127,4 +128,11 @@ class UpdateCommentEndpointTest : ProxerTest() {
127128 api.comment.update(" 0" ).rating(rating)
128129 } shouldThrow IllegalArgumentException ::class
129130 }
131+
132+ @Test
133+ fun testRatingValidationNull () {
134+ invoking {
135+ api.comment.update(" 0" ).rating(null )
136+ } shouldNotThrow IllegalArgumentException ::class
137+ }
130138}
You can’t perform that action at this time.
0 commit comments