### Question:
InternalTlsCertificateService { public void generateInternalTlsKeyAndCertificate() throws InterruptedException { try { externalProcessRunner.executeAndThrowOnFailure(generateCertScriptPath, generateCertScriptArgs.split("\\s+")); } catch (ProcessNotExecutableException | ProcessFailedException e) { log.error("Failed to generate internal TLS key and cert", e); throw new DeviationAwareRuntimeException(e, new ErrorDeviation(KEY_CERT_GENERATION_FAILED)); } X509Certificate generatedCert = internalTlsCertificateRepository.getInternalTlsCertificate(); auditDataHelper.putCertificateHash(generatedCert); } @Autowired  InternalTlsCertificateService(InternalTlsCertificateRepository internalTlsCertificateRepository,
            ExternalProcessRunner externalProcessRunner,
            @Value("${script.generate-certificate.path}") String generateCertScriptPath,
            @Value("${script.generate-certificate.args}") String generateCertScriptArgs,
            AuditDataHelper auditDataHelper); X509Certificate getInternalTlsCertificate(); byte[] exportInternalTlsCertificate(); void generateInternalTlsKeyAndCertificate(); X509Certificate importInternalTlsCertificate(byte[] certificateBytes); static final String KEY_CERT_GENERATION_FAILED; static final String IMPORT_INTERNAL_CERT_FAILED; }### Answer:
@Test public void generateInternalTlsKeyAndCertificate() { internalTlsCertificateService.setGenerateCertScriptPath(MOCK_SUCCESS_SCRIPT); try { internalTlsCertificateService.generateInternalTlsKeyAndCertificate(); } catch (Exception e) { fail("should not throw exceptions"); } }
@Test public void generateInternalTlsKeyAndCertificateFail() throws Exception { internalTlsCertificateService.setGenerateCertScriptPath(MOCK_FAIL_SCRIPT); try { internalTlsCertificateService.generateInternalTlsKeyAndCertificate(); } catch (DeviationAwareRuntimeException e) { assertEquals(KEY_CERT_GENERATION_FAILED, e.getErrorDeviation().getCode()); } }
@Test public void generateInternalTlsKeyAndCertificateNotExecutable() throws Exception { internalTlsCertificateService.setGenerateCertScriptPath(NON_EXISTING_SCRIPT); try { internalTlsCertificateService.generateInternalTlsKeyAndCertificate(); } catch (DeviationAwareRuntimeException e) { assertEquals(KEY_CERT_GENERATION_FAILED, e.getErrorDeviation().getCode()); } }