Package org.springframework.test.http

# Class HttpMessageContentConverter

java.lang.Object
org.springframework.test.http.HttpMessageContentConverter

public class HttpMessageContentConverter extends Object
Convert HTTP message content for testing purposes.

Since:
  6.2
Author:
  Stephane Nicoll

## Method Summary

Modifier and Type
Method
Description
`<T> T`
`convert(org.springframework.http.HttpInputMessage message, org.springframework.http.MediaType mediaType, org.springframework.core.ResolvableType targetType)`
Convert the given `HttpInputMessage` whose content must match the given `MediaType` to the requested `targetType`.
`<T> T`
`convertViaJson(Object value, org.springframework.core.ResolvableType targetType)`
Convert the given raw value to the given `targetType` by writing it first to JSON and reading it back.
`static HttpMessageContentConverter`
`of(Iterable<org.springframework.http.converter.HttpMessageConverter<?>> candidates)`
Create an instance with an iterable of the candidates to use.
`static HttpMessageContentConverter`
`of(org.springframework.http.converter.HttpMessageConverter<?>... candidates)`
Create an instance with a vararg of the candidates to use.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### of

public static HttpMessageContentConverter of(Iterable<org.springframework.http.converter.HttpMessageConverter<?>> candidates)
Create an instance with an iterable of the candidates to use.

Parameters:
  `candidates` - the candidates

### of

public static HttpMessageContentConverter of(org.springframework.http.converter.HttpMessageConverter<?>... candidates)
Create an instance with a vararg of the candidates to use.

Parameters:
  `candidates` - the candidates

### convert

public <T> T convert(org.springframework.http.HttpInputMessage message, org.springframework.http.MediaType mediaType, org.springframework.core.ResolvableType targetType) throws IOException, org.springframework.http.converter.HttpMessageNotReadableException
Convert the given `HttpInputMessage` whose content must match the given `MediaType` to the requested `targetType`.

Type Parameters:
  `T` - the converted object type
Parameters:
  `message` - an input message
  `mediaType` - the media type of the input
  `targetType` - the target type
Returns:
  a value of the given `targetType`
Throws:
  `IOException`
  `org.springframework.http.converter.HttpMessageNotReadableException`

### convertViaJson

public <T> T convertViaJson(Object value, org.springframework.core.ResolvableType targetType) throws IOException
Convert the given raw value to the given `targetType` by writing it first to JSON and reading it back.

Type Parameters:
  `T` - the converted object type
Parameters:
  `value` - the value to convert
  `targetType` - the target type
Returns:
  a value of the given `targetType`
Throws:
  `IOException`