diff options
author | Ahmedeldeeb50 <ahmed.eldeeb.ext@orange.com> | 2020-09-23 15:21:23 +0200 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2020-09-24 13:20:11 +0000 |
commit | a9de78841e84867f1b5065205760060bdc5307ec (patch) | |
tree | f8ef2479b23193a5b2841f21a7b330f30eb4ec63 /cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/Parser.spec.ts | |
parent | 2e80cc8a3e97b1e0979511c54aebd86bddfa7f35 (diff) |
Support parsing of Yaml files within Velocity and Jinja Template.
Issue-ID: CCSDK-2770
Signed-off-by: Ahmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Change-Id: I4ceb105206b8d5ed96c2dc67192223925fee8700
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/Parser.spec.ts')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/Parser.spec.ts | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/Parser.spec.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/Parser.spec.ts index e90377e0c..d9c4c2b4a 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/Parser.spec.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/utils/ParserFactory/Parser.spec.ts @@ -1,7 +1,11 @@ import { XmlParser } from './XmlParser'; +import { ParserFactory } from './ParserFactory'; +import { FileExtension } from '../TemplateType'; +import { JinjaXMLParser } from './JinjaXML'; fdescribe('ImportsTabComponent', () => { - const parser: XmlParser = new XmlParser(); + + const parserFactory = new ParserFactory(); beforeEach(() => { @@ -19,10 +23,58 @@ fdescribe('ImportsTabComponent', () => { </vdns-instances> </vlb-business-vnf-onap-plugin>`; + const parser = parserFactory.getParser(fileContent, FileExtension.XML); const res = parser.getVariables(fileContent); console.log(res); expect(res.length).toEqual(2); expect(res[0]).toEqual('vdns_int_private_ip_0'); expect(res[1]).toEqual('vdns_onap_private_ip_0'); }); + + it('Test J2 XML Parser', () => { + const fileContent = `<?xml version="1.0" encoding="UTF-8"?> + <configuration xmlns:junos="http://xml.juniper.net/junos/17.4R1/junos"> + <system xmlns="http://yang.juniper.net/junos-qfx/conf/system"> + <host-name operation="delete" /> + <host-name operation="create">[hostname]</host-name> + </system> + </configuration>`; + + const parser = parserFactory.getParser(fileContent, FileExtension.Jinja); + const res = parser.getVariables(fileContent); + console.log(typeof (res)); + console.log(res); + expect(res.length).toEqual(1); + expect(res[0]).toEqual('hostname'); + + }); + + it('Test J2 YML Parser', () => { + const fileContent = `apiVersion: v1 + kind: Service + metadata: + name: {{ .Values.vpg_name_0 }}-ssh + labels: + vnf-name: {{ .Values.vnf_name }} + vf-module-name: {{ .Values.vpg_name_0 }} + release: {{ .Release.Name }} + chart: {{ .Chart.Name }} + spec: + type: NodePort + ports: + port: 22 + nodePort: \${vpg-management-port} + selector: + vf-module-name: {{ .Values.vpg_name_0 }} + release: {{ .Release.Name }} + chart: {{ .Chart.Name }}`; + + const parser = parserFactory.getParser(fileContent, FileExtension.Jinja); + const res = parser.getVariables(fileContent); + console.log(res); + expect(res.length).toEqual(2); + expect(res[0]).toEqual('vpg_name_0'); + expect(res[1]).toEqual('vnf_name'); + + }); }); |