### Question:
SecretManager { public Path decryptAsFile(String filePathOrEncrypted) { if (!EncryptedSecret.isEncryptedSecret(filePathOrEncrypted)) { return Paths.get(filePathOrEncrypted); } else { return createTempFile("tmp", decryptAsBytes(filePathOrEncrypted)); } } @Autowired  SecretManager(SecretEngineRegistry secretEngineRegistry); String decrypt(String configValue); Path decryptAsFile(String filePathOrEncrypted); byte[] decryptAsBytes(String encryptedString);  }### Answer:
@Test public void decryptFileSecretEngineNotFound() throws SecretDecryptionException { when(secretEngineRegistry.getEngine("does-not-exist")).thenReturn(null); String secretConfig = "encrypted:does-not-exist!paramName:paramValue"; exceptionRule.expect(SecretDecryptionException.class); exceptionRule.expectMessage("Secret Engine does not exist: does-not-exist"); secretManager.decryptAsFile(secretConfig); }
@Test public void decryptFileInvalidParams() throws SecretDecryptionException { doThrow(InvalidSecretFormatException.class).when(secretEngine).validate(any()); String secretConfig = "encrypted:s3!paramName:paramValue"; exceptionRule.expect(InvalidSecretFormatException.class); secretManager.decryptAsFile(secretConfig); }