|
1 | 1 | package com.fasterxml.jackson.databind.views; |
2 | 2 |
|
3 | | -import static com.fasterxml.jackson.databind.BaseMapTest.newJsonMapper; |
4 | | -import static org.junit.Assert.assertEquals; |
5 | 3 | import com.fasterxml.jackson.annotation.*; |
| 4 | + |
| 5 | +import com.fasterxml.jackson.databind.BaseMapTest; |
6 | 6 | import com.fasterxml.jackson.databind.ObjectMapper; |
7 | 7 | import com.fasterxml.jackson.databind.ObjectReader; |
8 | | -import org.junit.Test; |
9 | 8 |
|
10 | 9 | public class ViewsWithCreatorTest |
| 10 | + extends BaseMapTest |
11 | 11 | { |
12 | | - |
13 | | - public static class View { } |
14 | | - public static class View1 extends View { } |
15 | | - public static class View2 extends View { } |
| 12 | + static class View { } |
| 13 | + static class View1 extends View { } |
| 14 | + static class View2 extends View { } |
16 | 15 |
|
17 | 16 | @JsonAutoDetect( |
18 | 17 | fieldVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, |
@@ -72,25 +71,27 @@ public String toString() { |
72 | 71 | } |
73 | 72 | } |
74 | 73 |
|
75 | | - @Test |
76 | | - public void testWithJsonCreator() throws Exception { |
77 | | - ObjectMapper mapper = newJsonMapper(); |
78 | | - ObjectReader reader = mapper.readerFor(ObjWithCreator.class).withView(View1.class); |
| 74 | + private final ObjectMapper MAPPER = newJsonMapper(); |
| 75 | + |
| 76 | + // [databind#1172] |
| 77 | + public void testWithJsonCreator() throws Exception |
| 78 | + { |
| 79 | + ObjectReader reader = MAPPER.readerFor(ObjWithCreator.class).withView(View1.class); |
79 | 80 |
|
80 | 81 | // serialize first, |
81 | | - String JSON = mapper.writeValueAsString(new ObjWithCreator("a", "b", "c")); |
| 82 | + String json = MAPPER.writeValueAsString(new ObjWithCreator("a", "b", "c")); |
82 | 83 | // then back |
83 | | - assertEquals("a-b-null", reader.readValue(JSON).toString()); |
| 84 | + assertEquals("a-b-null", reader.readValue(json).toString()); |
84 | 85 | } |
85 | 86 |
|
86 | | - @Test |
87 | | - public void testWithoutJsonCreator() throws Exception { |
88 | | - ObjectMapper mapper = newJsonMapper(); |
89 | | - ObjectReader reader = mapper.readerFor(ObjWithoutCreator.class).withView(View1.class); |
| 87 | + // [databind#1172] |
| 88 | + public void testWithoutJsonCreator() throws Exception |
| 89 | + { |
| 90 | + ObjectReader reader = MAPPER.readerFor(ObjWithoutCreator.class).withView(View1.class); |
90 | 91 |
|
91 | 92 | // serialize first, |
92 | | - String JSON = mapper.writeValueAsString(new ObjWithoutCreator("a", "b", "c")); |
| 93 | + String json = MAPPER.writeValueAsString(new ObjWithoutCreator("a", "b", "c")); |
93 | 94 | // then back |
94 | | - assertEquals("a-b-null", reader.readValue(JSON).toString()); |
| 95 | + assertEquals("a-b-null", reader.readValue(json).toString()); |
95 | 96 | } |
96 | 97 | } |
0 commit comments