diff --git a/src/main/java/org/kiwiproject/test/okhttp3/mockwebserver/RecordedRequestAssertions.java b/src/main/java/org/kiwiproject/test/okhttp3/mockwebserver/RecordedRequestAssertions.java index 0ccf3c9..5dc54fe 100644 --- a/src/main/java/org/kiwiproject/test/okhttp3/mockwebserver/RecordedRequestAssertions.java +++ b/src/main/java/org/kiwiproject/test/okhttp3/mockwebserver/RecordedRequestAssertions.java @@ -30,7 +30,7 @@ public class RecordedRequestAssertions { private final RecordedRequest recordedRequest; private RecordedRequestAssertions(RecordedRequest recordedRequest) { - this.recordedRequest = requireNotNull(recordedRequest); + this.recordedRequest = requireNotNull(recordedRequest, "recordedRequest must not be null"); } /** diff --git a/src/main/java/org/kiwiproject/test/okhttp3/mockwebserver/RecordedRequests.java b/src/main/java/org/kiwiproject/test/okhttp3/mockwebserver/RecordedRequests.java index b9136ae..8c749ff 100644 --- a/src/main/java/org/kiwiproject/test/okhttp3/mockwebserver/RecordedRequests.java +++ b/src/main/java/org/kiwiproject/test/okhttp3/mockwebserver/RecordedRequests.java @@ -12,7 +12,7 @@ import java.util.concurrent.TimeUnit; /** - * Contains test assertions for {@link RecordedRequest} when using {@link MockWebServer}. + * Contains utilities for working with {@link RecordedRequest} when using {@link MockWebServer}. */ @UtilityClass @Slf4j diff --git a/src/test/java/org/kiwiproject/test/okhttp3/mockwebserver/RecordedRequestAssertionsTest.java b/src/test/java/org/kiwiproject/test/okhttp3/mockwebserver/RecordedRequestAssertionsTest.java index ae2ade7..90c0dc0 100644 --- a/src/test/java/org/kiwiproject/test/okhttp3/mockwebserver/RecordedRequestAssertionsTest.java +++ b/src/test/java/org/kiwiproject/test/okhttp3/mockwebserver/RecordedRequestAssertionsTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertAll; import static org.kiwiproject.base.KiwiStrings.f; @@ -52,6 +53,19 @@ void setUp() { .build(); } + @Test + void shouldRequireNonNullRecordedRequest() { + assertAll( + () -> assertThatIllegalArgumentException() + .isThrownBy(() -> RecordedRequestAssertions.assertThat(null).isGET()) + .withMessage("recordedRequest must not be null"), + + () -> assertThatIllegalArgumentException() + .isThrownBy(() -> RecordedRequestAssertions.assertThatRecordedRequest(null).isPOST()) + .withMessage("recordedRequest must not be null") + ); + } + @Test void shouldCreateUsingAssertThat() { server.enqueue(new MockResponse());