3
3
import java .util .Arrays ;
4
4
import java .util .List ;
5
5
6
- import org .junit .Test ;
7
-
8
6
import com .fasterxml .jackson .annotation .JsonInclude .Include ;
9
7
import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
10
8
import com .fasterxml .jackson .dataformat .xml .XmlTestBase ;
@@ -18,11 +16,11 @@ public class TestUnwrappedDeserIssue86 extends XmlTestBase
18
16
public static class Issue86 {
19
17
20
18
@ JacksonXmlProperty (localName = "id" , isAttribute = true )
21
- private String id ;
19
+ public String id ;
22
20
23
21
@ JacksonXmlElementWrapper (useWrapping = false )
24
22
@ JacksonXmlProperty (localName = "test" )
25
- private List <Issue86 > children ;
23
+ public List <Issue86 > children ;
26
24
27
25
public Issue86 () {}
28
26
@@ -33,20 +31,15 @@ public Issue86(final String id, final List<Issue86> children) {
33
31
34
32
@ Override
35
33
public boolean equals (final Object other ) {
36
- if (other == null ) {
37
- return false ;
38
- }
39
-
40
- if (other == this ) {
41
- return true ;
42
- }
34
+ if (other == this ) return true ;
35
+ if (other == null ) return false ;
43
36
44
- if (!(other instanceof Issue86 )) {
45
- return false ;
46
- }
37
+ if (!(other instanceof Issue86 )) {
38
+ return false ;
39
+ }
47
40
48
- final Issue86 otherIssue86 = (Issue86 ) other ;
49
- return otherIssue86 .id .equals (id ) && otherIssue86 .children .equals (children );
41
+ final Issue86 otherIssue86 = (Issue86 ) other ;
42
+ return otherIssue86 .id .equals (id ) && otherIssue86 .children .equals (children );
50
43
}
51
44
}
52
45
@@ -56,34 +49,34 @@ public boolean equals(final Object other) {
56
49
/***********************************************************************
57
50
*/
58
51
59
- @ Test
60
- public void deserializeUnwrappedListWhenLocalNameForRootElementAndXmlPropertyMatch () throws Exception {
61
- final String source =
62
- "<test id=\" 0\" >" +
63
- "<test id=\" 0.1\" >" +
64
- "<test id=\" 0.1.1\" />" +
65
- "</test>" +
66
- "<test id=\" 0.2\" />" +
67
- "<test id=\" 0.3\" >" +
68
- "<test id=\" 0.3.1\" />" +
69
- "</test>" +
70
- "</test>" ;
71
-
72
- final Issue86 before = new Issue86 ("0" ,
73
- Arrays .asList (new Issue86 ("0.1" ,
74
- Arrays .asList (new Issue86 ("0.1.1" , null ))),
75
- new Issue86 ("0.2" , null ),
76
- new Issue86 ("0.3" ,
77
- Arrays .asList (
78
- new Issue86 ("0.3.1" , null )))));
79
-
80
- final XmlMapper mapper = new XmlMapper ();
81
- mapper .setSerializationInclusion (Include .NON_NULL );
82
-
83
- final String xml = mapper .writeValueAsString (before );
84
- assertEquals (source , xml );
85
-
86
- final Issue86 after = mapper .readValue (xml , Issue86 .class );
87
- assertEquals (before , after );
88
- }
52
+ public void testDeserializeUnwrappedListWhenLocalNameForRootElementAndXmlPropertyMatch () throws Exception
53
+ {
54
+ final String source =
55
+ "<test id=\" 0\" >" +
56
+ "<test id=\" 0.1\" >" +
57
+ "<test id=\" 0.1.1\" />" +
58
+ "</test>" +
59
+ "<test id=\" 0.2\" />" +
60
+ "<test id=\" 0.3\" >" +
61
+ "<test id=\" 0.3.1\" />" +
62
+ "</test>" +
63
+ "</test>" ;
64
+
65
+ final Issue86 before = new Issue86 ("0" ,
66
+ Arrays .asList (new Issue86 ("0.1" ,
67
+ Arrays .asList (new Issue86 ("0.1.1" , null ))),
68
+ new Issue86 ("0.2" , null ),
69
+ new Issue86 ("0.3" ,
70
+ Arrays .asList (
71
+ new Issue86 ("0.3.1" , null )))));
72
+
73
+ final XmlMapper mapper = new XmlMapper ();
74
+ mapper .setSerializationInclusion (Include .NON_NULL );
75
+
76
+ final String xml = mapper .writeValueAsString (before );
77
+ assertEquals (source , xml );
78
+
79
+ final Issue86 after = mapper .readValue (xml , Issue86 .class );
80
+ assertEquals (before , after );
81
+ }
89
82
}
0 commit comments