@@ -20,13 +20,16 @@ public void testJackson() throws JsonProcessingException {
2020 final TestObjectA testObjectA = new TestObjectA ();
2121 final TestObjectB testObjectB = new TestObjectB ();
2222 final TestObjectC <String > testObjectC = new TestObjectC <>("valueC" );
23+ final TestObjectD testObjectD = new TestObjectD ();
2324 final Wrapper wrapper = new Wrapper ();
2425 wrapper .testObjectA1 = testObjectA ;
2526 wrapper .testObjectA2 = testObjectA ;
2627 wrapper .testObjectB1 = testObjectB ;
2728 wrapper .testObjectB2 = testObjectB ;
2829 wrapper .testObjectC1 = testObjectC ;
2930 wrapper .testObjectC2 = testObjectC ;
31+ wrapper .testObjectD1 = testObjectD ;
32+ wrapper .testObjectD2 = testObjectD ;
3033 final ObjectMapper objectMapper = Utils .getObjectMapper ();
3134 objectMapper .enable (SerializationFeature .INDENT_OUTPUT );
3235 final String json = objectMapper .writeValueAsString (wrapper );
@@ -35,7 +38,9 @@ public void testJackson() throws JsonProcessingException {
3538 Assert .assertTrue (json .contains ("\" testObjectB1\" : {" ));
3639 Assert .assertTrue (json .contains ("\" testObjectB2\" : \" id2\" " ));
3740 Assert .assertTrue (json .contains ("\" testObjectC1\" : {" ));
38- Assert .assertTrue (json .contains ("\" testObjectC2\" : \" id2\" " ));
41+ Assert .assertTrue (json .contains ("\" testObjectC2\" : \" id3\" " ));
42+ Assert .assertTrue (json .contains ("\" testObjectD1\" : \" id4\" " ));
43+ Assert .assertTrue (json .contains ("\" testObjectD2\" : \" id4\" " ));
3944 }
4045
4146 @ Test
@@ -45,9 +50,11 @@ public void test() {
4550 Assert .assertTrue (output .contains ("testObjectA1: string" ));
4651 Assert .assertTrue (output .contains ("testObjectB1: TestObjectB | string" ));
4752 Assert .assertTrue (output .contains ("testObjectC1: TestObjectC<string> | string" ));
53+ Assert .assertTrue (output .contains ("testObjectD1: string" ));
4854 Assert .assertTrue (!output .contains ("interface TestObjectA" ));
4955 Assert .assertTrue (output .contains ("interface TestObjectB" ));
5056 Assert .assertTrue (output .contains ("interface TestObjectC<T>" ));
57+ Assert .assertTrue (!output .contains ("interface TestObjectD" ));
5158 }
5259
5360 @ JsonIdentityInfo (generator = ObjectIdGenerators .PropertyGenerator .class , property = "@@@id" )
@@ -73,7 +80,7 @@ private static class TestObjectB {
7380 private static class TestObjectC <T > {
7481
7582 @ JsonProperty ("@@@id" )
76- public String myIdentification = "id2 " ;
83+ public String myIdentification = "id3 " ;
7784
7885 public T myProperty ;
7986
@@ -82,13 +89,24 @@ public TestObjectC(T myProperty) {
8289 }
8390 }
8491
92+ @ JsonIdentityInfo (generator = ObjectIdGenerators .PropertyGenerator .class , property = "@@@id" )
93+ private static class TestObjectD {
94+
95+ @ JsonProperty ("@@@id" )
96+ public String myIdentification = "id4" ;
97+
98+ public String myProperty = "valueD" ;
99+ }
100+
85101 private static class Wrapper {
86102 public TestObjectA testObjectA1 ;
87103 public TestObjectA testObjectA2 ;
88104 public TestObjectB testObjectB1 ;
89105 public TestObjectB testObjectB2 ;
90106 public TestObjectC <String > testObjectC1 ;
91107 public TestObjectC <String > testObjectC2 ;
108+ public @ JsonIdentityReference (alwaysAsId = true ) TestObjectD testObjectD1 ;
109+ public @ JsonIdentityReference (alwaysAsId = true ) TestObjectD testObjectD2 ;
92110 }
93111
94112}
0 commit comments