@Test @WithMockUser(authorities = { "BACKUP_CONFIGURATION" }) public void uploadBackupFileInvalidBackupFile() throws Exception { doThrow(new InvalidBackupFileException("")).when(backupService) .uploadBackup(any(Boolean.class), any(String.class), any()); try { ResponseEntity<Backup> response = backupsApiController.uploadBackup(false, mockMultipartFile); fail("should throw BadRequestException"); } catch (BadRequestException expected) { } }
@Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = UPLOAD_BACKUP) public ResponseEntity<Backup> uploadBackup(Boolean ignoreWarnings, MultipartFile file) { try { BackupFile backupFile = backupService.uploadBackup(ignoreWarnings, file.getOriginalFilename(), file.getBytes()); return new ResponseEntity<>(backupConverter.convert(backupFile), HttpStatus.CREATED); } catch (InvalidFilenameException | UnhandledWarningsException | InvalidBackupFileException e) { throw new BadRequestException(e); } catch (IOException e) { throw new RuntimeException(e); } }
BackupsApiController implements BackupsApi { @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = UPLOAD_BACKUP) public ResponseEntity<Backup> uploadBackup(Boolean ignoreWarnings, MultipartFile file) { try { BackupFile backupFile = backupService.uploadBackup(ignoreWarnings, file.getOriginalFilename(), file.getBytes()); return new ResponseEntity<>(backupConverter.convert(backupFile), HttpStatus.CREATED); } catch (InvalidFilenameException | UnhandledWarningsException | InvalidBackupFileException e) { throw new BadRequestException(e); } catch (IOException e) { throw new RuntimeException(e); } } }
BackupsApiController implements BackupsApi { @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = UPLOAD_BACKUP) public ResponseEntity<Backup> uploadBackup(Boolean ignoreWarnings, MultipartFile file) { try { BackupFile backupFile = backupService.uploadBackup(ignoreWarnings, file.getOriginalFilename(), file.getBytes()); return new ResponseEntity<>(backupConverter.convert(backupFile), HttpStatus.CREATED); } catch (InvalidFilenameException | UnhandledWarningsException | InvalidBackupFileException e) { throw new BadRequestException(e); } catch (IOException e) { throw new RuntimeException(e); } } @Autowired  BackupsApiController(BackupService backupService,
            RestoreService restoreService, BackupConverter backupConverter,
            TokenService tokenService); }
BackupsApiController implements BackupsApi { @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = UPLOAD_BACKUP) public ResponseEntity<Backup> uploadBackup(Boolean ignoreWarnings, MultipartFile file) { try { BackupFile backupFile = backupService.uploadBackup(ignoreWarnings, file.getOriginalFilename(), file.getBytes()); return new ResponseEntity<>(backupConverter.convert(backupFile), HttpStatus.CREATED); } catch (InvalidFilenameException | UnhandledWarningsException | InvalidBackupFileException e) { throw new BadRequestException(e); } catch (IOException e) { throw new RuntimeException(e); } } @Autowired  BackupsApiController(BackupService backupService,
            RestoreService restoreService, BackupConverter backupConverter,
            TokenService tokenService); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") ResponseEntity<List<Backup>> getBackups(); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = DELETE_BACKUP) ResponseEntity<Void> deleteBackup(String filename); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") ResponseEntity<Resource> downloadBackup(String filename); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = BACKUP) ResponseEntity<Backup> addBackup(); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = UPLOAD_BACKUP) ResponseEntity<Backup> uploadBackup(Boolean ignoreWarnings, MultipartFile file); @Override @PreAuthorize("hasAuthority('RESTORE_CONFIGURATION')") @AuditEventMethod(event = RESTORE_BACKUP) synchronized ResponseEntity<TokensLoggedOut> restoreBackup(String filename); }
BackupsApiController implements BackupsApi { @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = UPLOAD_BACKUP) public ResponseEntity<Backup> uploadBackup(Boolean ignoreWarnings, MultipartFile file) { try { BackupFile backupFile = backupService.uploadBackup(ignoreWarnings, file.getOriginalFilename(), file.getBytes()); return new ResponseEntity<>(backupConverter.convert(backupFile), HttpStatus.CREATED); } catch (InvalidFilenameException | UnhandledWarningsException | InvalidBackupFileException e) { throw new BadRequestException(e); } catch (IOException e) { throw new RuntimeException(e); } } @Autowired  BackupsApiController(BackupService backupService,
            RestoreService restoreService, BackupConverter backupConverter,
            TokenService tokenService); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") ResponseEntity<List<Backup>> getBackups(); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = DELETE_BACKUP) ResponseEntity<Void> deleteBackup(String filename); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") ResponseEntity<Resource> downloadBackup(String filename); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = BACKUP) ResponseEntity<Backup> addBackup(); @Override @PreAuthorize("hasAuthority('BACKUP_CONFIGURATION')") @AuditEventMethod(event = UPLOAD_BACKUP) ResponseEntity<Backup> uploadBackup(Boolean ignoreWarnings, MultipartFile file); @Override @PreAuthorize("hasAuthority('RESTORE_CONFIGURATION')") @AuditEventMethod(event = RESTORE_BACKUP) synchronized ResponseEntity<TokensLoggedOut> restoreBackup(String filename); static final String GENERATE_BACKUP_INTERRUPTED; static final String RESTORE_INTERRUPTED; }