use of org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder in project vorto by eclipse.
the class IntegrationTestBase method createImage.
protected ResultActions createImage(String filename, String modelId, SecurityMockMvcRequestPostProcessors.UserRequestPostProcessor user, Integer size) throws Exception {
MockMultipartFile file = null;
if (size == null) {
file = new MockMultipartFile("file", filename, MediaType.IMAGE_PNG_VALUE, getClass().getClassLoader().getResourceAsStream("models/" + filename));
} else {
file = new MockMultipartFile("file", filename, MediaType.IMAGE_PNG_VALUE, new byte[size]);
}
MockMultipartHttpServletRequestBuilder builder = MockMvcRequestBuilders.fileUpload("/rest/models/" + modelId + "/images");
return repositoryServer.perform(builder.file(file).with(request -> {
request.setMethod("POST");
return request;
}).contentType(MediaType.MULTIPART_FORM_DATA).with(user));
}
Aggregations