@Test void testUploadMtaFileErrorSizeExceeded() throws Exception { Mockito.when(servletFileUpload.getItemIterator(Mockito.eq(request))) .thenThrow(new SizeLimitExceededException("size limit exceeded", MAX_PERMITTED_SIZE + 1024, MAX_PERMITTED_SIZE)); Assertions.assertThrows(SLException.class, () -> testedClass.uploadFile(request, SPACE_GUID, null)); }
@Override public ResponseEntity<FileMetadata> uploadFile(HttpServletRequest request, String spaceGuid, String namespace) { try { StopWatch stopWatch = StopWatch.createStarted(); LOGGER.trace("Received upload request on URI: {}", ServletUtil.decodeUri(request)); FileEntry fileEntry = uploadFiles(request, spaceGuid, namespace).get(0); FileMetadata file = parseFileEntry(fileEntry); AuditLoggingProvider.getFacade() .logConfigCreate(file); stopWatch.stop(); LOGGER.trace("Uploaded file \"{}\" with name {}, size {} and digest {} (algorithm {}) for {} ms.", file.getId(), file.getName(), file.getSize(), file.getDigest(), file.getDigestAlgorithm(), stopWatch.getTime()); return ResponseEntity.status(HttpStatus.CREATED) .body(file); } catch (FileUploadException | IOException | FileStorageException e) { throw new SLException(e, Messages.COULD_NOT_UPLOAD_FILE_0, e.getMessage()); } }
FilesApiServiceImpl implements FilesApiService { @Override public ResponseEntity<FileMetadata> uploadFile(HttpServletRequest request, String spaceGuid, String namespace) { try { StopWatch stopWatch = StopWatch.createStarted(); LOGGER.trace("Received upload request on URI: {}", ServletUtil.decodeUri(request)); FileEntry fileEntry = uploadFiles(request, spaceGuid, namespace).get(0); FileMetadata file = parseFileEntry(fileEntry); AuditLoggingProvider.getFacade() .logConfigCreate(file); stopWatch.stop(); LOGGER.trace("Uploaded file \"{}\" with name {}, size {} and digest {} (algorithm {}) for {} ms.", file.getId(), file.getName(), file.getSize(), file.getDigest(), file.getDigestAlgorithm(), stopWatch.getTime()); return ResponseEntity.status(HttpStatus.CREATED) .body(file); } catch (FileUploadException | IOException | FileStorageException e) { throw new SLException(e, Messages.COULD_NOT_UPLOAD_FILE_0, e.getMessage()); } } }
FilesApiServiceImpl implements FilesApiService { @Override public ResponseEntity<FileMetadata> uploadFile(HttpServletRequest request, String spaceGuid, String namespace) { try { StopWatch stopWatch = StopWatch.createStarted(); LOGGER.trace("Received upload request on URI: {}", ServletUtil.decodeUri(request)); FileEntry fileEntry = uploadFiles(request, spaceGuid, namespace).get(0); FileMetadata file = parseFileEntry(fileEntry); AuditLoggingProvider.getFacade() .logConfigCreate(file); stopWatch.stop(); LOGGER.trace("Uploaded file \"{}\" with name {}, size {} and digest {} (algorithm {}) for {} ms.", file.getId(), file.getName(), file.getSize(), file.getDigest(), file.getDigestAlgorithm(), stopWatch.getTime()); return ResponseEntity.status(HttpStatus.CREATED) .body(file); } catch (FileUploadException | IOException | FileStorageException e) { throw new SLException(e, Messages.COULD_NOT_UPLOAD_FILE_0, e.getMessage()); } }  }
FilesApiServiceImpl implements FilesApiService { @Override public ResponseEntity<FileMetadata> uploadFile(HttpServletRequest request, String spaceGuid, String namespace) { try { StopWatch stopWatch = StopWatch.createStarted(); LOGGER.trace("Received upload request on URI: {}", ServletUtil.decodeUri(request)); FileEntry fileEntry = uploadFiles(request, spaceGuid, namespace).get(0); FileMetadata file = parseFileEntry(fileEntry); AuditLoggingProvider.getFacade() .logConfigCreate(file); stopWatch.stop(); LOGGER.trace("Uploaded file \"{}\" with name {}, size {} and digest {} (algorithm {}) for {} ms.", file.getId(), file.getName(), file.getSize(), file.getDigest(), file.getDigestAlgorithm(), stopWatch.getTime()); return ResponseEntity.status(HttpStatus.CREATED) .body(file); } catch (FileUploadException | IOException | FileStorageException e) { throw new SLException(e, Messages.COULD_NOT_UPLOAD_FILE_0, e.getMessage()); } }  @Override ResponseEntity<List<FileMetadata>> getFiles(String spaceGuid, String namespace); @Override ResponseEntity<FileMetadata> uploadFile(HttpServletRequest request, String spaceGuid, String namespace); }
FilesApiServiceImpl implements FilesApiService { @Override public ResponseEntity<FileMetadata> uploadFile(HttpServletRequest request, String spaceGuid, String namespace) { try { StopWatch stopWatch = StopWatch.createStarted(); LOGGER.trace("Received upload request on URI: {}", ServletUtil.decodeUri(request)); FileEntry fileEntry = uploadFiles(request, spaceGuid, namespace).get(0); FileMetadata file = parseFileEntry(fileEntry); AuditLoggingProvider.getFacade() .logConfigCreate(file); stopWatch.stop(); LOGGER.trace("Uploaded file \"{}\" with name {}, size {} and digest {} (algorithm {}) for {} ms.", file.getId(), file.getName(), file.getSize(), file.getDigest(), file.getDigestAlgorithm(), stopWatch.getTime()); return ResponseEntity.status(HttpStatus.CREATED) .body(file); } catch (FileUploadException | IOException | FileStorageException e) { throw new SLException(e, Messages.COULD_NOT_UPLOAD_FILE_0, e.getMessage()); } }  @Override ResponseEntity<List<FileMetadata>> getFiles(String spaceGuid, String namespace); @Override ResponseEntity<FileMetadata> uploadFile(HttpServletRequest request, String spaceGuid, String namespace);  }