-
-
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.
- Loading branch information
1 parent
2adc987
commit 7ad860a
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/test/java/com/fasterxml/jackson/failing/ObjectIdWithInjectable639Test.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.failing; | ||
|
||
import com.fasterxml.jackson.annotation.*; | ||
import com.fasterxml.jackson.databind.*; | ||
|
||
public class ObjectIdWithInjectable639Test extends BaseMapTest | ||
{ | ||
// for [databind#639] | ||
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) | ||
public static final class Parent2 { | ||
@JsonProperty | ||
public Child2 child; | ||
|
||
@JsonCreator | ||
public Parent2(@JacksonInject("context") String context) { | ||
} | ||
} | ||
|
||
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) | ||
public static final class Child2 { | ||
@JsonProperty | ||
private final Parent2 parent; | ||
|
||
@JsonCreator | ||
public Child2(@JsonProperty("parent") Parent2 parent) { | ||
this.parent = parent; | ||
} | ||
} | ||
|
||
// for [databind#639] | ||
public void testObjectIdWithInjectable() throws Exception | ||
{ | ||
ObjectMapper mapper = new ObjectMapper() | ||
.setInjectableValues(new InjectableValues.Std(). | ||
addValue("context", "Stuff")); | ||
Parent2 parent2 = new Parent2("foo"); | ||
Child2 child2 = new Child2(parent2); | ||
parent2.child = child2; | ||
|
||
String json2 = mapper.writeValueAsString(parent2); | ||
parent2 = mapper.readValue(json2, Parent2.class); | ||
assertNotNull(parent2); | ||
assertNotNull(parent2.child); | ||
} | ||
} |