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

ContentResultMatchersDsl's matchers too strict #34494

Open
levi-h opened this issue Feb 26, 2025 · 0 comments
Open

ContentResultMatchersDsl's matchers too strict #34494

levi-h opened this issue Feb 26, 2025 · 0 comments
Labels
in: test Issues in the test module status: waiting-for-triage An issue we've not yet triaged or decided on theme: kotlin An issue related to Kotlin support

Comments

@levi-h
Copy link

levi-h commented Feb 26, 2025

In ContentResultMatchersDsl, the functions that accept a Matcher don't allow matchers for supertypes of the checked type. This causes code like

    mockMvc
        .get("/books/{bookId}/blurb", BOOK_ID)
        .andExpect { status { isOk() } }
        .andExpect { content { string(hasLength(145)) } }

to not compile, since hasLength is a Matcher<CharSequence> and string wants a Matcher<String>. The original method does accept a Matcher<? super String>; in this case, changing the string method to accept a Matcher<in String> would also solve this compilation error.

The other functions that accept a matcher (node and source) exhibit the same problem.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 26, 2025
@rstoyanchev rstoyanchev added in: test Issues in the test module theme: kotlin An issue related to Kotlin support labels Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module status: waiting-for-triage An issue we've not yet triaged or decided on theme: kotlin An issue related to Kotlin support
Projects
None yet
Development

No branches or pull requests

3 participants