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 authored Nov 18, 2022
1 parent 14ef2c6 commit afbf13b
Showing 4 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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.
*
Original file line number Diff line number Diff line change
@@ -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");
Original file line number Diff line number Diff line change
@@ -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.
*

0 comments on commit afbf13b

Please sign in to comment.