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

Add fluent AssertJ-style assertions for RecordedRequests from OkHttp MockWebServer #493

Closed
sleberknight opened this issue Jun 13, 2024 · 0 comments · Fixed by #502
Closed
Assignees
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Milestone

Comments

@sleberknight
Copy link
Member

Instead of this:

var request = takeRequiredRequest(mockWebServer);
assertThat(request.getMethod()).isEqualTo("GET");
assertThat(request.getPath()).isEqualTo("/status");

I want to do this:

assertThatRequiredRequest(mockWebServer)
    .hasMethod("GET")
    .hasPath("/status");

and so on. Since request methods are well-known, perhaps provide dedicated methods:

assertThatRequiredRequest(mockWebServer)
    .isPOST()
    .hasPath("/users")
    .hasBody("{ ... }");

The other things to probably include are:

  • body
  • body size
  • header(s)
  • request URI
  • ...
@sleberknight sleberknight added the new feature A new feature such as a new class, method, package, group of classes, etc. label Jun 13, 2024
@sleberknight sleberknight added this to the 3.5.0 milestone Jun 19, 2024
@sleberknight sleberknight self-assigned this Jun 19, 2024
sleberknight added a commit that referenced this issue Jun 24, 2024
* Add RecordedRequestAssertions and MockWebServerAssertions which
provide
  fluent assertions for RecordedRequest and MockWebServer, respectively
* Add MockWebServers (extracted as separate utility, after I had done
the same
  exact code multiple times)

Closes #493 
Closes #501
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant