Skip to content

Commit 42cdeb1

Browse files
committed
Add failing test for #1217 (from patch #1219)
1 parent fb96109 commit 42cdeb1

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.databind.BaseMapTest;
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
7+
public class IgnorePropertyOnDeser1217Test extends BaseMapTest
8+
{
9+
static class IgnoreObject {
10+
public int x = 1;
11+
public int y = 2;
12+
}
13+
14+
final static class TestIgnoreObject {
15+
@JsonIgnoreProperties({ "x" })
16+
public IgnoreObject obj;
17+
18+
@JsonIgnoreProperties({ "y" })
19+
public IgnoreObject obj2;
20+
}
21+
22+
private final ObjectMapper MAPPER = new ObjectMapper();
23+
24+
public void testIgnoreOnProperty() throws Exception
25+
{
26+
TestIgnoreObject result = MAPPER.readValue(
27+
aposToQuotes("{'obj':{'x': 10, 'y': 20}, 'obj2':{'x': 10, 'y': 20}}"),
28+
TestIgnoreObject.class);
29+
assertEquals(20, result.obj.y);
30+
assertEquals(10, result.obj2.x);
31+
32+
assertEquals(1, result.obj.x);
33+
assertEquals(2, result.obj2.y);
34+
35+
TestIgnoreObject result1 = MAPPER.readValue(
36+
aposToQuotes("{'obj':{'x': 20, 'y': 30}, 'obj2':{'x': 20, 'y': 40}}"),
37+
TestIgnoreObject.class);
38+
assertEquals(1, result1.obj.x);
39+
assertEquals(30, result1.obj.y);
40+
41+
assertEquals(20, result1.obj2.x);
42+
assertEquals(2, result1.obj2.y);
43+
}
44+
}

0 commit comments

Comments
 (0)