Skip to content

Consider adding overloaded methods to MockHttpServletRequestBuilder for headers and params #32918

@philwebb

Description

@philwebb

See #32913 and this prototype work by @snicoll for background.

In the example above, it's quite common to see code like this:

assertThat(this.mvc.get()
			.uri("/actuator/auditevents")
			.param("principal", "alice")
			.param("after", queryTimestamp)
			.param("type", "logout"))
		.hasStatusOk();

Repeating the .param call is quite noisy, and it would be nice if you could do something similar to Map.of(...):

assertThat(this.mvc.get()
			.uri("/actuator/auditevents")
			.params("principal", "alice", "after", queryTimestamp, "type", "logout"))
		.hasStatusOk();

Same with the header call.

Both headers and params are multi-value maps, so it's perhaps not entirely straightforward. Perhaps an instanceof check is also needed to support something like:

.params("h1", List.of("v1, "v2"), "h2", "v3")

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: testIssues in the test modulestatus: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions