f1e0ab62777f7e0e49aaec03c644c1eeb77383a6
[ccsdk/sli/plugins.git] / properties-node / provider / src / test / java / jtest / org / onap / ccsdk / sli / plugins / prop / TestPropertiesNode.java
1 package jtest.org.onap.ccsdk.sli.plugins.prop;
2
3 import java.util.HashMap;
4 import java.util.HashSet;
5 import java.util.Map;
6 import java.util.Set;
7
8 import org.junit.Test;
9 import static org.junit.Assert.assertEquals;
10 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
11 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
12 import org.onap.ccsdk.sli.plugins.prop.PropertiesNode;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 public class TestPropertiesNode {
17
18     private static final Logger log = LoggerFactory.getLogger(TestPropertiesNode.class);
19     
20     @Test
21     public void testJSONFileParsing() throws SvcLogicException {
22         SvcLogicContext ctx = new SvcLogicContext();
23
24         Map<String, String> p = new HashMap<String, String>();
25         p.put("fileName", "src/test/resources/test.json");
26         p.put("contextPrefix", "test-json");
27         p.put("fileBasedParsing","true");
28
29         PropertiesNode rcn = new PropertiesNode();
30         rcn.readProperties(p, ctx);
31
32         assertEquals(ctx.getAttribute("test-json.message"),"The provisioned access " +
33                 "bandwidth is at or exceeds 50% of the total server capacity.");
34     }
35
36     @Test
37     public void testJSONFileArrayParsing() throws SvcLogicException {
38         SvcLogicContext ctx = new SvcLogicContext();
39
40         Map<String, String> p = new HashMap<String, String>();
41         p.put("fileName", "src/test/resources/test.json");
42         p.put("contextPrefix", "test-json");
43         p.put("fileBasedParsing","true");
44
45         PropertiesNode rcn = new PropertiesNode();
46         rcn.readProperties(p, ctx);
47
48         assertEquals(ctx.getAttribute("test-json.equipment-data[0].max-server-speed"),"1600000");
49         assertEquals(ctx.getAttribute("test-json.resource-state.used"),"1605000");
50         assertEquals(ctx.getAttribute("test-json.resource-rule.service-model"),"DUMMY");
51         assertEquals(ctx.getAttribute("test-json.resource-rule.endpoint-position"),"VCE-Cust");
52     }
53
54     @Test
55     public void testJSONFileParsingPrefixCheck() throws SvcLogicException {
56         SvcLogicContext ctx = new SvcLogicContext();
57
58         Map<String, String> p = new HashMap<String, String>();
59         p.put("fileName", "src/test/resources/test.json");
60         p.put("contextPrefix", "");
61         p.put("fileBasedParsing","true");
62
63         PropertiesNode rcn = new PropertiesNode();
64         rcn.readProperties(p, ctx);
65
66         assertEquals(ctx.getAttribute("equipment-data[0].max-server-speed"),"1600000");
67         assertEquals(ctx.getAttribute("resource-state.used"),"1605000");
68         assertEquals(ctx.getAttribute("resource-rule.service-model"),"DUMMY");
69         assertEquals(ctx.getAttribute("resource-rule.endpoint-position"),"VCE-Cust");
70         assertEquals(ctx.getAttribute("resource-rule.hard-limit-expression"),"max-server-" +
71                 "speed * number-primary-servers");
72     }
73
74     @Test
75     public void testJSONFileParsingNoPrefix() throws SvcLogicException {
76         SvcLogicContext ctx = new SvcLogicContext();
77
78         Map<String, String> p = new HashMap<String, String>();
79         p.put("fileName", "src/test/resources/test.json");
80         p.put("fileBasedParsing","true");
81
82         PropertiesNode rcn = new PropertiesNode();
83         rcn.readProperties(p, ctx);
84
85         assertEquals(ctx.getAttribute("equipment-data[0].max-server-speed"),"1600000");
86         assertEquals(ctx.getAttribute("resource-state.used"),"1605000");
87         assertEquals(ctx.getAttribute("resource-rule.service-model"),"DUMMY");
88         assertEquals(ctx.getAttribute("resource-rule.endpoint-position"),"VCE-Cust");
89         assertEquals(ctx.getAttribute("resource-rule.hard-limit-expression"),"max-server-" +
90                 "speed * number-primary-servers");
91     }
92
93     @Test
94     public void testJSONFileParsingCtxCheck() throws SvcLogicException {
95         SvcLogicContext ctx = new SvcLogicContext();
96         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
97
98         Map<String, String> p = new HashMap<String, String>();
99         p.put("fileName", "src/test/resources/test.json");
100         p.put("fileBasedParsing","true");
101
102         PropertiesNode rcn = new PropertiesNode();
103         rcn.readProperties(p, ctx);
104
105         assertEquals(ctx.getAttribute("equipment-data[0].max-server-speed"),"1600000");
106         assertEquals(ctx.getAttribute("resource-state.used"),"1605000");
107         assertEquals(ctx.getAttribute("resource-rule.service-model"),"DUMMY");
108         assertEquals(ctx.getAttribute("resource-rule.endpoint-position"),"VCE-Cust");
109         assertEquals(ctx.getAttribute("resource-rule.hard-limit-expression"),"max-server-" +
110                 "speed * number-primary-servers");
111         assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
112     }
113
114     @Test(expected = SvcLogicException.class)
115     public void testToPropertiesInvalidJson() throws SvcLogicException {
116         SvcLogicContext ctx = new SvcLogicContext();
117         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
118
119         Map<String, String> p = new HashMap<String, String>();
120         p.put("fileName", "src/test/resources/test-invalid.json");
121         p.put("contextPrefix", "invalid");
122         p.put("fileBasedParsing","true");
123
124         PropertiesNode rcn = new PropertiesNode();
125         rcn.readProperties(p, ctx);
126
127         assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
128     }
129
130     @Test
131     public void testTXTFileParsing() throws SvcLogicException {
132         SvcLogicContext ctx = new SvcLogicContext();
133
134         Map<String, String> p = new HashMap<String, String>();
135         p.put("fileName", "src/test/resources/test.txt");
136         p.put("contextPrefix", "test-txt");
137         p.put("fileBasedParsing","true");
138
139         PropertiesNode rcn = new PropertiesNode();
140         rcn.readProperties(p, ctx);
141
142         assertEquals(ctx.getAttribute("test-txt.service-data.service-information.service-type"),"AVPN");
143         assertEquals(ctx.getAttribute("test-txt.service-configuration-notification-input.response-code"),"0");
144         assertEquals(ctx.getAttribute("test-txt.operational-data.avpn-ip-port-information.port-" +
145                                               "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
146         assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" +
147                                               "access-information.l1-customer-handoff"),"_1000BASELX");
148         assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" +
149                                               "access-information.vlan-tag-control"),"_1Q");
150     }
151
152     @Test
153     public void testTXTFileParsingPrefixCheck() throws SvcLogicException {
154         SvcLogicContext ctx = new SvcLogicContext();
155
156         Map<String, String> p = new HashMap<String, String>();
157         p.put("fileName", "src/test/resources/test.txt");
158         p.put("contextPrefix", "");
159         p.put("fileBasedParsing","true");
160
161         PropertiesNode rcn = new PropertiesNode();
162         rcn.readProperties(p, ctx);
163
164         assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
165         assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
166         assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
167                                               "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
168         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
169                                               "access-information.l1-customer-handoff"),"_1000BASELX");
170         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
171                                               "access-information.vlan-tag-control"),"_1Q");
172     }
173
174     @Test
175     public void testTXTFileParsingNoPrefix() throws SvcLogicException {
176         SvcLogicContext ctx = new SvcLogicContext();
177
178         Map<String, String> p = new HashMap<String, String>();
179         p.put("fileName", "src/test/resources/test.txt");
180         p.put("fileBasedParsing","true");
181
182         PropertiesNode rcn = new PropertiesNode();
183         rcn.readProperties(p, ctx);
184
185         assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
186         assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
187         assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
188                                               "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
189         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
190                                               "access-information.l1-customer-handoff"),"_1000BASELX");
191         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
192                                               "access-information.vlan-tag-control"),"_1Q");
193     }
194
195     @Test
196     public void testTXTFileParsingCtxCheck() throws SvcLogicException {
197         SvcLogicContext ctx = new SvcLogicContext();
198         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
199
200         Map<String, String> p = new HashMap<String, String>();
201         p.put("fileName", "src/test/resources/test.txt");
202         p.put("fileBasedParsing","true");
203
204         PropertiesNode rcn = new PropertiesNode();
205         rcn.readProperties(p, ctx);
206
207         assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
208         assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
209         assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
210                                               "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
211         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
212                                               "access-information.l1-customer-handoff"),"_1000BASELX");
213         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
214                                               "access-information.vlan-tag-control"),"_1Q");
215         assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
216     }
217
218     @Test(expected = SvcLogicException.class)
219     public void testToPropertiesInvalidParam() throws SvcLogicException {
220         SvcLogicContext ctx = new SvcLogicContext();
221         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
222
223         Map<String, String> p = new HashMap<String, String>();
224         p.put("responsePrefix", "response");
225         p.put("skipSending", "true");
226         p.put("fileBasedParsing","true");
227
228         PropertiesNode rcn = new PropertiesNode();
229         rcn.readProperties(p, ctx);
230
231         assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
232     }
233
234     @Test(expected = SvcLogicException.class)
235     public void testToPropertiesNoParam() throws SvcLogicException {
236         SvcLogicContext ctx = new SvcLogicContext();
237         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
238
239         Map<String, String> p = new HashMap<String, String>();
240         p.put("fileBasedParsing","true");
241
242         PropertiesNode rcn = new PropertiesNode();
243         rcn.readProperties(p, ctx);
244
245         assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
246     }
247
248     @Test(expected = SvcLogicException.class)
249     public void testToPropertiesFilePathError() throws SvcLogicException {
250         SvcLogicContext ctx = new SvcLogicContext();
251         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
252
253         Map<String, String> p = new HashMap<String, String>();
254         p.put("fileName", "src/tests/resources/test.txt");
255         p.put("fileBasedParsing","true");
256
257         PropertiesNode rcn = new PropertiesNode();
258         rcn.readProperties(p, ctx);
259
260         assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
261     }
262
263     @Test
264     public void testXMLFileParsing() throws SvcLogicException {
265         SvcLogicContext ctx = new SvcLogicContext();
266
267         Map<String, String> p = new HashMap<String, String>();
268         p.put("fileName", "src/test/resources/test.xml");
269         p.put("contextPrefix", "test-xml");
270         p.put("listName", "project.build");
271         p.put("fileBasedParsing","true");
272
273         PropertiesNode rcn = new PropertiesNode();
274         rcn.readProperties(p, ctx);
275
276         assertEquals(ctx.getAttribute("test-xml.project.modelVersion"),"4.0.0");
277     }
278
279     @Test
280     public void testXMLFileInnerParsing() throws SvcLogicException {
281         SvcLogicContext ctx = new SvcLogicContext();
282
283         Map<String, String> p = new HashMap<String, String>();
284         p.put("fileName", "src/test/resources/test.xml");
285         p.put("contextPrefix", "test-xml");
286         p.put("listName", "project.modelVersion");
287         p.put("fileBasedParsing","true");
288
289         PropertiesNode rcn = new PropertiesNode();
290         rcn.readProperties(p, ctx);
291
292         assertEquals(ctx.getAttribute("test-xml.project.properties.project.build.sourceEncoding"),"UTF-8");
293         assertEquals(ctx.getAttribute("test-xml.project.dependencies.dependency.scope"),"provided");
294         assertEquals(ctx.getAttribute("test-xml.project.build.pluginManagement.plugins.plugin.configuration" +
295                                               ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." +
296                                               "pluginExecutionFilter.versionRange"),"[1.2.0.100,)");
297         assertEquals(ctx.getAttribute("test-xml.project.build.plugins.plugin.configuration." +
298                                               "instructions.Import-Package"),"*");
299     }
300
301     @Test
302     public void testXMLFileParsingPrefixCheck() throws SvcLogicException {
303         SvcLogicContext ctx = new SvcLogicContext();
304
305         Map<String, String> p = new HashMap<String, String>();
306         p.put("fileName", "src/test/resources/test.xml");
307         p.put("contextPrefix", "");
308         p.put("fileBasedParsing","true");
309
310         PropertiesNode rcn = new PropertiesNode();
311         rcn.readProperties(p, ctx);
312
313         assertEquals(ctx.getAttribute("project.properties.project.build.sourceEncoding"),"UTF-8");
314         assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided");
315         assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" +
316                                               ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." +
317                                               "pluginExecutionFilter.versionRange"),"[1.2.0.100,)");
318         assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." +
319                                               "instructions.Import-Package"),"*");
320     }
321
322     @Test
323     public void testXMLFileParsingNoPrefix() throws SvcLogicException {
324         SvcLogicContext ctx = new SvcLogicContext();
325
326         Map<String, String> p = new HashMap<String, String>();
327         p.put("fileName", "src/test/resources/test.xml");
328         p.put("fileBasedParsing","true");
329
330         PropertiesNode rcn = new PropertiesNode();
331         rcn.readProperties(p, ctx);
332
333         assertEquals(ctx.getAttribute("project.properties.project.build.sourceEncoding"),"UTF-8");
334         assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided");
335         assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" +
336                                               ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." +
337                                               "pluginExecutionFilter.versionRange"),"[1.2.0.100,)");
338         assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." +
339                                               "instructions.Import-Package"),"*");
340     }
341
342     @Test
343     public void testXMLFileParsingCtxCheck() throws SvcLogicException {
344         SvcLogicContext ctx = new SvcLogicContext();
345         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
346
347         Map<String, String> p = new HashMap<String, String>();
348         p.put("fileName", "src/test/resources/test.xml");
349         p.put("fileBasedParsing","true");
350
351         PropertiesNode rcn = new PropertiesNode();
352         rcn.readProperties(p, ctx);
353
354         assertEquals(ctx.getAttribute("project.properties.project.build.sourceEncoding"),"UTF-8");
355         assertEquals(ctx.getAttribute("project.dependencies.dependency.scope"),"provided");
356         assertEquals(ctx.getAttribute("project.build.pluginManagement.plugins.plugin.configuration" +
357                                               ".lifecycleMappingMetadata.pluginExecutions.pluginExecution." +
358                                               "pluginExecutionFilter.versionRange"),"[1.2.0.100,)");
359         assertEquals(ctx.getAttribute("project.build.plugins.plugin.configuration." +
360                                               "instructions.Import-Package"),"*");
361         assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
362     }
363
364     @Test(expected = SvcLogicException.class)
365     public void testToPropertiesInvalidXML() throws SvcLogicException {
366         SvcLogicContext ctx = new SvcLogicContext();
367         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
368
369         Map<String, String> p = new HashMap<String, String>();
370         p.put("fileName", "src/test/resources/test-invalid.xml");
371         p.put("contextPrefix", "invalid");
372         p.put("fileBasedParsing","true");
373
374         PropertiesNode rcn = new PropertiesNode();
375         rcn.readProperties(p, ctx);
376
377         assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
378     }
379
380     @Test
381     public void testXMLFileParsingListName() throws SvcLogicException {
382         SvcLogicContext ctx = new SvcLogicContext();
383
384         Map<String, String> p = new HashMap<String, String>();
385         p.put("fileName", "src/test/resources/test.xml");
386         p.put("contextPrefix", "test-xml-listName");
387         p.put("fileBasedParsing","true");
388         p.put("listName", "project.build.pluginManagement");
389
390         PropertiesNode rcn = new PropertiesNode();
391         rcn.readProperties(p, ctx);
392
393         assertEquals(ctx.getAttribute("test-xml-listName.project.build." +
394                                               "pluginManagement.plugins.plugin.version"),null);
395         assertEquals(ctx.getAttribute("test-xml-listName.project.build." +
396                                               "plugins.plugin.groupId"),"org.apache.felix");
397     }
398
399     @Test
400     public void testXMLFileParsingListNameAnother() throws SvcLogicException {
401         SvcLogicContext ctx = new SvcLogicContext();
402
403         Map<String, String> p = new HashMap<String, String>();
404         p.put("fileName", "src/test/resources/test.xml");
405         p.put("contextPrefix", "test-xml-listName");
406         p.put("fileBasedParsing","true");
407         p.put("listName", "project.modelVersion");
408
409         PropertiesNode rcn = new PropertiesNode();
410         rcn.readProperties(p, ctx);
411
412         assertEquals(ctx.getAttribute("test-xml-listName.project.modelVersion"),null);
413         assertEquals(ctx.getAttribute("test-xml-listName.project.build." +
414                                               "plugins.plugin.groupId"),"org.apache.felix");
415     }
416
417     @Test
418     public void testTXTFileParsingNotFileBased() throws SvcLogicException {
419         SvcLogicContext ctx = new SvcLogicContext();
420
421         Map<String, String> p = new HashMap<String, String>();
422         p.put("fileName", "src/test/resources/test.txt");
423         p.put("contextPrefix", "test-txt");
424
425         PropertiesNode rcn = new PropertiesNode();
426         rcn.readProperties(p, ctx);
427
428         assertEquals(ctx.getAttribute("test-txt.service-data.service-information.service-type"),"AVPN");
429         assertEquals(ctx.getAttribute("test-txt.service-configuration-notification-input.response-code"),"0");
430         assertEquals(ctx.getAttribute("test-txt.operational-data.avpn-ip-port-information.port-" +
431                                               "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
432         assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" +
433                                               "access-information.l1-customer-handoff"),"_1000BASELX");
434         assertEquals(ctx.getAttribute("test-txt.service-data.avpn-ip-port-information.avpn-" +
435                                               "access-information.vlan-tag-control"),"_1Q");
436     }
437
438     @Test
439     public void testTXTFileParsingPrefixCheckNotFileBased() throws SvcLogicException {
440         SvcLogicContext ctx = new SvcLogicContext();
441
442         Map<String, String> p = new HashMap<String, String>();
443         p.put("fileName", "src/test/resources/test.txt");
444         p.put("contextPrefix", "");
445
446         PropertiesNode rcn = new PropertiesNode();
447         rcn.readProperties(p, ctx);
448
449         assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
450         assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
451         assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
452                                               "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
453         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
454                                               "access-information.l1-customer-handoff"),"_1000BASELX");
455         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
456                                               "access-information.vlan-tag-control"),"_1Q");
457     }
458
459     @Test
460     public void testTXTFileParsingNoPrefixNotFileBased() throws SvcLogicException {
461         SvcLogicContext ctx = new SvcLogicContext();
462
463         Map<String, String> p = new HashMap<String, String>();
464         p.put("fileName", "src/test/resources/test.txt");
465
466         PropertiesNode rcn = new PropertiesNode();
467         rcn.readProperties(p, ctx);
468
469         assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
470         assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
471         assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
472                                               "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
473         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
474                                               "access-information.l1-customer-handoff"),"_1000BASELX");
475         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
476                                               "access-information.vlan-tag-control"),"_1Q");
477     }
478
479     @Test
480     public void testTXTFileParsingCtxCheckNotFileBased() throws SvcLogicException {
481         SvcLogicContext ctx = new SvcLogicContext();
482         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "1");
483
484         Map<String, String> p = new HashMap<String, String>();
485         p.put("fileName", "src/test/resources/test.txt");
486
487         PropertiesNode rcn = new PropertiesNode();
488         rcn.readProperties(p, ctx);
489
490         assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
491         assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
492         assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
493                                               "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
494         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
495                                               "access-information.l1-customer-handoff"),"_1000BASELX");
496         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
497                                               "access-information.vlan-tag-control"),"_1Q");
498         assertEquals(ctx.getAttribute("tmp.sdn-circuit-req-row_length"),"1");
499     }
500
501     @Test
502     public void testJSONFileArrayParsingNotFileBased() throws SvcLogicException {
503         SvcLogicContext ctx = new SvcLogicContext();
504
505         Map<String, String> p = new HashMap<String, String>();
506         p.put("fileName", "src/test/resources/test.json");
507         p.put("contextPrefix", "NotFileBased");
508
509         PropertiesNode rcn = new PropertiesNode();
510         rcn.readProperties(p, ctx);
511
512         assertEquals(ctx.getAttribute("NotFileBased.\"limit-value\""),"\"1920000\"");
513         assertEquals(ctx.getAttribute("NotFileBased.\"hard-limit-expression\""),"\"max-server-speed * number-primary-servers\",");
514         assertEquals(ctx.getAttribute("NotFileBased.\"test-inner-node\""),"\"Test-Value\"");
515     }
516
517     @Test
518     public void testXMLFileInnerParsingNotFileBased() throws SvcLogicException {
519         SvcLogicContext ctx = new SvcLogicContext();
520
521         Map<String, String> p = new HashMap<String, String>();
522         p.put("fileName", "src/test/resources/test.xml");
523         p.put("contextPrefix", "NotFileBased");
524         p.put("listName", "project.modelVersion");
525
526         PropertiesNode rcn = new PropertiesNode();
527         rcn.readProperties(p, ctx);
528
529         assertEquals(ctx.getAttribute("NotFileBased.<name>RESTAPI"),"Call Node - Provider</name>");
530         assertEquals(ctx.getAttribute("NotFileBased.<project"),
531                      "xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
532                              " xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">");
533         assertEquals(ctx.getAttribute("NotFileBased.openECOMP"),"SDN-C");
534         assertEquals(ctx.getAttribute("NotFileBased.<ignore"),"/>");
535     }
536
537     @Test
538     public void testNoFileTypeNoPrefixNotFileBased() throws SvcLogicException {
539         SvcLogicContext ctx = new SvcLogicContext();
540
541         Map<String, String> p = new HashMap<String, String>();
542         p.put("fileName", "src/test/resources/test");
543         p.put("fileBasedParsing","true");
544
545         PropertiesNode rcn = new PropertiesNode();
546         rcn.readProperties(p, ctx);
547
548         assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
549         assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
550         assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
551                                               "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
552         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
553                                               "access-information.l1-customer-handoff"),"_1000BASELX");
554         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
555                                               "access-information.vlan-tag-control"),"_1Q");
556     }
557
558     @Test(expected = SvcLogicException.class)
559     public void testNoFileTypeParseReqError() throws SvcLogicException {
560         SvcLogicContext ctx = new SvcLogicContext();
561
562         Map<String, String> p = new HashMap<String, String>();
563         p.put("file Name", "src/test/resources/test");
564         p.put("fileBasedParsing","true");
565
566         PropertiesNode rcn = new PropertiesNode();
567         rcn.readProperties(p, ctx);
568
569         assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
570         assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
571         assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
572                                               "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
573         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
574                                               "access-information.l1-customer-handoff"),"_1000BASELX");
575         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
576                                               "access-information.vlan-tag-control"),"_1Q");
577     }
578
579     @Test
580     public void testNoFileTypeParseError() throws SvcLogicException {
581         SvcLogicContext ctx = new SvcLogicContext();
582
583         Map<String, String> p = new HashMap<String, String>();
584         p.put("fileName", "src/test/resources/test");
585         p.put("file Based % Parsing","true");
586
587         PropertiesNode rcn = new PropertiesNode();
588         rcn.readProperties(p, ctx);
589
590         assertEquals(ctx.getAttribute("service-data.service-information.service-type"),"AVPN");
591         assertEquals(ctx.getAttribute("service-configuration-notification-input.response-code"),"0");
592         assertEquals(ctx.getAttribute("operational-data.avpn-ip-port-information.port-" +
593                                               "level-cos.queueing.pe-per-class-queueing-behaviors.cos3-queueing"),"WRED");
594         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
595                                               "access-information.l1-customer-handoff"),"_1000BASELX");
596         assertEquals(ctx.getAttribute("service-data.avpn-ip-port-information.avpn-" +
597                                               "access-information.vlan-tag-control"),"_1Q");
598     }
599 }