Skip to content

Commit f9b40ec

Browse files
committed
Add test for shared path
Signed-off-by: John Mazanec <[email protected]>
1 parent dd48e98 commit f9b40ec

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

server/src/test/java/org/opensearch/common/xcontent/support/XContentMapValuesTests.java

+16
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,22 @@ public void testTransformInPlace() {
738738
assertEquals(expected, transformedMapped);
739739
}
740740

741+
public void testTransformSharedPaths() {
742+
Map<String, Object> mapToTransform = MapBuilder.<String, Object>newMapBuilder()
743+
.put("test", "value_before")
744+
.put("test.nested", "nested_value_before")
745+
.map();
746+
Map<String, Function<Object, Object>> transformers = Map.of("test", v -> "value_after", "test.nested", v -> "nested_value_after");
747+
748+
Map<String, Object> expected = MapBuilder.<String, Object>newMapBuilder()
749+
.put("test", "value_after")
750+
.put("test.nested", "nested_value_before")
751+
.immutableMap();
752+
753+
Map<String, Object> transformedMap = XContentMapValues.transform(mapToTransform, transformers, true);
754+
assertEquals(expected, transformedMap);
755+
}
756+
741757
private static Map<String, Object> toMap(Builder test, XContentType xContentType, boolean humanReadable) throws IOException {
742758
ToXContentObject toXContent = (builder, params) -> test.apply(builder);
743759
return convertToMap(toXContent(toXContent, xContentType, humanReadable), true, xContentType).v2();

0 commit comments

Comments
 (0)