Skip to content

Commit

Permalink
chore: add contentType to accept Spring MedieType (#1625)
Browse files Browse the repository at this point in the history
  • Loading branch information
hantsy committed Nov 18, 2022
1 parent 14ef2c6 commit afbf13b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
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

0 comments on commit afbf13b

Please sign in to comment.