-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/test/java/tools/jackson/databind/deser/merge/CustomMapMerge4922Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package tools.jackson.databind.deser.merge; | ||
|
||
import java.util.*; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.fasterxml.jackson.annotation.JsonMerge; | ||
|
||
import tools.jackson.databind.ObjectMapper; | ||
import tools.jackson.databind.testutil.DatabindTestUtil; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@SuppressWarnings("serial") | ||
public class CustomMapMerge4922Test | ||
extends DatabindTestUtil | ||
{ | ||
// [databind#4922] | ||
interface MyMap4922<K, V> extends Map<K, V> {} | ||
|
||
static class MapImpl<K, V> extends HashMap<K, V> implements MyMap4922<K, V> {} | ||
|
||
static class MergeMap4922 { | ||
@JsonMerge // either here | ||
public MyMap4922<Integer, String> map = new MapImpl<>(); | ||
} | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
// [databind#4922]: Merge for custom maps fails | ||
@Test | ||
void testJDKMapperReading() throws Exception { | ||
MergeMap4922 input = new MergeMap4922(); | ||
input.map.put(3, "ADS"); | ||
|
||
String json = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(input); | ||
MergeMap4922 merge2 = MAPPER.readValue(json, MergeMap4922.class); | ||
assertNotNull(merge2); | ||
} | ||
|
||
} |