Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recorded Request improvements #530

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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