-
-
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.
Ignore Records' immutable fields in BeanDeserializerFactory instead o…
…f ignoring it in POJOPropertiesCollector, to preserve any annotation info the fields may be carrying. (#4627)
- Loading branch information
Showing
7 changed files
with
79 additions
and
18 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
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
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
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
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
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
45 changes: 45 additions & 0 deletions
45
...t-jdk17/java/com/fasterxml/jackson/databind/records/RecordWithOverriddenAccessorTest.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,45 @@ | ||
package com.fasterxml.jackson.databind.records; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonIncludeProperties; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class RecordWithOverriddenAccessorTest extends DatabindTestUtil { | ||
|
||
record Id2Name(int id, String name) { | ||
} | ||
|
||
record RecordWithJsonIncludeProperties(@JsonIncludeProperties("id") Id2Name child) { | ||
@Override | ||
public Id2Name child() { | ||
return child; | ||
} | ||
} | ||
|
||
record RecordWithJsonIgnoreProperties(@JsonIgnoreProperties("name") Id2Name child) { | ||
@Override | ||
public Id2Name child() { | ||
return child; | ||
} | ||
} | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
// [databind#4630] | ||
@Test | ||
public void testSerializeJsonIncludeProperties() throws Exception { | ||
String json = MAPPER.writeValueAsString(new RecordWithJsonIncludeProperties(new Id2Name(123, "Bob"))); | ||
assertEquals(a2q("{'child':{'id':123}}"), json); | ||
} | ||
|
||
// [databind#4630] | ||
@Test | ||
public void testSerializeJsonIgnoreProperties() throws Exception { | ||
String json = MAPPER.writeValueAsString(new RecordWithJsonIgnoreProperties(new Id2Name(123, "Bob"))); | ||
assertEquals(a2q("{'child':{'id':123}}"), json); | ||
} | ||
} |