2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.ccsdk.sli.plugins.yangserializers.dfserializer;
23 import static org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatUtilsTest.addSpace;
26 * Unit test case utilities for identifier validation and restconf api
29 public final class IdentifierValidationUtilsTest {
31 static final String ENCODE_TO_JSON_YANG_COMMON_ID = "\n " +
32 "\"test_augment_1_for_module:name_of_the_ll6\": [\n" +
36 " \"test_augment_1_for_module:name_of_the_cont13\": {\n" +
37 " \"name_of_the_cont12\": {\n" +
38 " \"name_of_the_leaf26\": \"abc\"\n" +
40 " \"name_of_the_ll9\": [\n" +
44 " \"name_of_the_leaf28\": \"abc\",\n" +
45 " \"name_of_the_list9\": [\n" +
47 " \"name_of_the_leaf27\": \"abc\"\n" +
50 " \"name_of_the_leaf27\": \"abc\"\n" +
54 " \"test_augment_1_for_module:name_of_the_list7\": [\n" +
56 " \"name_of_the_leaf14\": \"test\"\n" +
59 " \"name_of_the_leaf14\": \"create\"\n" +
62 " \"test_augment_1_for_module:name_of_the_leaf15\": \"abc\",\n" +
63 " \"test_augment_1_for_module:name_of_the_cont5\": {\n" +
64 " \"name_of_the_leaf13\": \"true\"\n" +
67 static final String ENCODE_TO_JSON_YANG_AUG_POST_ID = "{\n" +
68 " \"test_name_of_the_module:name_of_the_leaf10\": \"abc\"," +
69 ENCODE_TO_JSON_YANG_COMMON_ID + "\n}";
71 static final String ENCODE_TO_JSON_YANG_ID = "{\n" +
72 " \"test_name_of_the_module:name_of_the_cont2\": {\n" +
73 " \"name_of_the_ll4\": [\n" +
77 " \"name_of_the_leaf5\": \"abc\",\n" +
78 " \"name_of_the_list6\": [\n" +
80 " \"name_of_the_leaf11\": \"abc\"\n" +
83 " \"name_of_the_leaf11\": \"abc\"\n" +
86 " \"name_of_the_ll5\": [\n" +
90 " \"name_of_the_ll3\": [\n" +
94 " \"name_of_the_leaf6\": \"abc\",\n" +
95 " \"name_of_the_cont3\": {\n" +
96 " \"name_of_the_leaf10\": \"abc\"\n" +
98 " \"name_of_the_list2\": [\n" +
100 " \"name_of_the_leaf4\": \"abc\"\n" +
103 " \"name_of_the_leaf4\": \"abc\"\n" +
106 " \"name_of_the_list1\": [\n" +
108 " \"name_of_the_ll2\": [\n" +
112 " \"name_of_the_list5\": [\n" +
114 " \"name_of_the_leaf9\": \"abc\"\n" +
117 " \"name_of_the_leaf9\": \"abc\"\n" +
120 " \"name_of_the_list4\": [\n" +
122 " \"name_of_the_leaf8\": \"abc\"\n" +
125 " \"name_of_the_leaf8\": \"abc\"\n" +
128 " \"name_of_the_leaf1\": \"true\",\n" +
129 " \"name_of_the_leaf3\": \"abc\",\n" +
130 " \"name_of_the_leaf2\": \"abc\",\n" +
131 " \"name_of_the_cont4\": {\n" +
132 " \"name_of_the_leaf11\": \"abc\"\n" +
134 " \"name_of_the_ll1\": [\n" +
140 " \"name_of_the_ll2\": [\n" +
144 " \"name_of_the_list5\": [\n" +
146 " \"name_of_the_leaf9\": \"abc\"\n" +
149 " \"name_of_the_leaf9\": \"abc\"\n" +
152 " \"name_of_the_list4\": [\n" +
154 " \"name_of_the_leaf8\": \"abc\"\n" +
157 " \"name_of_the_leaf8\": \"abc\"\n" +
160 " \"name_of_the_leaf1\": \"true\",\n" +
161 " \"name_of_the_leaf3\": \"abc\",\n" +
162 " \"name_of_the_leaf2\": \"abc\",\n" +
163 " \"name_of_the_cont4\": {\n" +
164 " \"name_of_the_leaf11\": \"abc\"\n" +
166 " \"name_of_the_ll1\": [\n" +
172 " \"name_of_the_cont4\": {\n" +
173 " \"name_of_the_leaf10\": \"abc\"," +
174 addSpace(ENCODE_TO_JSON_YANG_COMMON_ID,8) + "\n" +
176 " \"name_of_the_leaf12\": \"abc\"\n" +
180 static final String ENCODE_TO_JSON_WITH_AUG_PATH = "{\n" +
181 " \"test_augment_1_for_module:name_of_the_leaf13\": \"true\"\n" +
184 static final String ENCODE_TO_JSON_YANG_PUT_ID = "{\n" +
185 " \"test_name_of_the_module:name_of_the_cont4\": {" + addSpace(
186 ENCODE_TO_JSON_YANG_COMMON_ID, 4) + ",\n" +
187 " \"name_of_the_leaf10\": \"abc\"\n" +
191 static final String ENCODE_TO_XML_YANG_COMMON_ID = "\n" +
192 "<name_of_the_ll6 xmlns=\"urn:opendaylight:params:xml:ns:yang:" +
193 "test:augment:name\">unbounded</name_of_the_ll6>\n" +
194 "<name_of_the_ll6 xmlns=\"urn:opendaylight:params:xml:ns:yang:" +
195 "test:augment:name\">8</name_of_the_ll6>\n" +
196 "<name_of_the_cont13 xmlns=\"urn:opendaylight:params:xml:ns:ya" +
197 "ng:test:augment:name\">\n" +
198 " <name_of_the_cont12>\n" +
199 " <name_of_the_leaf26>abc</name_of_the_leaf26>\n" +
200 " </name_of_the_cont12>\n" +
201 " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
202 " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
203 " <name_of_the_leaf28>abc</name_of_the_leaf28>\n" +
204 " <name_of_the_list9>\n" +
205 " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
206 " </name_of_the_list9>\n" +
207 " <name_of_the_list9>\n" +
208 " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
209 " </name_of_the_list9>\n" +
210 "</name_of_the_cont13>\n" +
211 "<name_of_the_list7 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
212 "g:test:augment:name\">\n" +
213 " <name_of_the_leaf14>test</name_of_the_leaf14>\n" +
214 "</name_of_the_list7>\n" +
215 "<name_of_the_list7 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
216 "g:test:augment:name\">\n" +
217 " <name_of_the_leaf14>create</name_of_the_leaf14>\n" +
218 "</name_of_the_list7>\n" +
219 "<name_of_the_leaf15 xmlns=\"urn:opendaylight:params:xml:ns:ya" +
220 "ng:test:augment:name\">abc</name_of_the_leaf15>\n" +
221 "<name_of_the_cont5 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
222 "g:test:augment:name\">\n" +
223 " <name_of_the_leaf13>true</name_of_the_leaf13>\n" +
224 "</name_of_the_cont5>";
226 static final String ENCODE_TO_XML_YANG_AUG_POST_ID = "<?xml version=\"1" +
227 ".0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
228 "<name_of_the_leaf10 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
229 "g:test:name\">abc</name_of_the_leaf10>" +
230 ENCODE_TO_XML_YANG_COMMON_ID + "\n";
232 static final String ENCODE_TO_XML_YANG_PUT_ID = "<?xml version=\"1.0\" " +
233 "encoding=\"UTF-8\" standalone=\"no\"?>\n" +
234 "<name_of_the_cont4 xmlns=\"urn:opendaylight:params:xml:ns:yang" +
236 " <name_of_the_leaf10>abc</name_of_the_leaf10>" +
237 addSpace(ENCODE_TO_XML_YANG_COMMON_ID, 4) + "\n</name_of_the_co" +
240 static final String ENCODE_TO_XML_YANG_ID= "<?xml version=\"1.0\" " +
241 "encoding=\"UTF-8\" standalone=\"no\"?>\n" +
242 "<name_of_the_cont2 xmlns=\"urn:opendaylight:params:xml:ns:yan" +
244 " <name_of_the_ll4>abc</name_of_the_ll4>\n" +
245 " <name_of_the_ll4>abc</name_of_the_ll4>\n" +
246 " <name_of_the_leaf5>abc</name_of_the_leaf5>\n" +
247 " <name_of_the_list6>\n" +
248 " <name_of_the_leaf11>abc</name_of_the_leaf11>\n" +
249 " </name_of_the_list6>\n" +
250 " <name_of_the_list6>\n" +
251 " <name_of_the_leaf11>abc</name_of_the_leaf11>\n" +
252 " </name_of_the_list6>\n" +
253 " <name_of_the_ll5>abc</name_of_the_ll5>\n" +
254 " <name_of_the_ll5>abc</name_of_the_ll5>\n" +
255 " <name_of_the_ll3>abc</name_of_the_ll3>\n" +
256 " <name_of_the_ll3>abc</name_of_the_ll3>\n" +
257 " <name_of_the_leaf6>abc</name_of_the_leaf6>\n" +
258 " <name_of_the_cont3>\n" +
259 " <name_of_the_leaf10>abc</name_of_the_leaf10>\n" +
260 " </name_of_the_cont3>\n" +
261 " <name_of_the_list2>\n" +
262 " <name_of_the_leaf4>abc</name_of_the_leaf4>\n" +
263 " </name_of_the_list2>\n" +
264 " <name_of_the_list2>\n" +
265 " <name_of_the_leaf4>abc</name_of_the_leaf4>\n" +
266 " </name_of_the_list2>\n" +
267 " <name_of_the_list1>\n" +
268 " <name_of_the_ll2>abc</name_of_the_ll2>\n" +
269 " <name_of_the_ll2>abc</name_of_the_ll2>\n" +
270 " <name_of_the_list5>\n" +
271 " <name_of_the_leaf9>abc</name_of_the_leaf9>\n" +
272 " </name_of_the_list5>\n" +
273 " <name_of_the_list5>\n" +
274 " <name_of_the_leaf9>abc</name_of_the_leaf9>\n" +
275 " </name_of_the_list5>\n" +
276 " <name_of_the_list4>\n" +
277 " <name_of_the_leaf8>abc</name_of_the_leaf8>\n" +
278 " </name_of_the_list4>\n" +
279 " <name_of_the_list4>\n" +
280 " <name_of_the_leaf8>abc</name_of_the_leaf8>\n" +
281 " </name_of_the_list4>\n" +
282 " <name_of_the_leaf1>true</name_of_the_leaf1>\n" +
283 " <name_of_the_leaf3>abc</name_of_the_leaf3>\n" +
284 " <name_of_the_leaf2>abc</name_of_the_leaf2>\n" +
285 " <name_of_the_cont4>\n" +
286 " <name_of_the_leaf11>abc</name_of_the_leaf11>\n" +
287 " </name_of_the_cont4>\n" +
288 " <name_of_the_ll1>abc</name_of_the_ll1>\n" +
289 " <name_of_the_ll1>abc</name_of_the_ll1>\n" +
290 " </name_of_the_list1>\n" +
291 " <name_of_the_list1>\n" +
292 " <name_of_the_ll2>abc</name_of_the_ll2>\n" +
293 " <name_of_the_ll2>abc</name_of_the_ll2>\n" +
294 " <name_of_the_list5>\n" +
295 " <name_of_the_leaf9>abc</name_of_the_leaf9>\n" +
296 " </name_of_the_list5>\n" +
297 " <name_of_the_list5>\n" +
298 " <name_of_the_leaf9>abc</name_of_the_leaf9>\n" +
299 " </name_of_the_list5>\n" +
300 " <name_of_the_list4>\n" +
301 " <name_of_the_leaf8>abc</name_of_the_leaf8>\n" +
302 " </name_of_the_list4>\n" +
303 " <name_of_the_list4>\n" +
304 " <name_of_the_leaf8>abc</name_of_the_leaf8>\n" +
305 " </name_of_the_list4>\n" +
306 " <name_of_the_leaf1>true</name_of_the_leaf1>\n" +
307 " <name_of_the_leaf3>abc</name_of_the_leaf3>\n" +
308 " <name_of_the_leaf2>abc</name_of_the_leaf2>\n" +
309 " <name_of_the_cont4>\n" +
310 " <name_of_the_leaf11>abc</name_of_the_leaf11>\n" +
311 " </name_of_the_cont4>\n" +
312 " <name_of_the_ll1>abc</name_of_the_ll1>\n" +
313 " <name_of_the_ll1>abc</name_of_the_ll1>\n" +
314 " </name_of_the_list1>\n" +
315 " <name_of_the_cont4>\n" +
316 " <name_of_the_leaf10>abc</name_of_the_leaf10>" +
317 addSpace(ENCODE_TO_XML_YANG_COMMON_ID, 8) + "\n" +
318 " </name_of_the_cont4>\n" +
319 " <name_of_the_leaf12>abc</name_of_the_leaf12>\n" +
320 "</name_of_the_cont2>\n";
322 static final String ENCODE_TO_JSON_RPC_ID = "{\n" +
323 " \"test_name_of_the_module:input\": {\n" +
324 " \"name_of_the_cont14\": {\n" +
325 " \"name_of_the_leaf28\": \"abc\"\n" +
327 " \"name_of_the_cont13\": {\n" +
328 " \"name_of_the_ll9\": [\n" +
332 " \"name_of_the_leaf28\": \"abc\",\n" +
333 " \"name_of_the_list9\": [\n" +
335 " \"name_of_the_leaf27\": \"abc\"\n" +
338 " \"name_of_the_leaf27\": \"abc\"\n" +
342 " \"name_of_the_leaf30\": \"abc\",\n" +
343 " \"name_of_the_ll10\": [\n" +
347 " \"name_of_the_list10\": [\n" +
349 " \"name_of_the_leaf29\": \"abc\"\n" +
352 " \"name_of_the_leaf29\": \"abc\"\n" +
355 " \"name_of_the_cont15\": {\n" +
356 " \"name_of_the_leaf31\": \"abc\"\n" +
361 static final String DECODE_FROM_JSON_RPC_ID = "{\n" +
362 " \"test_name_of_the_module:output\": {\n" +
363 " \"name_of_the_cont16\": {\n" +
364 " \"name_of_the_leaf32\": \"abc\"\n" +
366 " \"name_of_the_list11\": [\n" +
368 " \"name_of_the_leaf33\": \"abc\"\n" +
371 " \"name_of_the_leaf33\": \"abc\"\n" +
374 " \"name_of_the_leaf34\": \"abc\",\n" +
375 " \"name_of_the_ll11\": [\n" +
379 " \"name_of_the_cont17\": {\n" +
380 " \"name_of_the_leaf35\": \"abc\"\n" +
382 " \"name_of_the_cont13\": {\n" +
383 " \"name_of_the_cont12\": {\n" +
384 " \"name_of_the_leaf26\": \"abc\"\n" +
386 " \"name_of_the_list9\": [\n" +
388 " \"name_of_the_leaf27\": \"abc\"\n" +
391 " \"name_of_the_leaf27\": \"abc\"\n" +
394 " \"name_of_the_ll9\": [\n" +
398 " \"name_of_the_leaf28\": \"abc\"\n" +
403 static final String ENCODE_TO_XML_RPC_ID = "<?xml version=\"1.0\" " +
404 "encoding=\"UTF-8\" standalone=\"no\"?>\n" +
405 "<input xmlns=\"urn:opendaylight:params:xml:ns:yang:test:name\"" +
407 " <name_of_the_cont14>\n" +
408 " <name_of_the_leaf28>abc</name_of_the_leaf28>\n" +
409 " </name_of_the_cont14>\n" +
410 " <name_of_the_cont13>\n" +
411 " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
412 " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
413 " <name_of_the_leaf28>abc</name_of_the_leaf28>\n" +
414 " <name_of_the_list9>\n" +
415 " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
416 " </name_of_the_list9>\n" +
417 " <name_of_the_list9>\n" +
418 " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
419 " </name_of_the_list9>\n" +
420 " </name_of_the_cont13>\n" +
421 " <name_of_the_leaf30>abc</name_of_the_leaf30>\n" +
422 " <name_of_the_ll10>abc</name_of_the_ll10>\n" +
423 " <name_of_the_ll10>abc</name_of_the_ll10>\n" +
424 " <name_of_the_list10>\n" +
425 " <name_of_the_leaf29>abc</name_of_the_leaf29>\n" +
426 " </name_of_the_list10>\n" +
427 " <name_of_the_list10>\n" +
428 " <name_of_the_leaf29>abc</name_of_the_leaf29>\n" +
429 " </name_of_the_list10>\n" +
430 " <name_of_the_cont15>\n" +
431 " <name_of_the_leaf31>abc</name_of_the_leaf31>\n" +
432 " </name_of_the_cont15>\n" +
435 static final String DECODE_FROM_XML_RPC_ID = "<?xml version=\"1.0\" " +
436 "encoding=\"UTF-8\" standalone=\"no\"?>\n" +
437 "<output xmlns=\"urn:opendaylight:params:xml:ns:yang:test:name" +
439 " <name_of_the_cont16>\n" +
440 " <name_of_the_leaf32>abc</name_of_the_leaf32>\n" +
441 " </name_of_the_cont16>\n" +
442 " <name_of_the_list11>\n" +
443 " <name_of_the_leaf33>abc</name_of_the_leaf33>\n" +
444 " </name_of_the_list11>\n" +
445 " <name_of_the_list11>\n" +
446 " <name_of_the_leaf33>abc</name_of_the_leaf33>\n" +
447 " </name_of_the_list11>\n" +
448 " <name_of_the_leaf34>abc</name_of_the_leaf34>\n" +
449 " <name_of_the_ll11>abc</name_of_the_ll11>\n" +
450 " <name_of_the_ll11>abc</name_of_the_ll11>\n" +
451 " <name_of_the_cont17>\n" +
452 " <name_of_the_leaf35>abc</name_of_the_leaf35>\n" +
453 " </name_of_the_cont17>\n" +
454 " <name_of_the_cont13>\n" +
455 " <name_of_the_cont12>\n" +
456 " <name_of_the_leaf26>abc</name_of_the_leaf26>\n" +
457 " </name_of_the_cont12>\n" +
458 " <name_of_the_list9>\n" +
459 " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
460 " </name_of_the_list9>\n" +
461 " <name_of_the_list9>\n" +
462 " <name_of_the_leaf27>abc</name_of_the_leaf27>\n" +
463 " </name_of_the_list9>\n" +
464 " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
465 " <name_of_the_ll9>abc</name_of_the_ll9>\n" +
466 " <name_of_the_leaf28>abc</name_of_the_leaf28>\n" +
467 " </name_of_the_cont13>\n" +