-
Couldn't load subscription status.
- Fork 38.8k
Description
Eric Deandrea opened SPR-16729 and commented
Seems that the reactive WebTestClient is missing some valuable assertions that are available on MockMvc.
With MockMvc I can do things like
this.mockMvc.perform(get("/some/url"))
.andExpect(jsonPath("$.someNestedObject.*", Matchers.hasSize(5)))
.andExpect(jsonPath("$.someNestedObject.anotherObject").value(Matchers.startsWith("Some String")));The WebTestClient.jsonPath method doesn't have an overloaded
jsonPath(String expression, Matcher<T> matcher)method like its MockMvcResultMatchers counterpart does. Also JsonPathAssertions doesn't have an overloaded
value(Matcher<T> matcher)method like its JsonPathResultMatchers counterpart does. Under the covers both JsonPathResultMatchers & JsonPathAssertions utilize the exact same JsonPathExpectationsHelper which exposes the
public <T> void assertValue(String content, Matcher<T> matcher)method which is needed.
Is there a particular reason this is missing or is it an oversight? Also seems that there is 0 support for assertions against XML using WebTestClient. Again, is there a specific reason as to why not?
Affects: 5.0.5
Issue Links:
- Better support for testing JSON [SPR-16737] #21278 Better support for testing JSON
- Provide XML-based assertions in WebTestClient [SPR-16741] #21282 Provide XML-based assertions in WebTestClient
- Introduce consumeWith() methods in WebTestClient assertions [SPR-16574] #21116 Introduce consumeWith() methods in WebTestClient assertions
Referenced from: commits 20de500