### Question:
PropertyConfiguration { @NotNull public <T> Optional<T> getValue(@NotNull final NullableProperty<T> property) throws InvalidPropertyException { assertPropertyNotNull(property); final PropertyValue<T> value = valueFromCache(property); final Optional<ValueParseException> parseException = value.getException(); final Optional<PropertyResolutionInfo> propertyResolutionInfo = value.getResolutionInfo(); if (value.getValue().isPresent()) { return value.getValue(); } else if (parseException.isPresent() && propertyResolutionInfo.isPresent()) { throw new InvalidPropertyException(property.getKey(), propertyResolutionInfo.get().getSource(), parseException.get()); } else { return Optional.empty(); } } PropertyConfiguration(@NotNull final List<PropertySource> orderedPropertySources); @NotNull Optional<T> getValueOrEmpty(@NotNull final NullableProperty<T> property); @NotNull T getValueOrDefault(@NotNull final ValuedProperty<T> property); @NotNull Optional<T> getValue(@NotNull final NullableProperty<T> property); @NotNull T getValue(@NotNull final ValuedProperty<T> property); boolean wasKeyProvided(@NotNull final String key); boolean wasPropertyProvided(@NotNull final TypedProperty<T> property); Optional<String> getPropertySource(@NotNull final Property property); Optional<String> getPropertyOrigin(@NotNull final Property property); @NotNull Set<String> getKeys(); Optional<ValueParseException> getPropertyException(@NotNull final TypedProperty<T> property); Optional<String> getRaw(@NotNull final Property property); @NotNull Map<String, String> getRaw(); @NotNull Map<String, String> getRaw(@NotNull final Set<String> keys); @NotNull Map<String, String> getRaw(@NotNull final Predicate<String> predicate); @NotNull Map<String, String> getRaw(@NotNull final PassthroughProperty property);  }### Answer:
@Test public void getValueNullableValue() throws InvalidPropertyException { final NullableProperty<String> nullableProperty = new NullableTestProperty("example.key"); final PropertyConfiguration config = configOf(Pair.of(nullableProperty.getKey(), "providedValue")); Assertions.assertEquals(Optional.of("providedValue"), config.getValue(nullableProperty), "A provided nullable property should return the provided value."); }
@Test public void getValueThrowsOnParseFailureNullable() { final NullableProperty<String> nullableProperty = new NullableTestProperty("example.key"); Assertions.assertThrows(InvalidPropertyException.class, () -> configOf(Pair.of(nullableProperty.getKey(), UNKNOWN_VALUE)).getValue(nullableProperty), "Should throw an exception when failing to parse."); }
@Test public void getValueNullableNull() throws InvalidPropertyException { final NullableProperty<String> nullableProperty = new NullableTestProperty("example.key"); Assertions.assertEquals(Optional.empty(), emptyConfig().getValue(nullableProperty), "Config should provide an empty Optional if the property is nullable."); }
@Test public void getValueOverridesDefault() throws InvalidPropertyException { final ValuedProperty<String> propertyWithDefault = new ValuedTestProperty("example.key", "defaultValue"); final PropertyConfiguration config = configOf(Pair.of(propertyWithDefault.getKey(), "overridden")); Assertions.assertEquals("overridden", config.getValue(propertyWithDefault), "A valid provided value should override any default value."); }
@Test() public void getValueThrowsOnParseFailureTyped() { final ValuedProperty<String> propertyWithDefault = new ValuedTestProperty("example.key", "defaultValue"); Assertions.assertThrows(InvalidPropertyException.class, () -> configOf(Pair.of(propertyWithDefault.getKey(), UNKNOWN_VALUE)).getValue(propertyWithDefault), "Should throw an exception when failing to parse."); }
@Test public void getValueProvidesDefault() throws InvalidPropertyException { final ValuedProperty<String> propertyWithDefault = new ValuedTestProperty("example.key", "defaultValue"); Assertions.assertEquals(propertyWithDefault.getDefaultValue(), emptyConfig().getValue(propertyWithDefault), "Config should provide default value when property is not provided."); }