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 Parent2(@acksonInject"context") String context)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 Child2(@sonProperty"parent") Parent2 parent)25 public Child2(@JsonProperty("parent") Parent2 parent) { 26 this.parent = parent; 27 } 28 } 29 30 // for [databind#639] testObjectIdWithInjectable()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 } 46