FileController { @RequestMapping(value = "/upload", method = RequestMethod.POST) public String saveAuto(@RequestPart(value = "json") JsonPojo pojo, @RequestParam(value = "some-random") String random, @RequestParam(value = "data", required = true) List<MultipartFile> files, @RequestBody Role role) { System.out.println("random:" + random); System.out.println("pojo:" + pojo.getJson()); files.forEach(file -> System.out.println("filename: " + file.getOriginalFilename())); System.out.println("role" + role.toString()); return "success"; }  @RequestMapping(value = "/upload", method = RequestMethod.POST) String saveAuto(@RequestPart(value = "json") JsonPojo pojo, @RequestParam(value = "some-random") String random,
                           @RequestParam(value = "data", required = true) List<MultipartFile> files, @RequestBody Role role);  }
@Test public void testSaveAuto() throws Exception { MockMultipartFile firstFile = new MockMultipartFile("data", "filename.txt", "text/plain","mock file test".getBytes()); MockMultipartFile secondFile = new MockMultipartFile("data", "other-file-name.data", "text/plain", "some other type".getBytes()); MockMultipartFile jsonFile = new MockMultipartFile("json", "", "application/json", "{\"json\": \"someValue\"}".getBytes()); mockMvc.perform(MockMvcRequestBuilders.fileUpload("/upload").file(firstFile).file(secondFile).file(jsonFile) .param("random", "4")).andExpect(status().is(200)).andExpect(content().string("success")); System.out.println("====================="); files(firstFile, secondFile); }