0

i have this endpoint:

@PreAuthorize("hasAuthority('user:write')")
    @PostMapping(value = "{messageId}/upload")
    public ResponseEntity<Message> uploadImage(@PathVariable("messageId") Integer id,
                                             @RequestParam("file") MultipartFile file) throws IOException {
        messageService.saveImage(id,file);
        return new ResponseEntity<>(HttpStatus.OK);
    }

Here my test:

@Test
    public void checkIfUploadFileForMessageWillBeSuccess() throws Exception {

        mockMvc.perform(put("/api/message/2/upload")
                .content (***What should i write here***)
                .andExpect(authenticated())
                .andExpect(status().is2xxSuccessful())
                .andExpect(content()
                        .contentTypeCompatibleWith(MediaType.APPLICATION_JSON));
    }

How i upload file: file uploading

How should i describe in code that i'm attaching file as param in the body?

freedman
  • 17
  • 6

0 Answers0