|
12 | 12 | // Unit test for [JACKSON-890]
|
13 | 13 | public class TestBackRefsWithPolymorphic extends BaseMapTest
|
14 | 14 | {
|
15 |
| - private final String CLASS_NAME = getClass().getName(); |
16 |
| - |
17 |
| - // NOTE: order is arbitrary, test is fragile... has to work for now |
18 |
| - private final String JSON = |
19 |
| - "{\"@class\":\""+CLASS_NAME+"$PropertySheetImpl\",\"id\":0,\"properties\":{\"p1name\":{\"@class\":" |
20 |
| - +"\"" +CLASS_NAME+ "$StringPropertyImpl\",\"id\":0,\"name\":\"p1name\",\"value\":\"p1value\"}," |
21 |
| - +"\"p2name\":{\"@class\":\""+CLASS_NAME+"$StringPropertyImpl\",\"id\":0," |
22 |
| - +"\"name\":\"p2name\",\"value\":\"p2value\"}}}"; |
23 |
| - |
24 |
| - private final ObjectMapper MAPPER = new ObjectMapper(); |
25 |
| - |
26 |
| - public void testDeserialize() throws IOException |
27 |
| - { |
28 |
| - PropertySheet input = MAPPER.readValue(JSON, PropertySheet.class); |
29 |
| - assertEquals(JSON, MAPPER.writeValueAsString(input)); |
30 |
| - } |
31 |
| - |
32 |
| - public void testSerialize() throws IOException |
33 |
| - { |
34 |
| - PropertySheet sheet = new PropertySheetImpl(); |
35 |
| - |
36 |
| - sheet.addProperty(new StringPropertyImpl("p1name", "p1value")); |
37 |
| - sheet.addProperty(new StringPropertyImpl("p2name", "p2value")); |
38 |
| - String actual = MAPPER.writeValueAsString(sheet); |
39 |
| - assertEquals(JSON, actual); |
40 |
| - } |
41 |
| - |
42 | 15 | @JsonPropertyOrder(alphabetic=true)
|
43 | 16 | interface Entity
|
44 | 17 | {
|
@@ -217,4 +190,36 @@ public StringPropertyImpl(String name, String value) {
|
217 | 190 | }
|
218 | 191 |
|
219 | 192 | static class YetAnotherClass extends StringPropertyImpl { }
|
| 193 | + |
| 194 | + /* |
| 195 | + /********************************************************** |
| 196 | + /* Test methods |
| 197 | + /********************************************************** |
| 198 | + */ |
| 199 | + |
| 200 | + private final String CLASS_NAME = getClass().getName(); |
| 201 | + // NOTE: order is arbitrary, test is fragile... has to work for now |
| 202 | + private final String JSON = |
| 203 | + "{\"@class\":\""+CLASS_NAME+"$PropertySheetImpl\",\"id\":0,\"properties\":{\"p1name\":{\"@class\":" |
| 204 | + +"\"" +CLASS_NAME+ "$StringPropertyImpl\",\"id\":0,\"name\":\"p1name\",\"value\":\"p1value\"}," |
| 205 | + +"\"p2name\":{\"@class\":\""+CLASS_NAME+"$StringPropertyImpl\",\"id\":0," |
| 206 | + +"\"name\":\"p2name\",\"value\":\"p2value\"}}}"; |
| 207 | + |
| 208 | + private final ObjectMapper MAPPER = new ObjectMapper(); |
| 209 | + |
| 210 | + public void testDeserialize() throws IOException |
| 211 | + { |
| 212 | + PropertySheet input = MAPPER.readValue(JSON, PropertySheet.class); |
| 213 | + assertEquals(JSON, MAPPER.writeValueAsString(input)); |
| 214 | + } |
| 215 | + |
| 216 | + public void testSerialize() throws IOException |
| 217 | + { |
| 218 | + PropertySheet sheet = new PropertySheetImpl(); |
| 219 | + |
| 220 | + sheet.addProperty(new StringPropertyImpl("p1name", "p1value")); |
| 221 | + sheet.addProperty(new StringPropertyImpl("p2name", "p2value")); |
| 222 | + String actual = MAPPER.writeValueAsString(sheet); |
| 223 | + assertEquals(JSON, actual); |
| 224 | + } |
220 | 225 | }
|
0 commit comments