Add test to verify map keys retain order when mapped.
See: #4577 Original pull request: #4568
This commit is contained in:
committed by
Mark Paluch
parent
3dccdd2bc2
commit
6a7c4fc17c
@@ -28,6 +28,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.bson.conversions.Bson;
|
||||
import org.bson.types.Code;
|
||||
@@ -1517,6 +1518,20 @@ public class QueryMapperUnitTests {
|
||||
assertThat(mappedObject).isEqualTo("{ 'field.name.with.dots' : 'A' }");
|
||||
}
|
||||
|
||||
@Test // GH-4577
|
||||
void mappingShouldRetainMapKeyOrder() {
|
||||
|
||||
TreeMap<String, String> sourceMap = new TreeMap<>(Map.of("test1", "123", "test2", "456"));
|
||||
|
||||
org.bson.Document target = mapper.getMappedObject(query(where("simpleMap").is(sourceMap)).getQueryObject(),
|
||||
context.getPersistentEntity(WithSimpleMap.class));
|
||||
assertThat(target.get("simpleMap", Map.class)).containsExactlyEntriesOf(sourceMap);
|
||||
}
|
||||
|
||||
class WithSimpleMap {
|
||||
Map<String, String> simpleMap;
|
||||
}
|
||||
|
||||
class WithDeepArrayNesting {
|
||||
|
||||
List<WithNestedArray> level0;
|
||||
|
||||
Reference in New Issue
Block a user