forked from FasterXML/jackson-databind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/2.16' into 2787-allow-mixins-f…
…or-enums
- Loading branch information
Showing
15 changed files
with
504 additions
and
21 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
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
23 changes: 23 additions & 0 deletions
23
...test-jdk14/java/com/fasterxml/jackson/databind/failing/RecordDeserialization3897Test.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,23 @@ | ||
package com.fasterxml.jackson.databind.failing; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
|
||
// [databinding#3897] This is failing test for `Record` class deserialization with single field annotated with | ||
// `JsonProperty.Access.WRITE_ONLY`. Regression from Jackson 2.14.2 | ||
public class RecordDeserialization3897Test extends BaseMapTest { | ||
|
||
record Example( | ||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY) | ||
String value | ||
) {} | ||
|
||
// Passes in 2.14.2, but does not in 2.15.0 | ||
public void testRecordWithWriteOnly() throws Exception { | ||
final String JSON = a2q("{'value':'foo'}"); | ||
|
||
Example result = newJsonMapper().readValue(JSON, Example.class); | ||
|
||
assertEquals("foo", result.value()); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...-jdk14/java/com/fasterxml/jackson/databind/records/RecordIgnoreNonAccessorGetterTest.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,54 @@ | ||
package com.fasterxml.jackson.databind.records; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.annotation.PropertyAccessor; | ||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
public class RecordIgnoreNonAccessorGetterTest extends BaseMapTest { | ||
|
||
// [databind#3628] | ||
interface InterfaceWithGetter { | ||
|
||
String getId(); | ||
|
||
String getName(); | ||
} | ||
|
||
@JsonPropertyOrder({"id", "name", "count"}) // easier to assert when JSON field ordering is always the same | ||
record RecordWithInterfaceWithGetter(String name) implements InterfaceWithGetter { | ||
|
||
@Override | ||
public String getId() { | ||
return "ID:" + name; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
// [databind#3895] | ||
public int getCount() { | ||
return 999; | ||
} | ||
} | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
public void testSerializeIgnoreInterfaceGetter_WithoutUsingVisibilityConfig() throws Exception { | ||
String json = MAPPER.writeValueAsString(new RecordWithInterfaceWithGetter("Bob")); | ||
|
||
assertEquals("{\"id\":\"ID:Bob\",\"name\":\"Bob\",\"count\":999}", json); | ||
} | ||
|
||
public void testSerializeIgnoreInterfaceGetter_UsingVisibilityConfig() throws Exception { | ||
MAPPER.setVisibility(PropertyAccessor.GETTER, Visibility.NONE); | ||
MAPPER.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); | ||
|
||
String json = MAPPER.writeValueAsString(new RecordWithInterfaceWithGetter("Bob")); | ||
|
||
assertEquals("{\"name\":\"Bob\"}", json); | ||
} | ||
} |
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
Oops, something went wrong.