Skip to content

ContentResultMatchersDsl's matchers too strict #34494

Closed as duplicate
Closed as duplicate
@levi-h

Description

@levi-h

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.

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulestatus: duplicateA duplicate of another issuetheme: kotlinAn issue related to Kotlin support

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions