### Question:
BackupService { public List<BackupFile> getBackupFiles() { List<File> files = backupRepository.getBackupFiles(); List<BackupFile> backupFiles = new ArrayList<>(); files.stream().forEach(b -> backupFiles.add(new BackupFile(b.getName()))); setCreatedAt(backupFiles); return backupFiles; } @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 getBackups() { List<BackupFile> backups = backupService.getBackupFiles(); assertEquals(2, backups.size()); assertEquals(BACKUP_FILE_1_NAME, backups.get(0).getFilename()); assertEquals(BACKUP_FILE_1_CREATED_AT, backups.get(0).getCreatedAt().toString()); assertEquals(BACKUP_FILE_2_NAME, backups.get(1).getFilename()); assertEquals(BACKUP_FILE_2_CREATED_AT, backups.get(1).getCreatedAt().toString()); }
@Test public void getBackupsEmptyList() { when(backupRepository.getBackupFiles()).thenReturn(new ArrayList<>()); List<BackupFile> backups = backupService.getBackupFiles(); assertEquals(0, backups.size()); }
@Test public void getBackupsException() { when(backupRepository.getBackupFiles()).thenThrow(new RuntimeException()); try { backupService.getBackupFiles(); fail("should throw RuntimeException"); } catch (RuntimeException expected) { } }