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