@Test void testCreateFileFromForm() { HttpServletRequest httpServletRequest = mock(HttpServletRequest.class); when(httpServletRequest.getContentType()).thenReturn("multipart/form-data"); Exception exception = assertThrows( UnsupportedOperationException.class, () -> filesApiController.createFileFromForm(httpServletRequest)); assertThat(exception.getMessage()) .containsPattern("Media type 'multipart/form-data' not supported"); }
@PostMapping(consumes = {"application/x-www-form-urlencoded", "multipart/form-data"}) @ResponseStatus(BAD_REQUEST) public CompletableFuture<ResponseEntity<FileResponse>> createFileFromForm( HttpServletRequest httpServletRequest) { throw new UnsupportedOperationException( "Media type '" + httpServletRequest.getContentType() + "' not supported"); }
FilesController extends ApiController { @PostMapping(consumes = {"application/x-www-form-urlencoded", "multipart/form-data"}) @ResponseStatus(BAD_REQUEST) public CompletableFuture<ResponseEntity<FileResponse>> createFileFromForm( HttpServletRequest httpServletRequest) { throw new UnsupportedOperationException( "Media type '" + httpServletRequest.getContentType() + "' not supported"); } }
FilesController extends ApiController { @PostMapping(consumes = {"application/x-www-form-urlencoded", "multipart/form-data"}) @ResponseStatus(BAD_REQUEST) public CompletableFuture<ResponseEntity<FileResponse>> createFileFromForm( HttpServletRequest httpServletRequest) { throw new UnsupportedOperationException( "Media type '" + httpServletRequest.getContentType() + "' not supported"); } FilesController(FilesService filesService, UserPermissionEvaluator userPermissionEvaluator); }
FilesController extends ApiController { @PostMapping(consumes = {"application/x-www-form-urlencoded", "multipart/form-data"}) @ResponseStatus(BAD_REQUEST) public CompletableFuture<ResponseEntity<FileResponse>> createFileFromForm( HttpServletRequest httpServletRequest) { throw new UnsupportedOperationException( "Media type '" + httpServletRequest.getContentType() + "' not supported"); } FilesController(FilesService filesService, UserPermissionEvaluator userPermissionEvaluator); @ApiOperation("Upload file (see documentation)") @PostMapping @ResponseStatus(CREATED) CompletableFuture<ResponseEntity<FileResponse>> createFile(
      HttpServletRequest httpServletRequest); @PostMapping(consumes = {"application/x-www-form-urlencoded", "multipart/form-data"}) @ResponseStatus(BAD_REQUEST) CompletableFuture<ResponseEntity<FileResponse>> createFileFromForm(
      HttpServletRequest httpServletRequest); @ApiOperation("Retrieve file metadata (see documentation)") @GetMapping(value = "/{fileId}") FileResponse readFile(@PathVariable("fileId") String fileId); @ApiOperation("Download file (see documentation)") @GetMapping(value = "/{fileId}", params = "alt=media") ResponseEntity<StreamingResponseBody> downloadFile(@PathVariable("fileId") String fileId); @ApiOperation("Delete file (see documentation)") @DeleteMapping(value = "/{fileId}") @ResponseStatus(NO_CONTENT) void deleteFile(@PathVariable("fileId") String fileId); }
FilesController extends ApiController { @PostMapping(consumes = {"application/x-www-form-urlencoded", "multipart/form-data"}) @ResponseStatus(BAD_REQUEST) public CompletableFuture<ResponseEntity<FileResponse>> createFileFromForm( HttpServletRequest httpServletRequest) { throw new UnsupportedOperationException( "Media type '" + httpServletRequest.getContentType() + "' not supported"); } FilesController(FilesService filesService, UserPermissionEvaluator userPermissionEvaluator); @ApiOperation("Upload file (see documentation)") @PostMapping @ResponseStatus(CREATED) CompletableFuture<ResponseEntity<FileResponse>> createFile(
      HttpServletRequest httpServletRequest); @PostMapping(consumes = {"application/x-www-form-urlencoded", "multipart/form-data"}) @ResponseStatus(BAD_REQUEST) CompletableFuture<ResponseEntity<FileResponse>> createFileFromForm(
      HttpServletRequest httpServletRequest); @ApiOperation("Retrieve file metadata (see documentation)") @GetMapping(value = "/{fileId}") FileResponse readFile(@PathVariable("fileId") String fileId); @ApiOperation("Download file (see documentation)") @GetMapping(value = "/{fileId}", params = "alt=media") ResponseEntity<StreamingResponseBody> downloadFile(@PathVariable("fileId") String fileId); @ApiOperation("Delete file (see documentation)") @DeleteMapping(value = "/{fileId}") @ResponseStatus(NO_CONTENT) void deleteFile(@PathVariable("fileId") String fileId);  }