### Question:
RestoreService { public synchronized void restoreFromBackup(String fileName) throws BackupFileNotFoundException, InterruptedException, RestoreProcessFailedException { auditDataHelper.putBackupFilename(backupRepository.getFilePath(fileName)); String configurationBackupPath = backupRepository.getConfigurationBackupPath(); String backupFilePath = configurationBackupPath + fileName; File backupFile = new File(backupFilePath); if (!backupFile.isFile()) { throw new BackupFileNotFoundException("backup file " + backupFilePath + " does not exist"); } String[] arguments = buildArguments(backupFilePath); try { eventPublisher.publishEvent(BackupRestoreEvent.START); ExternalProcessRunner.ProcessResult processResult = externalProcessRunner .executeAndThrowOnFailure(configurationRestoreScriptPath, arguments); int exitCode = processResult.getExitCode(); if (log.isInfoEnabled()) { String restoreFinishedLogMsg = String.format("Restoring configuration finished with exit status %s", exitCode); log.info(restoreFinishedLogMsg); log.info(" --- Restore script console output - START --- "); log.info(ExternalProcessRunner.processOutputToString(processResult.getProcessOutput())); log.info(" --- Restore script console output - END --- "); } persistenceUtils.evictPoolConnections(); } catch (ProcessFailedException | ProcessNotExecutableException e) { throw new RestoreProcessFailedException(e, "restoring from a backup failed"); } finally { eventPublisher.publishEvent(BackupRestoreEvent.END); apiKeyService.clearApiKeyCaches(); log.debug("Cleared api key caches"); } } @Autowired  RestoreService(ExternalProcessRunner externalProcessRunner,
            @Value("${script.restore-configuration.path}") String configurationRestoreScriptPath,
            @Value("${script.restore-configuration.args}") String configurationRestoreScriptArgs,
            CurrentSecurityServerId currentSecurityServerId, BackupRepository backupRepository,
            ApiKeyService apiKeyService, AuditDataHelper auditDataHelper, PersistenceUtils persistenceUtils,
            ApplicationEventPublisher publisher); synchronized void restoreFromBackup(String fileName);  }### Answer:
@Test public void restoreFromBackup() throws Exception { restoreService.restoreFromBackup(tempBackupFilename); assertTrue(true); }
@Test public void restoreFromNonExistingBackup() throws Exception { try { restoreService.restoreFromBackup("no-backups-here.tar"); fail("should have thrown an exception"); } catch (BackupFileNotFoundException e) { assertEquals(BackupFileNotFoundException.ERROR_BACKUP_FILE_NOT_FOUND, e.getErrorDeviation().getCode()); } }
@Test public void restoreFromBackupFail() throws Exception { restoreService.setConfigurationRestoreScriptPath(ExternalProcessRunnerTest.MOCK_FAIL_SCRIPT); try { restoreService.restoreFromBackup(tempBackupFilename); fail("should have thrown an exception"); } catch (RestoreProcessFailedException e) { assertEquals(RestoreProcessFailedException.RESTORE_PROCESS_FAILED, e.getErrorDeviation().getCode()); } }
@Test public void restoreFromBackupNotExecutable() throws Exception { restoreService.setConfigurationRestoreScriptPath("path/to/nowhere.sh"); try { restoreService.restoreFromBackup(tempBackupFilename); fail("should have thrown an exception"); } catch (RestoreProcessFailedException e) { assertEquals(RestoreProcessFailedException.RESTORE_PROCESS_FAILED, e.getErrorDeviation().getCode()); } }