1 package com.fasterxml.jackson.databind.objectid; 2 3 import com.fasterxml.jackson.annotation.*; 4 5 import com.fasterxml.jackson.databind.*; 6 7 public class TestObjectIdWithInjectables538 extends BaseMapTest 8 { 9 @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) 10 public static class A { 11 public B b; 12 A(@acksonInject"i1") String injected)13 public A(@JacksonInject("i1") String injected) { 14 } 15 } 16 17 @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) 18 public static class B { 19 public A a; 20 21 @JsonCreator B(@acksonInject"i2") String injected)22 public B(@JacksonInject("i2") String injected) { 23 } 24 } 25 26 /* 27 /***************************************************** 28 /* Test methods 29 /***************************************************** 30 */ 31 32 private final ObjectMapper MAPPER = new ObjectMapper(); 33 testWithInjectables538()34 public void testWithInjectables538() throws Exception 35 { 36 A a = new A("a"); 37 B b = new B("b"); 38 a.b = b; 39 b.a = a; 40 41 String json = MAPPER.writeValueAsString(a); 42 43 InjectableValues.Std inject = new InjectableValues.Std(); 44 inject.addValue("i1", "e1"); 45 inject.addValue("i2", "e2"); 46 A output = null; 47 48 try { 49 output = MAPPER.reader(inject).forType(A.class).readValue(json); 50 } catch (Exception e) { 51 throw new IllegalStateException("Failed to deserialize from JSON '"+json+"'", e); 52 } 53 assertNotNull(output); 54 assertNotNull(output.b); 55 assertSame(output, output.b.a); 56 } 57 } 58 59