Skip to content

Commit 7ad860a

Browse files
committed
add failing test for #639
1 parent 2adc987 commit 7ad860a

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import com.fasterxml.jackson.annotation.*;
4+
import com.fasterxml.jackson.databind.*;
5+
6+
public class ObjectIdWithInjectable639Test extends BaseMapTest
7+
{
8+
// for [databind#639]
9+
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class)
10+
public static final class Parent2 {
11+
@JsonProperty
12+
public Child2 child;
13+
14+
@JsonCreator
15+
public Parent2(@JacksonInject("context") String context) {
16+
}
17+
}
18+
19+
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class)
20+
public static final class Child2 {
21+
@JsonProperty
22+
private final Parent2 parent;
23+
24+
@JsonCreator
25+
public Child2(@JsonProperty("parent") Parent2 parent) {
26+
this.parent = parent;
27+
}
28+
}
29+
30+
// for [databind#639]
31+
public void testObjectIdWithInjectable() throws Exception
32+
{
33+
ObjectMapper mapper = new ObjectMapper()
34+
.setInjectableValues(new InjectableValues.Std().
35+
addValue("context", "Stuff"));
36+
Parent2 parent2 = new Parent2("foo");
37+
Child2 child2 = new Child2(parent2);
38+
parent2.child = child2;
39+
40+
String json2 = mapper.writeValueAsString(parent2);
41+
parent2 = mapper.readValue(json2, Parent2.class);
42+
assertNotNull(parent2);
43+
assertNotNull(parent2.child);
44+
}
45+
}

0 commit comments

Comments
 (0)