@Test public void successfulUploadReturnsHttpOk() { new Expectations() { { mockStorageService.store((MultipartFile) any, anyString); times = 1; } }; assertEquals(HttpStatus.OK, testFileUploadController.handleFileUpload(mockMultipartFile, "type").getStatusCode()); }
@PostMapping("/upload/{type}") public ResponseEntity<String> handleFileUpload(@RequestParam("file") MultipartFile file, @PathVariable("type") String type) { logger.debug("File received at endpoint: /upload/{}, name={}", type, file.getOriginalFilename()); try { storageService.store(file, type); } catch (Exception e) { logger.error("File storage error", e); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"Error\": \"File storage error.\"}"); } return ResponseEntity.status(HttpStatus.OK).body("{\"Success\": \"True\"}"); }
FileUploadController { @PostMapping("/upload/{type}") public ResponseEntity<String> handleFileUpload(@RequestParam("file") MultipartFile file, @PathVariable("type") String type) { logger.debug("File received at endpoint: /upload/{}, name={}", type, file.getOriginalFilename()); try { storageService.store(file, type); } catch (Exception e) { logger.error("File storage error", e); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"Error\": \"File storage error.\"}"); } return ResponseEntity.status(HttpStatus.OK).body("{\"Success\": \"True\"}"); } }
FileUploadController { @PostMapping("/upload/{type}") public ResponseEntity<String> handleFileUpload(@RequestParam("file") MultipartFile file, @PathVariable("type") String type) { logger.debug("File received at endpoint: /upload/{}, name={}", type, file.getOriginalFilename()); try { storageService.store(file, type); } catch (Exception e) { logger.error("File storage error", e); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"Error\": \"File storage error.\"}"); } return ResponseEntity.status(HttpStatus.OK).body("{\"Success\": \"True\"}"); } @Autowired  FileUploadController(
   		StorageService storageService, OdeProperties odeProperties,
         SimpMessagingTemplate template); }
FileUploadController { @PostMapping("/upload/{type}") public ResponseEntity<String> handleFileUpload(@RequestParam("file") MultipartFile file, @PathVariable("type") String type) { logger.debug("File received at endpoint: /upload/{}, name={}", type, file.getOriginalFilename()); try { storageService.store(file, type); } catch (Exception e) { logger.error("File storage error", e); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"Error\": \"File storage error.\"}"); } return ResponseEntity.status(HttpStatus.OK).body("{\"Success\": \"True\"}"); } @Autowired  FileUploadController(
   		StorageService storageService, OdeProperties odeProperties,
         SimpMessagingTemplate template); @PostMapping("/upload/{type}") ResponseEntity<String> handleFileUpload(@RequestParam("file") MultipartFile file, @PathVariable("type") String type); @ExceptionHandler(StorageFileNotFoundException.class) ResponseEntity<Void> handleStorageFileNotFound(StorageFileNotFoundException exc); }
FileUploadController { @PostMapping("/upload/{type}") public ResponseEntity<String> handleFileUpload(@RequestParam("file") MultipartFile file, @PathVariable("type") String type) { logger.debug("File received at endpoint: /upload/{}, name={}", type, file.getOriginalFilename()); try { storageService.store(file, type); } catch (Exception e) { logger.error("File storage error", e); return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"Error\": \"File storage error.\"}"); } return ResponseEntity.status(HttpStatus.OK).body("{\"Success\": \"True\"}"); } @Autowired  FileUploadController(
   		StorageService storageService, OdeProperties odeProperties,
         SimpMessagingTemplate template); @PostMapping("/upload/{type}") ResponseEntity<String> handleFileUpload(@RequestParam("file") MultipartFile file, @PathVariable("type") String type); @ExceptionHandler(StorageFileNotFoundException.class) ResponseEntity<Void> handleStorageFileNotFound(StorageFileNotFoundException exc);  }