### Question:
ExpressionConfigSourceInterceptor implements ConfigSourceInterceptor { @Override public ConfigValue getValue(final ConfigSourceInterceptorContext context, final String name) { return getValue(context, name, 1); }  @Override ConfigValue getValue(final ConfigSourceInterceptorContext context, final String name);  }### Answer:
@Test public void simpleExpression() { SmallRyeConfig config = buildConfig("my.prop", "1234", "expression", "${my.prop}"); assertEquals("1234", config.getValue("expression", String.class)); }
@Test public void multipleExpressions() { SmallRyeConfig config = buildConfig("my.prop", "1234", "expression", "${my.prop}${my.prop}"); assertEquals("12341234", config.getValue("expression", String.class)); }
@Test public void composedExpressions() { SmallRyeConfig config = buildConfig("my.prop", "1234", "expression", "${${compose}}", "compose", "my.prop"); assertEquals("1234", config.getValue("expression", String.class)); }
@Test public void defaultExpression() { SmallRyeConfig config = buildConfig("expression", "${my.prop:1234}"); assertEquals("1234", config.getValue("expression", String.class)); }
@Test public void defaultExpressionEmpty() { SmallRyeConfig config = buildConfig("expression", "12${my.prop:}34"); assertEquals("1234", config.getValue("expression", String.class)); }
@Test public void defaultExpressionComposed() { SmallRyeConfig config = buildConfig("expression", "${my.prop:${compose}}", "compose", "1234"); assertEquals("1234", config.getValue("expression", String.class)); }
@Test public void defaultExpressionComposedEmpty() { SmallRyeConfig config = buildConfig("expression", "${my.prop:${compose:}}", "my.prop", "1234"); assertEquals("1234", config.getValue("expression", String.class)); }
@Test public void noExpression() { SmallRyeConfig config = buildConfig("expression", "${my.prop}"); final NoSuchElementException exception = assertThrows(NoSuchElementException.class, () -> config.getValue("expression", String.class)); assertEquals("SRCFG00011: Could not expand value my.prop in property expression", exception.getMessage()); }
@Test public void noExpressionComposed() { SmallRyeConfig config = buildConfig("expression", "${my.prop${compose}}"); final NoSuchElementException exception = assertThrows(NoSuchElementException.class, () -> config.getValue("expression", String.class)); assertEquals("SRCFG00011: Could not expand value compose in property expression", exception.getMessage()); }
@Test public void withoutExpansion() { SmallRyeConfig config = buildConfig("my.prop", "1234", "expression", "${my.prop}"); assertEquals("1234", config.getValue("expression", String.class)); Expressions.withoutExpansion(() -> assertEquals("${my.prop}", config.getValue("expression", String.class))); Expressions.withoutExpansion(() -> assertEquals("${my.prop}", config.getValue("expression", String.class))); Expressions.withoutExpansion(() -> assertEquals("${my.prop}", config.getValue("expression", String.class))); assertEquals("1234", config.getValue("expression", String.class)); }
@Test void expressionMissing() { final SmallRyeConfig config = buildConfig("my.prop", "${expression}", "my.prop.partial", "${expression}partial"); assertThrows(Exception.class, () -> config.getValue("my.prop", String.class)); assertThrows(Exception.class, () -> config.getValue("my.prop.partial", String.class)); }