Skip to content

Commit c68e30e

Browse files
committed
Minor addition to #4628 test
1 parent 1af5bed commit c68e30e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/test-jdk17/java/com/fasterxml/jackson/databind/tofix/RecordWIthJsonIgnoreAndValue4628Test.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.junit.jupiter.api.Test;
99

1010
import static org.junit.jupiter.api.Assertions.assertEquals;
11+
import static org.junit.jupiter.api.Assertions.assertNull;
1112

1213
// [databind#4628] @JsonIgnore is ignored with read access
1314
public class RecordWIthJsonIgnoreAndValue4628Test
@@ -19,6 +20,13 @@ record RecordWithIgnoreJsonProperty(int id, @JsonIgnore @JsonProperty("name") St
1920
record RecordWithIgnoreJsonPropertyDifferentName(int id, @JsonIgnore @JsonProperty("name2") String name) {
2021
}
2122

23+
static class Pojo4628 {
24+
public int id;
25+
@JsonIgnore @JsonProperty("name") public String name;
26+
27+
public Pojo4628() { }
28+
}
29+
2230
private final ObjectMapper MAPPER = newJsonMapper();
2331

2432

@@ -36,4 +44,12 @@ public void testDeserializeJsonIgnoreAndJsonPropertyRecord() throws Exception {
3644
assertEquals(new RecordWithIgnoreJsonProperty(123, null), value); // should be null, actual "bob"
3745
}
3846

47+
// But second case works for POJOs
48+
49+
@Test
50+
public void deserializeJsonIgnoreAndJsonPropertyPojo() throws Exception {
51+
Pojo4628 value = MAPPER.readValue("{\"id\":123,\"name\":\"Bob\"}", Pojo4628.class);
52+
assertEquals(123, value.id);
53+
assertNull(value.name);
54+
}
3955
}

0 commit comments

Comments
 (0)