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

chore: allow contentType() to accept Spring MediaType #1625

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -191,6 +191,11 @@ public MockMvcRequestSpecification contentType(ContentType contentType) {
return header(CONTENT_TYPE, contentType.toString());
}

public MockMvcRequestSpecification contentType(MediaType mediaType) {
notNull(mediaType, "mediaType");
return header(CONTENT_TYPE, mediaType.toString());
}

public MockMvcRequestSpecification contentType(String contentType) {
notNull(contentType, "contentType");
return header(CONTENT_TYPE, contentType);
Expand Down
Expand Up @@ -57,6 +57,16 @@ public interface MockMvcRequestSpecification extends MockMvcRequestSender {
*/
MockMvcRequestSpecification contentType(ContentType contentType);

/**
* Specify the content type of the request.
*
* @param mediaType The content type of the request
* @return The request specification
* @see ContentType
* @see MediaType
*/
MockMvcRequestSpecification contentType(MediaType mediaType);

/**
* Specify the content type of the request.
*
Expand Down
Expand Up @@ -118,6 +118,12 @@ public WebTestClientRequestSpecification contentType(ContentType contentType) {
return header(CONTENT_TYPE, contentType.toString());
}

@Override
public WebTestClientRequestSpecification contentType(MediaType mediaType) {
notNull(mediaType, "mediaType");
return header(CONTENT_TYPE, mediaType.toString());
}

@Override
public WebTestClientRequestSpecification contentType(String contentType) {
notNull(contentType, "contentType");
Expand Down
Expand Up @@ -46,6 +46,16 @@ public interface WebTestClientRequestSpecification extends WebTestClientRequestS
*/
WebTestClientRequestSpecification contentType(ContentType contentType);

/**
* Specify the content type of the request.
*
* @param mediaType The content type of the request
* @return The request specification
*
* @see ContentType
*/
WebTestClientRequestSpecification contentType(MediaType mediaType);

/**
* Specify the content type of the request.
*
Expand Down