Skip to content

Commit

Permalink
Add tests for map keys with quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Aug 10, 2023
1 parent a80ebf0 commit f318ddb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2288,4 +2288,23 @@ public String convert(final String value) throws IllegalArgumentException, NullP
return value.trim();
}
}

@Test
void mapKeyQuotes() {
SmallRyeConfig config = new SmallRyeConfigBuilder()
.withMapping(MapKeyQuotes.class)
// TODO - Default Values does not properly sypport quoted keys due to how NameIterator works
.withSources(config("map.values.\"key.quoted\"", "1234",
"map.values.key.\"quoted\"", "1234"))
.build();

MapKeyQuotes mapping = config.getConfigMapping(MapKeyQuotes.class);
assertEquals("1234", mapping.values().get("key.quoted"));
assertEquals("1234", mapping.values().get("key.\"quoted\""));
}

@ConfigMapping(prefix = "map")
interface MapKeyQuotes {
Map<String, String> values();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,14 @@ void previous() {
nameIterator.previous();
assertEquals("foo", nameIterator.getNextSegment());
}

@Test
void quotes() {
NameIterator nameIterator = new NameIterator("one.\"two.three\".four");
assertEquals("one", nameIterator.getNextSegment());
nameIterator.next();
assertEquals("two.three", nameIterator.getNextSegment());
nameIterator.next();
assertEquals("four", nameIterator.getNextSegment());
}
}

0 comments on commit f318ddb

Please sign in to comment.