Search in sources :

Example 1 with StandardMultipartHttpServletRequest

use of org.springframework.web.multipart.support.StandardMultipartHttpServletRequest in project spring-framework by spring-projects.

the class MockMultipartHttpServletRequestBuilder method createServletRequest.

/**
	 * Create a new {@link MockMultipartHttpServletRequest} based on the
	 * supplied {@code ServletContext} and the {@code MockMultipartFiles}
	 * added to this builder.
	 */
@Override
protected final MockHttpServletRequest createServletRequest(ServletContext servletContext) {
    MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest(servletContext);
    this.files.stream().forEach(request::addFile);
    this.parts.values().stream().flatMap(Collection::stream).forEach(request::addPart);
    if (!this.parts.isEmpty()) {
        new StandardMultipartHttpServletRequest(request).getMultiFileMap().values().stream().flatMap(Collection::stream).forEach(request::addFile);
    }
    return request;
}
Also used : MockMultipartHttpServletRequest(org.springframework.mock.web.MockMultipartHttpServletRequest) StandardMultipartHttpServletRequest(org.springframework.web.multipart.support.StandardMultipartHttpServletRequest)

Aggregations

MockMultipartHttpServletRequest (org.springframework.mock.web.MockMultipartHttpServletRequest)1 StandardMultipartHttpServletRequest (org.springframework.web.multipart.support.StandardMultipartHttpServletRequest)1