Skip to content

SPR-16417 - Support varargs for expectations in MockMvc #1651

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

Closed
wants to merge 2 commits into from
Closed

SPR-16417 - Support varargs for expectations in MockMvc #1651

wants to merge 2 commits into from

Conversation

neonailol
Copy link
Contributor

@neonailol neonailol commented Jan 25, 2018

The current way of writing multiple expect statements is kinda verbose:

 mockMvc.perform(get("/person/1"))
   .andExpect(status().isOk())
   .andExpect(content().contentType(MediaType.APPLICATION_JSON))
   .andExpect(jsonPath("$.person.name").value("Jason"));

I propose vararg method that can do the same in a slightly cleaner way using default interface method:

 mockMvc.perform(get("/person/1"))
   .andExpect(
     status().isOk(),
     content().contentType(MediaType.APPLICATION_JSON),
     jsonPath("$.person.name").value("Jason")
   );

@sbrannen
Copy link
Member

Hi @neonailol,

Thanks for the PR.

Please open a JIRA issue for this enhancement request and post a link to the JIRA issue back here.

@sbrannen sbrannen changed the title spring-test: Allow to execute a number of expectations together Support varargs for expectations in MockMvc Jan 25, 2018
@sbrannen
Copy link
Member

FYI: I updated the title to more succinctly describe the enhancement request.

@neonailol
Copy link
Contributor Author

neonailol commented Jan 25, 2018

@sbrannen I created an issues corresponding this pull request SPR-16417

@neonailol neonailol changed the title Support varargs for expectations in MockMvc SPR-16417: Support varargs for expectations in MockMvc Jan 25, 2018
@neonailol neonailol changed the title SPR-16417: Support varargs for expectations in MockMvc SPR-16417 - Support varargs for expectations in MockMvc Jan 25, 2018
@rstoyanchev
Copy link
Contributor

Resolved in a slightly different way, by adding ResultMatcher#matchAll.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants