### Question:
BackupService { public byte[] readBackupFile(String filename) throws BackupFileNotFoundException { if (!getBackup(filename).isPresent()) { throw new BackupFileNotFoundException(getFileNotFoundExceptionMessage(filename)); } return backupRepository.readBackupFile(filename); } @Autowired  BackupService(BackupRepository backupRepository, ServerConfService serverConfService,
            ExternalProcessRunner externalProcessRunner,
            @Value("${script.generate-backup.path}") String generateBackupScriptPath,
            AuditDataHelper auditDataHelper); List<BackupFile> getBackupFiles(); void deleteBackup(String filename); byte[] readBackupFile(String filename); BackupFile generateBackup(); BackupFile uploadBackup(Boolean ignoreWarnings, String filename, byte[] fileBytes); String generateBackupFileName();  }### Answer:
@Test public void downloadBackup() throws Exception { byte[] bytes = "teststring".getBytes(StandardCharsets.UTF_8); when(backupRepository.readBackupFile(BACKUP_FILE_1_NAME)).thenReturn(bytes); byte[] response = backupService.readBackupFile(BACKUP_FILE_1_NAME); assertEquals(bytes.length, response.length); }
@Test public void downloadNonExistingBackup() { try { backupService.readBackupFile("test_file.tar"); fail("should throw BackupFileNotFoundException"); } catch (BackupFileNotFoundException expected) { } }