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.
test : Add failing test wrt FasterXML#3355
- Loading branch information
1 parent
2df0d23
commit 757e639
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
...com/fasterxml/jackson/databind/tofix/DeserializationWithCreatorPropertyOrder3355Test.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,75 @@ | ||
package com.fasterxml.jackson.databind.tofix; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil; | ||
import com.fasterxml.jackson.databind.testutil.failure.JacksonTestFailureExpected; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class DeserializationWithCreatorPropertyOrder3355Test | ||
extends DatabindTestUtil { | ||
|
||
public static class Common3355 { | ||
private final String property; | ||
private final ContainerFail3355 container; | ||
|
||
@JsonCreator | ||
public Common3355(@JsonProperty("property") final String property, | ||
@JsonProperty("container") final ContainerFail3355 container) { | ||
this.property = property; | ||
this.container = container; | ||
} | ||
|
||
public String getProperty() { | ||
return property; | ||
} | ||
|
||
public ContainerFail3355 getContainer() { | ||
return container; | ||
} | ||
} | ||
|
||
public static class ContainerFail3355 { | ||
private final Common3355 common; | ||
|
||
@JsonCreator | ||
public ContainerFail3355(@JsonProperty("common") final Common3355 common) { | ||
this.common = common; | ||
} | ||
|
||
@JsonIgnoreProperties("container") | ||
public Common3355 getCommon() { | ||
return common; | ||
} | ||
} | ||
|
||
@JacksonTestFailureExpected | ||
@Test | ||
public void testDeserFailing() throws Exception { | ||
final String objectJson = "{ \"property\": \"valueOne\" }"; | ||
final String containersJson = "{ \"common\": { \"property\": \"valueTwo\" } }"; | ||
|
||
final ObjectMapper objectMapper = newJsonMapper(); | ||
|
||
// If we deserialize inner object first, outer object FAILS | ||
final Common3355 object = objectMapper.readValue(objectJson, Common3355.class); | ||
final ContainerFail3355 container = objectMapper.readValue(containersJson, ContainerFail3355.class); | ||
System.out.println(); | ||
} | ||
|
||
@Test | ||
public void testDeserPassing() throws Exception { | ||
final String objectJson = "{ \"property\": \"valueOne\" }"; | ||
final String containersJson = "{ \"common\": { \"property\": \"valueTwo\" } }"; | ||
|
||
final ObjectMapper objectMapper = newJsonMapper(); | ||
|
||
// If we deserialize outer object first, it WORKS | ||
final ContainerFail3355 container = objectMapper.readValue(containersJson, ContainerFail3355.class); | ||
final Common3355 object = objectMapper.readValue(objectJson, Common3355.class); | ||
System.out.println(); | ||
} | ||
|
||
} |