### Question:
SecretAwarePropertySource extends EnumerablePropertySource<EnumerablePropertySource> { @Override public Object getProperty(String name) { Object o = source.getProperty(name); if (o instanceof String && EncryptedSecret.isEncryptedSecret((String) o)) { String propertyValue = (String) o; if (secretManager == null) { throw new SecretException("No secret manager to decrypt value of " + name); } String lName = name.toLowerCase(); if (isSamlFile(lName)) { return "file:" + secretManager.decryptAsFile(propertyValue).toString(); } else if (isFile(lName) || EncryptedSecret.isEncryptedFile(propertyValue)) { return secretManager.decryptAsFile(propertyValue).toString(); } else { return secretManager.decrypt(propertyValue); } } return o; } SecretAwarePropertySource(EnumerablePropertySource source, SecretManager secretManager); @Override Object getProperty(String name); @Override String[] getPropertyNames();  }### Answer:
@Test public void secretPropertyShouldGetDecrypted() { secretAwarePropertySource.getProperty("testSecretString"); verify(secretManager, times(1)).decrypt(any()); verify(secretManager, never()).decryptAsFile(any()); }
@Test public void secretFileShouldGetDecryptedAsFile() { secretAwarePropertySource.getProperty("testSecretFile"); verify(secretManager, never()).decrypt(any()); verify(secretManager, times(1)).decryptAsFile(any()); }
@Test public void secretPathShouldGetDecryptedAsFile() { secretAwarePropertySource.getProperty("testSecretPath"); verify(secretManager, never()).decrypt(any()); verify(secretManager, times(1)).decryptAsFile(any()); }
@Test public void secretFileInPropertyValueShouldGetDecryptedAsFile() { secretAwarePropertySource.getProperty("testSecretCert"); verify(secretManager, never()).decrypt(any()); verify(secretManager, times(1)).decryptAsFile(any()); }
@Test public void unencryptedPropertyShouldDoNothing() { String notSecretKey = "testNotSoSecret"; Object returnedValue = secretAwarePropertySource.getProperty(notSecretKey); verify(secretManager, never()).decrypt(any()); verify(secretManager, never()).decryptAsFile(any()); assertEquals(testValues.get(notSecretKey), returnedValue); }
@Test public void noSecretManagerShouldThrowException() { secretAwarePropertySource.setSecretManager(null); thrown.expect(SecretException.class); thrown.expectMessage("No secret manager to decrypt value of testSecretString"); secretAwarePropertySource.getProperty("testSecretString"); }