1
1
package com .fasterxml .jackson .failing ;
2
2
3
+ import com .fasterxml .jackson .annotation .JsonBackReference ;
4
+ import com .fasterxml .jackson .annotation .JsonManagedReference ;
5
+ import com .fasterxml .jackson .databind .ObjectMapper ;
6
+ import com .fasterxml .jackson .databind .testutil .DatabindTestUtil ;
7
+ import org .junit .jupiter .api .Test ;
8
+
3
9
import java .beans .ConstructorProperties ;
4
10
5
- import com .fasterxml .jackson .annotation .*;
11
+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
12
+ import static org .junit .jupiter .api .Assertions .assertSame ;
6
13
7
- import com .fasterxml .jackson .databind .BaseMapTest ;
8
- import com .fasterxml .jackson .databind .ObjectMapper ;
9
-
10
- public class BackReference1516Test extends BaseMapTest
11
- {
14
+ class BackReference1516Test extends DatabindTestUtil {
12
15
static class ParentWithCreator {
13
16
String id , name ;
14
17
15
18
@ JsonManagedReference
16
19
ChildObject1 child ;
17
20
18
- @ ConstructorProperties ({ "id" , "name" , "child" })
21
+ @ ConstructorProperties ({"id" , "name" , "child" })
19
22
public ParentWithCreator (String id , String name ,
20
- ChildObject1 child ) {
23
+ ChildObject1 child ) {
21
24
this .id = id ;
22
25
this .name = name ;
23
26
this .child = child ;
24
27
}
25
28
}
26
29
27
- static class ChildObject1
28
- {
30
+ static class ChildObject1 {
29
31
public String id , name ;
30
32
31
33
@ JsonBackReference
32
34
public ParentWithCreator parent ;
33
35
34
- @ ConstructorProperties ({ "id" , "name" , "parent" })
36
+ @ ConstructorProperties ({"id" , "name" , "parent" })
35
37
public ChildObject1 (String id , String name ,
36
- ParentWithCreator parent ) {
38
+ ParentWithCreator parent ) {
37
39
this .id = id ;
38
40
this .name = name ;
39
41
this .parent = parent ;
@@ -47,47 +49,40 @@ static class ParentWithoutCreator {
47
49
public ChildObject2 child ;
48
50
}
49
51
50
- static class ChildObject2
51
- {
52
+ static class ChildObject2 {
52
53
public String id , name ;
53
54
54
55
@ JsonBackReference
55
56
public ParentWithoutCreator parent ;
56
57
57
- @ ConstructorProperties ({ "id" , "name" , "parent" })
58
+ @ ConstructorProperties ({"id" , "name" , "parent" })
58
59
public ChildObject2 (String id , String name ,
59
- ParentWithoutCreator parent ) {
60
+ ParentWithoutCreator parent ) {
60
61
this .id = id ;
61
62
this .name = name ;
62
63
this .parent = parent ;
63
64
}
64
65
}
65
66
66
- /*
67
- /**********************************************************
68
- /* Test methods
69
- /**********************************************************
70
- */
71
-
72
67
private final ObjectMapper MAPPER = newJsonMapper ();
73
68
74
69
private final String PARENT_CHILD_JSON = a2q (
75
- "{ 'id': 'abc',\n " +
76
- " 'name': 'Bob',\n " +
77
- " 'child': { 'id': 'def', 'name':'Bert' }\n " +
78
- "}" );
70
+ "{ 'id': 'abc',\n " +
71
+ " 'name': 'Bob',\n " +
72
+ " 'child': { 'id': 'def', 'name':'Bert' }\n " +
73
+ "}" );
79
74
80
- public void testWithParentCreator () throws Exception
81
- {
75
+ @ Test
76
+ void withParentCreator () throws Exception {
82
77
ParentWithCreator result = MAPPER .readValue (PARENT_CHILD_JSON ,
83
78
ParentWithCreator .class );
84
79
assertNotNull (result );
85
80
assertNotNull (result .child );
86
81
assertSame (result , result .child .parent );
87
82
}
88
83
89
- public void testWithParentNoCreator () throws Exception
90
- {
84
+ @ Test
85
+ void withParentNoCreator () throws Exception {
91
86
ParentWithoutCreator result = MAPPER .readValue (PARENT_CHILD_JSON ,
92
87
ParentWithoutCreator .class );
93
88
assertNotNull (result );
0 commit comments