### Question:
ValueResolvingFilter implements ConfigFilter { private String format(String template) { Matcher m = PATTERN_REFERENCE.matcher(template); final StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, Matcher.quoteReplacement(root.get(m.group(1)).asString().get())); } m.appendTail(sb); m = PATTERN_BACKSLASH.matcher(sb.toString()); return m.replaceAll(""); } ValueResolvingFilter(boolean failOnMissingReference);  ValueResolvingFilter(); @Override void init(Config config); @Override String apply(Config.Key key, String stringValue);  }### Answer:
@Test public void testValueResolvingMissingReferenceFails() { Config config = Config.builder( ConfigSources.create( Map.of( "wrong", "${missing}" ))) .addFilter(ConfigFilters.valueResolving() .failOnMissingReference(true) .build()) .disableEnvironmentVariablesSource() .disableSystemPropertiesSource() .disableFilterServices() .build(); ConfigException ex = assertThrows(ConfigException.class, () -> { config.get("wrong").asString().get(); }); assertThat(ex.getMessage(), startsWith(String.format(ValueResolvingFilter.MISSING_REFERENCE_ERROR, "wrong"))); assertThat(ex.getCause(), instanceOf(MissingValueException.class)); }
@Test public void testValueResolvingMissingReferenceFailsViaNoArgsCtor() { Config config = Config.builder( ConfigSources.create( Map.of( "wrong", "${missing}" ))) .addFilter(ConfigFilters.valueResolving().failOnMissingReference(true).build()) .disableEnvironmentVariablesSource() .disableSystemPropertiesSource() .disableFilterServices() .build(); ConfigException ex = assertThrows(ConfigException.class, () -> { config.get("wrong").asString().get(); }); assertThat(ex.getMessage(), startsWith(String.format(ValueResolvingFilter.MISSING_REFERENCE_ERROR, "wrong"))); assertThat(ex.getCause(), instanceOf(MissingValueException.class)); }