53
53
import static org .hamcrest .MatcherAssert .assertThat ;
54
54
import static org .hamcrest .core .Is .is ;
55
55
import static org .junit .Assert .assertEquals ;
56
+ import static org .junit .Assert .assertNotNull ;
56
57
import static org .onosproject .yang .serializers .utils .SerializersUtil .convertRidToUri ;
57
58
import static org .slf4j .LoggerFactory .getLogger ;
58
59
@@ -66,21 +67,20 @@ public class JsonSerializerTest {
66
67
private static YangSerializerContext context ;
67
68
private static YangSerializer jsonSerializer ;
68
69
69
- private static String outputIdTestJson = "{\" identity-test:con1\" :{" +
70
- "\" interface\" :\" identity-types:physical\" ,\" interfaces\" :{" +
71
- "\" int-list\" :[{\" iden\" :\" identity-types-second:virtual\" ," +
72
- "\" available\" :{\" ll\" :[\" identity-types:Loopback\" ," +
73
- "\" identity-test:Giga\" ,\" identity-types-second:Ethernet\" ]}}," +
74
- "{\" iden\" :\" optical\" ,\" available\" :{\" ll\" :[\" Giga\" ]}}]}}}" ;
75
-
76
- private static String outputIdTestJson1 = "{\" jsonlist:c2\" :{\" leaflist1" +
77
- "\" :[\" a\" ,\" b\" ,\" c\" ],\" leaf1\" :1,\" leaf2\" :2,\" leaf3\" :3," +
78
- "\" leaf4\" :4,\" leaf5\" :5,\" leaf6\" :6,\" leaf7\" :\" 7\" ,\" leaf8\" " +
79
- ":\" 8\" ,\" leaf9\" :true,\" leaf10\" :\" -922337203685477580.8\" " +
80
- ",\" ll1\" :[1,10],\" ll2\" :[2,20],\" ll3\" :[3,30],\" ll4\" :[4,40],\" " +
81
- "ll5\" :[5,50],\" ll6\" :[6,60],\" ll7\" :[\" 7\" ,\" 70\" ],\" ll8\" :[\" " +
82
- "8\" ,\" 80\" ],\" ll9\" :[true,false],\" ll10\" :[" +
83
- "\" -922337203685477580.8\" ,\" -922337203685477480.8\" ]}}" ;
70
+ private static String outputIdTestJson = "{\" identity-test:con1\" :" +
71
+ "{\" interface\" :\" identity-types:physical\" ,\" interfaces\" :" +
72
+ "{\" int-list\" :[{\" available\" :{\" ll\" :[\" identity-types:Loopback\" ," +
73
+ "\" identity-test:Giga\" ,\" identity-types-second:Ethernet\" ]}," +
74
+ "\" iden\" :\" identity-types-second:virtual\" },{\" available\" :{" +
75
+ "\" ll\" :[\" Giga\" ]},\" iden\" :\" optical\" }]}}}" ;
76
+
77
+ private static String outputIdTestJson1 = "{\" jsonlist:c2\" :{\" leaf1\" :1,\" " +
78
+ "leaf10\" :\" -922337203685477580.8\" ,\" leaf2\" :2,\" leaf3\" :3," +
79
+ "\" leaf4\" :4,\" leaf5\" :5,\" leaf6\" :6,\" leaf7\" :\" 7\" ," +
80
+ "\" leaf8\" :\" 8\" ,\" leaf9\" :true,\" leaflist1\" :[\" a\" ,\" b\" ,\" c\" ]," +
81
+ "\" ll1\" :[1,10],\" ll10\" :[\" -922337203685477580.8\" ,\" -922337203685477480.8\" ]," +
82
+ "\" ll2\" :[2,20],\" ll3\" :[3,30],\" ll4\" :[4,40],\" ll5\" :[5,50],\" ll6\" :[6,60]," +
83
+ "\" ll7\" :[\" 7\" ,\" 70\" ],\" ll8\" :[\" 8\" ,\" 80\" ],\" ll9\" :[true,false]}}" ;
84
84
@ Rule
85
85
public ExpectedException thrown = ExpectedException .none ();
86
86
@@ -112,12 +112,8 @@ public void demo1Test() throws IOException {
112
112
InputStream inputStreamOutput = compositeStreamOutPut .resourceData ();
113
113
ObjectNode rootNodeOutput ;
114
114
ObjectMapper mapper = new ObjectMapper ();
115
- try {
116
- rootNodeOutput = (ObjectNode ) mapper .readTree (inputStreamOutput );
117
- assertEquals (true , rootNodeOutput != null );
118
- } catch (IOException e ) {
119
- throw e ;
120
- }
115
+ rootNodeOutput = (ObjectNode ) mapper .readTree (inputStreamOutput );
116
+ assertNotNull (rootNodeOutput );
121
117
}
122
118
123
119
@ Test
@@ -148,12 +144,8 @@ public void colonTest() throws IOException {
148
144
InputStream inputStreamOutput = compositeStreamOutPut .resourceData ();
149
145
ObjectNode rootNodeOutput ;
150
146
ObjectMapper mapper = new ObjectMapper ();
151
- try {
152
- rootNodeOutput = (ObjectNode ) mapper .readTree (inputStreamOutput );
153
- assertEquals (true , rootNodeOutput != null );
154
- } catch (IOException e ) {
155
- throw e ;
156
- }
147
+ rootNodeOutput = (ObjectNode ) mapper .readTree (inputStreamOutput );
148
+ assertNotNull (rootNodeOutput );
157
149
}
158
150
159
151
@ Test
@@ -184,12 +176,8 @@ public void jsonListTest() throws IOException {
184
176
InputStream inputStreamOutput = compositeStreamOutPut .resourceData ();
185
177
ObjectNode rootNodeOutput ;
186
178
ObjectMapper mapper = new ObjectMapper ();
187
- try {
188
- rootNodeOutput = (ObjectNode ) mapper .readTree (inputStreamOutput );
189
- assertEquals (rootNodeOutput .toString (), outputIdTestJson1 );
190
- } catch (IOException e ) {
191
- throw e ;
192
- }
179
+ rootNodeOutput = (ObjectNode ) mapper .readTree (inputStreamOutput );
180
+ assertEquals (rootNodeOutput .toString (), outputIdTestJson1 );
193
181
}
194
182
195
183
@ Test
@@ -220,16 +208,12 @@ public void identityValueNsTest() throws IOException {
220
208
InputStream inputStreamOutput = compositeStreamOutPut .resourceData ();
221
209
ObjectNode rootNodeOutput ;
222
210
ObjectMapper mapper = new ObjectMapper ();
223
- try {
224
- rootNodeOutput = (ObjectNode ) mapper .readTree (inputStreamOutput );
225
- assertEquals (rootNodeOutput .toString (), outputIdTestJson );
226
- } catch (IOException e ) {
227
- throw e ;
228
- }
211
+ rootNodeOutput = (ObjectNode ) mapper .readTree (inputStreamOutput );
212
+ assertEquals (rootNodeOutput .toString (), outputIdTestJson );
229
213
}
230
214
231
215
@ Test
232
- public void identityValueNsErrorTest () throws IOException {
216
+ public void identityValueNsErrorTest () {
233
217
thrown .expect (IllegalArgumentException .class );
234
218
thrown .expectMessage ("Invalid input for value namespace" );
235
219
String path = "src/test/resources/id-test2.json" ;
0 commit comments