### Question:
KeyConfiguration extends ConfigItem { public Optional<DefaultKeyVaultConfig> getKeyVaultConfig(KeyVaultType type) { if (type == null) { return Optional.empty(); } if (KeyVaultType.AZURE.equals(type) && azureKeyVaultConfig != null) { return Optional.of(KeyVaultConfigConverter.convert(azureKeyVaultConfig)); } if (KeyVaultType.HASHICORP.equals(type) && hashicorpKeyVaultConfig != null) { return Optional.of(KeyVaultConfigConverter.convert(hashicorpKeyVaultConfig)); } if (keyVaultConfigs == null) { return Optional.empty(); } return keyVaultConfigs.stream().filter(c -> type.equals(c.getKeyVaultType())).findFirst(); } KeyConfiguration(
            final Path passwordFile,
            final List<String> passwords,
            final List<KeyData> keyData,
            final AzureKeyVaultConfig azureKeyVaultConfig,
            final HashicorpKeyVaultConfig hashicorpKeyVaultConfig);  KeyConfiguration(); Path getPasswordFile(); List<String> getPasswords(); List<KeyData> getKeyData(); AzureKeyVaultConfig getAzureKeyVaultConfig(); HashicorpKeyVaultConfig getHashicorpKeyVaultConfig(); List<KeyVaultConfig> getKeyVaultConfigs(); Optional<DefaultKeyVaultConfig> getKeyVaultConfig(KeyVaultType type); void setPasswordFile(Path passwordFile); void setPasswords(List<String> passwords); void setKeyData(List<KeyData> keyData); void addKeyVaultConfig(KeyVaultConfig keyVaultConfig); @Valid
    @NotNull
    @Size(min = 1, message = "At least 1 public/private key pair must be provided")
    private List<KeyData> keyData; }### Answer:
@Test public void loadKeyVaultConfigFromNoConfig() { KeyConfiguration keyConfiguration = new KeyConfiguration(); Optional<DefaultKeyVaultConfig> result = keyConfiguration.getKeyVaultConfig(KeyVaultType.AZURE); assertThat(result).isNotPresent(); }
@Test public void loadKeyVaultConfigFromDeprecatedTypes() { AzureKeyVaultConfig azureKeyVaultConfig = new AzureKeyVaultConfig(); HashicorpKeyVaultConfig hashicorpKeyVaultConfig = new HashicorpKeyVaultConfig(); KeyConfiguration keyConfiguration = new KeyConfiguration(null, null, null, azureKeyVaultConfig, hashicorpKeyVaultConfig); DefaultKeyVaultConfig azureResult = keyConfiguration.getKeyVaultConfig(KeyVaultType.AZURE).get(); assertThat(azureResult).isNotNull(); DefaultKeyVaultConfig hashicorpResult = keyConfiguration.getKeyVaultConfig(KeyVaultType.HASHICORP).get(); assertThat(hashicorpResult).isNotNull(); }
@Test public void loadKeyVaultConfigWithNullType() { KeyConfiguration keyConfiguration = new KeyConfiguration(); assertThat(keyConfiguration.getKeyVaultConfig(null)).isNotPresent(); }