Skip to content

Commit e984a98

Browse files
authored
Add failing test (reproduction) for #562 (#4347)
1 parent 62aac6b commit e984a98

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import java.util.Collections;
4+
import java.util.Map;
5+
6+
import org.junit.jupiter.api.Test;
7+
8+
import com.fasterxml.jackson.annotation.*;
9+
10+
import com.fasterxml.jackson.databind.*;
11+
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
12+
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
15+
public class AnySetterForCreator562Test extends DatabindTestUtil
16+
{
17+
// [databind#562]
18+
static class POJO562
19+
{
20+
String a;
21+
22+
Map<String,Object> stuff;
23+
24+
@JsonCreator
25+
public POJO562(@JsonProperty("a") String a,
26+
@JsonAnySetter Map<String, Object>
27+
leftovers) {
28+
this.a = a;
29+
stuff = leftovers;
30+
}
31+
}
32+
33+
private final ObjectMapper MAPPER = newJsonMapper();
34+
35+
// [databind#562]
36+
@Test
37+
public void testAnySetterViaCreator562() throws Exception
38+
{
39+
POJO562 pojo = MAPPER.readValue(a2q(
40+
"{'a':'value', 'b':42}"
41+
),
42+
POJO562.class);
43+
assertEquals(pojo.a, "value");
44+
assertEquals(Collections.singletonMap("b", Integer.valueOf(42)),
45+
pojo.stuff);
46+
}
47+
}

0 commit comments

Comments
 (0)