diff --git a/implementation/src/test/java/io/smallrye/config/ConfigMappingInterfaceTest.java b/implementation/src/test/java/io/smallrye/config/ConfigMappingInterfaceTest.java index 92861cd2e..4513331b2 100644 --- a/implementation/src/test/java/io/smallrye/config/ConfigMappingInterfaceTest.java +++ b/implementation/src/test/java/io/smallrye/config/ConfigMappingInterfaceTest.java @@ -2659,4 +2659,28 @@ interface Nested { String value(); } } + + @Test + void optionalMapValue() { + SmallRyeConfig config = new SmallRyeConfigBuilder() + .withSources(config("map.map.key", "value", "map.map.empty", "")) + .withMapping(OptionalMapValue.class) + .build(); + + OptionalMapValue mapping = config.getConfigMapping(OptionalMapValue.class); + assertTrue(mapping.map().get("key").value().isPresent()); + assertEquals("value", mapping.map().get("key").value().get()); + assertTrue(mapping.map().containsKey("empty")); + assertFalse(mapping.map().get("empty").value().isPresent()); + } + + @ConfigMapping(prefix = "map") + interface OptionalMapValue { + Map map(); + + interface Value { + @WithParentName + Optional value(); + } + } }