-
-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
d8857c1
commit aafba87
Showing
5 changed files
with
86 additions
and
8 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
45 changes: 45 additions & 0 deletions
45
...dk17/java/com/fasterxml/jackson/databind/records/RecordWithOverriddenInclude4630Test.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 RecordWithOverriddenInclude4630Test 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); | ||
} | ||
} |