Search in sources :

Example 1 with ObjectMapperSerializationContextImpl

use of io.restassured.internal.mapping.ObjectMapperSerializationContextImpl in project rest-assured by rest-assured.

the class MockMvcRequestSpecificationImpl method body.

public MockMvcRequestSpecification body(Object object, ObjectMapper mapper) {
    notNull(object, "object");
    notNull(mapper, "Object mapper");
    String requestContentType = getRequestContentType();
    ObjectMapperSerializationContextImpl ctx = new ObjectMapperSerializationContextImpl();
    ctx.setObject(object);
    ctx.setCharset(findEncoderCharsetOrReturnDefault(requestContentType));
    ctx.setContentType(requestContentType);
    this.requestBody = mapper.serialize(ctx);
    return this;
}
Also used : ObjectMapperSerializationContextImpl(io.restassured.internal.mapping.ObjectMapperSerializationContextImpl)

Example 2 with ObjectMapperSerializationContextImpl

use of io.restassured.internal.mapping.ObjectMapperSerializationContextImpl in project rest-assured by rest-assured.

the class MultiPartSpecBuilder method applyContentToSpec.

private void applyContentToSpec(MultiPartSpecificationImpl spec) {
    final Object actualContent;
    if (explicitObjectMapper != null) {
        ObjectMapperSerializationContextImpl ctx = new ObjectMapperSerializationContextImpl();
        ctx.setObject(content);
        ctx.setContentType(mimeType);
        actualContent = explicitObjectMapper.serialize(ctx);
    } else if (explicitObjectMapperType != null) {
        actualContent = ObjectMapping.serialize(content, mimeType, null, explicitObjectMapperType, new ObjectMapperConfig(), new EncoderConfig());
    } else {
        actualContent = content;
    }
    spec.setContent(actualContent);
}
Also used : ObjectMapperSerializationContextImpl(io.restassured.internal.mapping.ObjectMapperSerializationContextImpl) ObjectMapperConfig(io.restassured.config.ObjectMapperConfig) EncoderConfig(io.restassured.config.EncoderConfig)

Aggregations

ObjectMapperSerializationContextImpl (io.restassured.internal.mapping.ObjectMapperSerializationContextImpl)2 EncoderConfig (io.restassured.config.EncoderConfig)1 ObjectMapperConfig (io.restassured.config.ObjectMapperConfig)1