Skip to content

Commit 3dd61ce

Browse files
committed
Add test for #1516; unfrtunately does not fail due to diffs to original where lombok generates constructors (I think)
1 parent 06af743 commit 3dd61ce

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import java.util.List;
4+
import java.util.UUID;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
8+
import com.fasterxml.jackson.databind.BaseMapTest;
9+
import com.fasterxml.jackson.databind.ObjectMapper;
10+
11+
public class BackReference1516Test extends BaseMapTest
12+
{
13+
@JsonIgnoreProperties(ignoreUnknown = true)
14+
static class ParentObject {
15+
public UUID id;
16+
public String productId;
17+
public String productName;
18+
public String companyName;
19+
public UUID companyLogoImageId;
20+
public String recordNumber;
21+
public String revisionNumber;
22+
public String jsonString;
23+
24+
// Test passes if @JsonManagedReference is removed.
25+
@JsonManagedReference
26+
public List<ChildObject> childSet;
27+
28+
public ParentObject() { }
29+
}
30+
31+
@JsonIgnoreProperties(ignoreUnknown = true)
32+
static class ChildObject
33+
{
34+
public UUID id;
35+
// Test passes if @JsonBackReference is removed.
36+
@JsonBackReference
37+
public ParentObject parentObject;
38+
public UUID componentId;
39+
public int orderNumber;
40+
public String orderLabel;
41+
public String title;
42+
43+
public ChildObject() { }
44+
}
45+
46+
/*
47+
/**********************************************************
48+
/* Unit tests
49+
/**********************************************************
50+
*/
51+
52+
private final ObjectMapper MAPPER = new ObjectMapper();
53+
54+
public void testIssue1516() throws Exception
55+
{
56+
ParentObject result = MAPPER.readValue(aposToQuotes(
57+
"{\n"+
58+
" 'companyName': 'My Famke Company',\n"+
59+
" 'companyLogoImageId': '29a8045e-3d10-4121-9f27-429aa74d00ad',\n"+
60+
" 'productId': 'ABC-0003',\n"+
61+
" 'productName': 'Engineering Test',\n"+
62+
" 'recordNumber': '01',\n"+
63+
" 'revisionNumber': '1.0',\n"+
64+
" 'procedureId': '6e6f607e-fb3f-4750-8a0a-2b38220e3328',\n"+
65+
" 'childSet': [ { 'title': 'Child 1',\n"+
66+
" 'componentId': '3f7debe1-cddc-4b66-b7a7-49249e0c9d3e',\n"+
67+
" 'orderLabel': '1',\n"+
68+
" 'orderNumber': 1\n"+
69+
" } ]\n"+
70+
"}"),
71+
ParentObject.class);
72+
assertNotNull(result);
73+
}
74+
}

0 commit comments

Comments
 (0)