Skip to content

Commit

Permalink
Recorded Request improvements
Browse files Browse the repository at this point in the history
* Add a message to RecordedRequestAssertions null check to make
  it clear what is required without needing to go into the code.
* Make Javadoc in RecordedRequests clearer.
  • Loading branch information
sleberknight committed Dec 1, 2024
1 parent 5d99d71 commit 29bb194
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 29bb194

Please sign in to comment.