d2412a0f469718bf35786954d0d04d24e28f106b
[appc/cdt.git] /
1 /*
2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
5 ===================================================================
6
7 Unless otherwise specified, all software contained herein is licensed
8 under the Apache License, Version 2.0 (the License);
9 you may not use this software except in compliance with the License.
10 You may obtain a copy of the License at
11
12     http://www.apache.org/licenses/LICENSE-2.0
13
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19
20 ECOMP is a trademark and service mark of AT&T Intellectual Property.
21 ============LICENSE_END============================================
22 */
23
24
25 import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
26 import { By, BrowserModule } from '@angular/platform-browser';
27 import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
28 import { Component, OnInit, ViewChild, Input } from '@angular/core';
29 import { HttpUtilService } from '../../../../shared/services/httpUtil/http-util.service';
30 import { MappingEditorService } from '../../../../shared/services/mapping-editor.service';
31 import { ArtifactRequest } from '../../../../shared/models/index';
32 import { ActivatedRoute, Router } from "@angular/router";
33 import { saveAs } from "file-saver";
34 import { NotificationService } from '../../../../shared/services/notification.service';
35 import { NotificationsService } from "angular2-notifications"
36 import { ParamShareService } from '../../../../shared/services/paramShare.service';
37 import { DialogService } from "ng2-bootstrap-modal";
38 import { ConfirmComponent } from '../../../../shared/confirmModal/confirm.component';
39 import { BuildDesignComponent } from '../../build-artifacts.component';
40 import { environment } from '../../../../../environments/environment';
41 import { ModalComponent } from 'ng2-bs3-modal/ng2-bs3-modal'
42 import { FormsModule } from '@angular/forms';
43 import { RouterTestingModule } from '@angular/router/testing';
44 import { HomeComponent } from '../../../../home/home/home.component';
45 import { LogoutComponent } from '../../../../shared/components/logout/logout.component';
46 import { HelpComponent } from '../../../../shared/components/help/help/help.component';
47 import { AboutUsComponent } from '../../../../about-us/aboutus.component';
48 import { TestComponent } from '../../../../test/test.component';
49 import { HttpModule } from '@angular/http';
50 import { AceEditorComponent } from 'ng2-ace-editor';
51 import { Ng2Bs3ModalModule } from 'ng2-bs3-modal/ng2-bs3-modal';
52 import { SimpleNotificationsModule } from 'angular2-notifications';
53 import { GoldenConfigurationComponent } from './template-configuration.component';
54 import { NgProgress } from 'ngx-progressbar';
55 import { BaseRequestOptions, Response, ResponseOptions, Http } from '@angular/http';
56 import { MockBackend, MockConnection } from '@angular/http/testing';
57
58 describe('GoldenConfigurationComponent', () => {
59   let component: GoldenConfigurationComponent;
60   let fixture: ComponentFixture<GoldenConfigurationComponent>;
61   let buildDesignComponent: BuildDesignComponent;
62   let paramShareService: ParamShareService;
63   let dialogService: DialogService;
64   let notificationService: NotificationService;
65   let httpUtil: HttpUtilService;
66   let mappingEditorService: MappingEditorService;
67   let activeRoutes: ActivatedRoute;
68   let router: Router;
69   let nService: NotificationsService
70   const routes = [
71     {
72       path: 'home',
73       component: HomeComponent
74     }, {
75       path: 'vnfs',
76       loadChildren: '../../../../vnfs/vnfs.module#VnfsModule'
77     }, {
78       path: 'test',
79       component: TestComponent
80     },
81     {
82       path: 'help',
83       component: HelpComponent
84     }, {
85       path: 'aboutUs',
86       component: AboutUsComponent
87     }, {
88       path: 'logout',
89       component: LogoutComponent
90     }, {
91       path: '',
92       redirectTo: '/home',
93       pathMatch: 'full'
94     }
95   ];
96
97   beforeEach(() => {
98     TestBed.configureTestingModule({
99       imports: [FormsModule, BrowserModule, RouterTestingModule.withRoutes(routes), HttpModule, Ng2Bs3ModalModule, SimpleNotificationsModule.forRoot()],
100       declarations: [GoldenConfigurationComponent, HomeComponent, TestComponent, HelpComponent, AboutUsComponent, LogoutComponent, AceEditorComponent],
101       providers: [BuildDesignComponent, NgProgress, ParamShareService, DialogService, NotificationService, MockBackend,
102         BaseRequestOptions,
103         {
104           provide: Http,
105           useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => {
106             return new Http(backend, defaultOptions);
107           },
108           deps: [MockBackend, BaseRequestOptions],
109         },
110
111         HttpUtilService, MappingEditorService, NotificationsService],
112       schemas: [NO_ERRORS_SCHEMA],
113     })
114
115   });
116
117   beforeEach(async(() => {
118     TestBed.compileComponents()
119
120   }));
121
122
123   it('validate if uploaded file should be xml or json', () => {
124     fixture = TestBed.createComponent(GoldenConfigurationComponent);
125     component = fixture.componentInstance;
126     expect(component.validateUploadedFile('xls')).toBe(false);
127     expect(component.validateUploadedFile('json')).toBe(true);
128     expect(component.validateUploadedFile('xml')).toBe(true);
129   });
130
131
132   it('validate initialisation of variables in ngOnit() function', inject([MappingEditorService], (mappingEditorService: MappingEditorService) => {
133     fixture = TestBed.createComponent(GoldenConfigurationComponent);
134     component = fixture.componentInstance;
135     mappingEditorService.latestAction = { "action": "Configure", "action-level": "vnf", "scope": { "vnf-type": "testVnf", "vnfc-type": "" }, "template": "Y", "vm": [], "device-protocol": "CHEF", "user-name": "", "port-number": "", "artifact-list": [{ "artifact-name": "template_Configure_test_0.0.1V.json", "artifact-type": "config_template" }, { "artifact-name": "pd_Configure_test_0.0.1V.yaml", "artifact-type": "parameter_definitions" }], "scopeType": "vnf-type" }
136
137     expect(component.ngOnInit());
138     expect(component.ngAfterViewInit());
139     expect(component.action).toEqual('Configure');
140     expect(component.vnfType).toEqual('testVnf');
141     expect(component.vnfcType).toEqual('');
142     expect(component.protocol).toEqual('CHEF');
143
144     expect(component.artifactName).toEqual('template_Configure_test_0.0.1V.json');
145
146     mappingEditorService.latestAction = { "action": "Configure", "action-level": "vnf", "scope": { "vnf-type": "testVnf", "vnfc-type": "testVnfc" }, "template": "Y", "vm": [], "device-protocol": "CHEF", "user-name": "", "port-number": "", "artifact-list": [{ "artifact-name": "template_Configure_test_0.0.1V.json", "artifact-type": "config_template" }, { "artifact-name": "pd_Configure_test_0.0.1V.yaml", "artifact-type": "parameter_definitions" }], "scopeType": "vnf-type" }
147     expect(component.ngOnInit());
148     expect(component.vnfcType).toEqual('testVnfc');
149
150
151   }));
152
153   it('check if variables are empty when reference data object is empty', inject([MappingEditorService], (mappingEditorService: MappingEditorService) => {
154     fixture = TestBed.createComponent(GoldenConfigurationComponent);
155     component = fixture.componentInstance;
156     // mappingEditorService.latestAction = { "action": "", "scope": { "vnf-type": "", "vnfc-type": "" }, "vm": [], "protocol": "", "download-dg-reference": "", "user-name": "", "port-number": "", "artifact-list": [], "deviceTemplate": "", "scopeType": "" };
157     mappingEditorService.latestAction = undefined;
158     expect(component.ngAfterViewInit());
159     expect(component.action).toEqual('');
160     expect(component.vnfType).toEqual('');
161     expect(component.vnfcType).toEqual('');
162     expect(component.protocol).toEqual('');
163     expect(component.artifactName).toEqual('');
164
165   }));
166
167   it('check if correct notification is fired while initialising if reference data object is undefined', () => {
168     fixture = TestBed.createComponent(GoldenConfigurationComponent);
169     component = fixture.componentInstance;
170     expect(component.ngAfterViewInit());
171     expect(component.Actions.length).toBe(0)
172     expect(component.enableBrowse).toBe(false)
173   });
174
175   it('test sync template when template data, param data and pd data are available', inject([MappingEditorService, ParamShareService], (mappingEditorService: MappingEditorService, paramShareService: ParamShareService) => {
176     fixture = TestBed.createComponent(GoldenConfigurationComponent);
177     component = fixture.componentInstance;
178     mappingEditorService.fromScreen === 'MappingScreen'
179     component.configMappingEditorContent = "<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" \n    xmlns:a=\"http://xml.juniper.net/junos/15.1X49/junos\" >\n            <version>15.1X49-D50.3</version>\n            <groups>\n                <name>node0</name>\n                <system>\n                   <tacplus-server>\n                        <name>${sync_auto-pop_name1}</name>\n                        <source-address>${sync_auto-pop_address1}</source-address>\n                    </tacplus-server>\n                    <tacplus-server>\n                        <name>${node0_tacplus_server_name2}</name>\n                        <source-address>${sync_auto-pop_address1}</source-address>\n                    </tacplus-server>\n                </system>         \n           </groups>\n    </configuration>"
180     mappingEditorService.initialise(component.templateeditor.getEditor(), component.configMappingEditorContent, component.modal);
181
182     var pdData = [{ "name": "sync_auto-pop_name1", "type": null, "description": null, "required": null, "default": null, "source": "A&AI", "rule-type": "vnfc-oam-ipv4-address-list", "request-keys": [{ "key-name": null, "key-value": null }, { "key-name": null, "key-value": null }, { "key-name": null, "key-value": null }], "response-keys": [{ "key-name": "unique-key-name", "key-value": "parent-name" }, { "key-name": "unique-key-value", "key-value": "vnfc" }, { "key-name": "field-key-name", "key-value": "ipaddress-v4-oam-vip" }, { "key-name": null, "key-value": "vm-number" }, { "key-name": null, "key-value": "test" }], "ruleTypeValues": [null, "vnf-name", "vm-name-list", "vnfc-name-list", "vnf-oam-ipv4-address", "vnfc-oam-ipv4-address-list"], "showFilterFields": true, "enableFilterByValue": true }, { "name": "sync_auto-pop_address1", "type": null, "description": null, "required": null, "default": null, "source": "A&AI", "rule-type": "vm-name-list", "request-keys": [{ "key-name": null, "key-value": null }, { "key-name": null, "key-value": null }, { "key-name": null, "key-value": null }], "response-keys": [{ "key-name": "unique-key-name", "key-value": "parent-name" }, { "key-name": "unique-key-value", "key-value": "vserver" }, { "key-name": "field-key-name", "key-value": "vserver-name" }, { "key-name": null, "key-value": "vnfc-function-code" }, { "key-name": null, "key-value": null }], "ruleTypeValues": [null, "vnf-name", "vm-name-list", "vnfc-name-list", "vnf-oam-ipv4-address", "vnfc-oam-ipv4-address-list"], "showFilterFields": true, "enableFilterByValue": true }, { "name": "node0_tacplus_server_name2", "type": null, "description": null, "required": null, "default": null, "source": "Manual", "rule-type": null, "request-keys": [{ "key-name": null, "key-value": null }, { "key-name": null, "key-value": null }, { "key-name": null, "key-value": null }], "response-keys": [{ "key-name": null, "key-value": null }, { "key-name": null, "key-value": null }, { "key-name": null, "key-value": null }, { "key-name": null, "key-value": null }, { "key-name": null, "key-value": null }], "ruleTypeValues": [null] }];
183     paramShareService.setSessionParamData([pdData]);
184     localStorage["paramsContent"] = {
185       "sync_auto-pop_name1": "testIp1",
186       "sync_auto-pop_address1": "",
187       "node0_tacplus_server_name2": "testIp2"
188     };
189     expect(component.syncTemplate());
190
191
192   }));
193
194   it('test sync template when template data, param data and pd data are not available', inject([MappingEditorService, ParamShareService], (mappingEditorService: MappingEditorService, paramShareService: ParamShareService) => {
195     fixture = TestBed.createComponent(GoldenConfigurationComponent);
196     component = fixture.componentInstance;
197     mappingEditorService.fromScreen === 'MappingScreen'
198     component.configMappingEditorContent = "<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" \n    xmlns:a=\"http://xml.juniper.net/junos/15.1X49/junos\" >\n            <version>15.1X49-D50.3</version>\n            <groups>\n                <name>node0</name>\n                <system>\n                   <tacplus-server>\n                        <name>${sync_auto-pop_name1}</name>\n                        <source-address>${sync_auto-pop_address1}</source-address>\n                    </tacplus-server>\n                    <tacplus-server>\n                        <name>${node0_tacplus_server_name2}</name>\n                        <source-address>${sync_auto-pop_address1}</source-address>\n                    </tacplus-server>\n                </system>         \n           </groups>\n    </configuration>"
199     mappingEditorService.initialise(component.templateeditor.getEditor(), component.configMappingEditorContent, component.modal);
200
201     var pdData = [];
202     paramShareService.setSessionParamData([pdData]);
203     localStorage["paramsContent"] = {};
204     expect(component.syncTemplate());
205
206
207   }));
208
209   it('test whether proper param data and template data are getting set in the appDataObject', inject([MappingEditorService], (mappingEditorService: MappingEditorService) => {
210     fixture = TestBed.createComponent(GoldenConfigurationComponent);
211     component = fixture.componentInstance;
212     mappingEditorService.latestAction = { "action": "Configure", "action-level": "vnf", "scope": { "vnf-type": "testVnf", "vnfc-type": "" }, "template": "Y", "vm": [], "device-protocol": "CHEF", "user-name": "", "port-number": "", "artifact-list": [{ "artifact-name": "template_Configure_test_0.0.1V.json", "artifact-type": "config_template" }, { "artifact-name": "pd_Configure_test_0.0.1V.yaml", "artifact-type": "parameter_definitions" }], "scopeType": "vnf-type" };
213     component.ngOnInit();
214     component.ngAfterViewInit();
215     component.appDataObject = { reference: {}, template: { templateData: {}, nameValueData: {} }, pd: {} };
216     component.configMappingEditorContent = "<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" \n    xmlns:a=\"http://xml.juniper.net/junos/15.1X49/junos\" >\n            <version>15.1X49-D50.3</version>\n            <groups>\n                <name>node0</name>\n                <system>\n                   <tacplus-server>\n                        <name>${sync_auto-pop_name1}</name>\n                        <source-address>${sync_auto-pop_address1}</source-address>\n                    </tacplus-server>\n                    <tacplus-server>\n                        <name>${node0_tacplus_server_name2}</name>\n                        <source-address>${sync_auto-pop_address1}</source-address>\n                    </tacplus-server>\n                </system>         \n           </groups>\n    </configuration>"
217     mappingEditorService.initialise(component.templateeditor.getEditor(), component.configMappingEditorContent, component.modal);
218     localStorage["paramsContent"] = JSON.stringify({ "sync_auto-pop_name1": "testIp1", "sync_auto-pop_address1": "", "node0_tacplus_server_name2": "testIp2" });
219
220     component.userId = "testuser";
221     component.apiToken = "87264736473";
222     component.prepareAppData();
223     var paramData = { "input": ({ "design-request": ({ "request-id": '87264736473', "action": 'uploadArtifact', "payload": '{"userID":"testuser","vnf-type":"testVnf","action":"Configure","artifact-name":"param_Configure_testVnf_0.0.1V.json","artifact-type":"APPC-CONFIG","artifact-version":"0.0.1","artifact-contents":"[{\"sync_auto-pop_name1\":\"10.0.1.34\",\"sync_auto-pop_address1\":\"\",\"node0_tacplus_server_name2\":\"192.34.45.5\"}]"}' }) }) };
224     var templateData = { input: ({ "design-request": ({ "request-id": '87264736473', "action": 'uploadArtifact', "payload": '{"userID":"testuser","vnf-type":"testVnf","action":"Configure","artifact-name":"template_Configure_test_0.0.1V.json","artifact-type":"APPC-CONFIG","artifact-version":"0.0.1","artifact-contents":"<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" \n    xmlns:a=\"http://xml.juniper.net/junos/15.1X49/junos\" >\n<version>15.1X49-D50.3</version>\n            <groups>\n                <name>node0</name>\n                <system>\n                   <tacplus-server>\n                        <name>${sync_auto-pop_name1}</name>\n                        <source-address>${sync_auto-pop_address1}</source-address>\n              </tacplus-server>\n                    <tacplus-server>\n                        <name>${node0_tacplus_server_name2}</name>\n          <source-address>${sync_auto-pop_address1}</source-address>\n                    </tacplus-server>\n                </system>         \n   </groups>\n    </configuration>"}' }) }) };
225     expect(component.appDataObject.template.nameValueData["payload"]).toBe(JSON.stringify(paramData["payload"]));
226     expect(component.appDataObject.template.templateData["payload"]).toBe(JSON.stringify(templateData["payload"]));
227   }));
228
229
230   it('test whether proper param data is getting set in the downloadDataObject', inject([MappingEditorService], (mappingEditorService: MappingEditorService) => {
231     fixture = TestBed.createComponent(GoldenConfigurationComponent);
232     component = fixture.componentInstance;
233     mappingEditorService.latestAction = { "action": "Configure", "action-level": "vnf", "scope": { "vnf-type": "testVnf", "vnfc-type": "" }, "template": "Y", "vm": [], "device-protocol": "CHEF", "user-name": "", "port-number": "", "artifact-list": [{ "artifact-name": "template_Configure_test_0.0.1V.json", "artifact-type": "config_template" }, { "artifact-name": "pd_Configure_test_0.0.1V.yaml", "artifact-type": "parameter_definitions" }], "scopeType": "vnf-type" };
234     component.ngOnInit();
235     component.ngAfterViewInit();
236     component.downloadDataObject = {
237       reference: {},
238       template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
239       pd: { pdData: '', pdFileName: '' }
240     };
241     localStorage["paramsContent"] = JSON.stringify({ "sync_auto-pop_name1": "testIp1", "sync_auto-pop_address1": "", "node0_tacplus_server_name2": "testIp2" });
242
243     component.onDownloadParameter();
244     var nameValueData = {
245       "sync_auto-pop_name1": "testIp1",
246       "sync_auto-pop_address1": "",
247       "node0_tacplus_server_name2": "testIp2"
248     };
249     expect(component.downloadDataObject.template.nameValueData).toBe(JSON.stringify(nameValueData, null, "\t"));
250     expect(component.downloadDataObject.template.nameValueFileName).toBe("param_Configure_testVnf_0.0.1V.json");
251   }));
252
253   it('test whether proper template data is getting set in the downloadDataObject', inject([MappingEditorService], (mappingEditorService: MappingEditorService) => {
254     fixture = TestBed.createComponent(GoldenConfigurationComponent);
255     component = fixture.componentInstance;
256     mappingEditorService.latestAction = { "action": "Configure", "action-level": "vnf", "scope": { "vnf-type": "testVnf", "vnfc-type": "" }, "template": "Y", "vm": [], "device-protocol": "CHEF", "user-name": "", "port-number": "", "artifact-list": [{ "artifact-name": "template_Configure_test_0.0.1V.json", "artifact-type": "config_template" }, { "artifact-name": "pd_Configure_test_0.0.1V.yaml", "artifact-type": "parameter_definitions" }], "scopeType": "vnf-type" };
257     component.ngOnInit();
258     component.ngAfterViewInit();
259     component.downloadDataObject = {
260       reference: {},
261       template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
262       pd: { pdData: '', pdFileName: '' }
263     };
264     component.configMappingEditorContent = "<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" \n    xmlns:a=\"http://xml.juniper.net/junos/15.1X49/junos\" >\n            <version>15.1X49-D50.3</version>\n            <groups>\n                <name>node0</name>\n                <system>\n                   <tacplus-server>\n                        <name>${sync_auto-pop_name1}</name>\n                        <source-address>${sync_auto-pop_address1}</source-address>\n                    </tacplus-server>\n                    <tacplus-server>\n                        <name>${node0_tacplus_server_name2}</name>\n                        <source-address>${sync_auto-pop_address1}</source-address>\n                    </tacplus-server>\n                </system>         \n           </groups>\n    </configuration>"
265     component.fileType = "text/xml"
266     component.onDownloadTemplate('Template');
267
268     component.fileType = "text/plain"
269     component.onDownloadTemplate('Template');
270     component.fileType = "text/json"
271     component.onDownloadTemplate('Template');
272     component.tempretrieveFlag = true;
273     component.fileNameForTempSave = "Configure_testVnf_0.0.1V.json"
274     component.onDownloadTemplate('Template');
275     expect(component.downloadDataObject.template.templateData).toBe(component.configMappingEditorContent.replace(/\(([^()]|(R))*\)=\(/g, '').replace(/\)}/g, '}'));
276    }));
277
278
279   it('test merge status for golden config template and uploaded parameter data', inject([MappingEditorService], (mappingEditorService: MappingEditorService) => {
280     fixture = TestBed.createComponent(GoldenConfigurationComponent);
281     component = fixture.componentInstance;
282     mappingEditorService.latestAction = { "action": "Configure", "action-level": "vnf", "scope": { "vnf-type": "testVnf", "vnfc-type": "" }, "template": "Y", "vm": [], "device-protocol": "CHEF", "user-name": "", "port-number": "", "artifact-list": [{ "artifact-name": "template_Configure_test_0.0.1V.json", "artifact-type": "config_template" }, { "artifact-name": "pd_Configure_test_0.0.1V.yaml", "artifact-type": "parameter_definitions" }], "scopeType": "vnf-type" };
283     component.ngOnInit();
284     component.ngAfterViewInit();
285     component.downloadDataObject = {
286       reference: {},
287       template: { templateData: {}, nameValueData: {}, templateFileName: '', nameValueFileName: '' },
288       pd: { pdData: '', pdFileName: '' }
289     };
290     component.configMappingEditorContent = "<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" \r\n    xmlns:a=\"http://xml.juniper.net/junos/15.1X49/junos\" >\r\n            <version>15.1X49-D50.3</version>\r\n            <groups>\r\n                <name>node0</name>\r\n                <system>\r\n                   <tacplus-server>\r\n                        <name>testIp1</name>\r\n                        <source-address>135.144.3.125</source-address>\r\n                    </tacplus-server>\r\n                    <tacplus-server>\r\n                        <name>199.37.184.242</name>\r\n                        <source-address>testIp2</source-address>\r\n                    </tacplus-server>\r\n                </system>         \r\n            </groups>\r\n     </configuration>";
291     mappingEditorService.initialise(component.templateeditor.getEditor(), component.configMappingEditorContent, component.modal);
292     localStorage["paramsContent"] = JSON.stringify({
293       "node0_tacplus_server_name1": "testIp1",
294       "node0_tacplus_server_source_address1": "675453432",
295       "node0_tacplus_server_name2": "testIp2"
296     });
297     component.mergeParams();
298     expect(component.mergeStatus).toBe(true);
299
300     component.configMappingEditorContent = "<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" \n    xmlns:a=\"http://xml.juniper.net/junos/15.1X49/junos\" >\n            <version>15.1X49-D50.3</version>\n            <groups>\n                <name>node0</name>\n                <system>\n                   <tacplus-server>\n                        <name>${sync_auto-pop_name1}</name>\n                        <source-address>${sync_auto-pop_address1}</source-address>\n                    </tacplus-server>\n                    <tacplus-server>\n                        <name>${node0_tacplus_server_name2}</name>\n                        <source-address>${sync_auto-pop_address1}</source-address>\n                    </tacplus-server>\n                </system>         \n           </groups>\n    </configuration>"
301     mappingEditorService.initialise(component.templateeditor.getEditor(), component.configMappingEditorContent, component.modal);
302     component.mergeParams();
303     expect(component.mergeStatus).toBe(false);
304
305   }));
306
307   it('test handleAnnotation method', inject([MappingEditorService], (mappingEditorService: MappingEditorService) => {
308     fixture = TestBed.createComponent(GoldenConfigurationComponent);
309     component = fixture.componentInstance;
310     mappingEditorService.latestAction = { "action": "Configure", "action-level": "vnf", "scope": { "vnf-type": "testVnf", "vnfc-type": "" }, "template": "Y", "vm": [], "device-protocol": "CHEF", "user-name": "", "port-number": "", "artifact-list": [{ "artifact-name": "template_Configure_test_0.0.1V.json", "artifact-type": "config_template" }, { "artifact-name": "pd_Configure_test_0.0.1V.yaml", "artifact-type": "parameter_definitions" }], "scopeType": "vnf-type" };
311     component.ngOnInit();
312     component.ngAfterViewInit();
313
314     component.configMappingEditorContent = "<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" \r\n    xmlns:a=\"http://xml.juniper.net/junos/15.1X49/junos\" >\r\n            <version>15.1X49-D50.3</version>\r\n            <groups>\r\n                <name>node0</name>\r\n                <system>\r\n                   <tacplus-server>\r\n                        <name>199.37.184.211</name>\r\n                        <source-address>675453432</source-address>\r\n                    </tacplus-server>\r\n                    <tacplus-server>\r\n                        <name>199.37.184.242</name>\r\n                        <source-address>675453432</source-address>\r\n                    </tacplus-server>\r\n                </system>         \r\n            </groups>\r\n     </configuration>";
315     mappingEditorService.initialise(component.templateeditor.getEditor(), component.configMappingEditorContent, component.modal);
316     component.selectedWord = "node0";
317     expect(component.handleAnnotation(component.modal));
318   }));
319
320   it('test handleAnnotation method', inject([MappingEditorService], (mappingEditorService: MappingEditorService) => {
321     fixture = TestBed.createComponent(GoldenConfigurationComponent);
322     component = fixture.componentInstance;
323     mappingEditorService.latestAction = { "action": "Configure", "action-level": "vnf", "scope": { "vnf-type": "testVnf", "vnfc-type": "" }, "template": "Y", "vm": [], "device-protocol": "CHEF", "user-name": "", "port-number": "", "artifact-list": [{ "artifact-name": "template_Configure_test_0.0.1V.json", "artifact-type": "config_template" }, { "artifact-name": "pd_Configure_test_0.0.1V.yaml", "artifact-type": "parameter_definitions" }], "scopeType": "vnf-type" };
324     component.ngOnInit();
325     component.ngAfterViewInit();
326
327     component.configMappingEditorContent = "<configuration xmlns=\"http://xml.juniper.net/xnm/1.1/xnm\" \r\n    xmlns:a=\"http://xml.juniper.net/junos/15.1X49/junos\" >\r\n            <version>15.1X49-D50.3</version>\r\n            <groups>\r\n                <name>node0</name>\r\n                <system>\r\n                   <tacplus-server>\r\n                        <name>{(node1)=(name1)}</name>\r\n                        <source-address>675453432</source-address>\r\n                    </tacplus-server>\r\n                    <tacplus-server>\r\n                        <name>199.37.184.242</name>\r\n                        <source-address>675453432</source-address>\r\n                    </tacplus-server>\r\n                </system>         \r\n            </groups>\r\n     </configuration>";
328     mappingEditorService.initialise(component.templateeditor.getEditor(), component.configMappingEditorContent, component.modal);
329     component.selectedWord = "node0";
330     component.tempName = "name0";
331     component.submitNameValues()
332     expect(component.replaceWord).toContain("{(node0)=(name0)}");
333     component.selectedWord = "{(node1)=(name1)}";
334     component.submitNameValues();
335     component.tempName = false;
336     component.submitNameValues();
337   }));
338
339   it('retrieveTemplateFromAppc function should return response on success and set the configMappingEditorContent object', inject([HttpUtilService, NgProgress, MappingEditorService, MockBackend], (httpUtilService: HttpUtilService, mappingEditorService: MappingEditorService, ngProgress: NgProgress, mockBackend: MockBackend) => {
340     fixture = TestBed.createComponent(GoldenConfigurationComponent);
341     component = fixture.componentInstance;
342     var mockData = {
343       "output": {
344         "data": {
345           "block": "{\"userID\":null,\"designInfo\":null,\"statusInfo\":null,\"artifactInfo\":[{\"artifact-content\":\"   <configuration xmlns=\\\"http://xml.juniper.net/xnm/1.1/xnm\\\" \\n    xmlns:a=\\\"http://xml.juniper.net/junos/15.1X49/junos\\\" >\\n            <version>15.1X49-D50.3</version>\\n            <groups>\\n                <name>node0</name>\\n                <system>\\n                   <tacplus-server>\\n                        <name>${sync_auto-pop_name1}</name>\\n                        <source-address>${sync_auto-pop_address1}</source-address>\\n                    </tacplus-server>\\n                    <tacplus-server>\\n                        <name>${node0_tacplus_server_name2}</name>\\n                        <source-address>${sync_auto-pop_address1}</source-address>\\n                    </tacplus-server>\\n                </system>         \\n           </groups>\\n    </configuration>\"}]}",
346           "requestId": "497085412083"
347         },
348         "status": {
349           "code": "400",
350           "message": "success"
351         }
352       }
353     }
354     let response = new ResponseOptions({
355       body: JSON.stringify(mockData)
356     });
357     const baseResponse = new Response(response);
358     mockBackend.connections.subscribe(
359       (c: MockConnection) => c.mockRespond(baseResponse)
360     );
361
362     mappingEditorService.latestAction = { "action": "Configure", "action-level": "vnf", "scope": { "vnf-type": "testVnf", "vnfc-type": "" }, "template": "Y", "vm": [], "device-protocol": "CHEF", "user-name": "", "port-number": "", "artifact-list": [{ "artifact-name": "template_Configure_test_0.0.1V.json", "artifact-type": "config_template" }, { "artifact-name": "pd_Configure_test_0.0.1V.yaml", "artifact-type": "parameter_definitions" }], "scopeType": "vnf-type" }
363
364     mappingEditorService.fromScreen = 'MappingScreen';
365     component.action = 'Configure';
366     component.refObj = mappingEditorService.latestAction;
367     component.scopeName = "testVnf";
368     component.vnfType = "testVnf";
369     component.userId = "abc";
370     component.item.action = "Configure";
371     component.retrieveTemplateFromAppc();
372     expect(component.configMappingEditorContent).not.toBe(null);
373
374   }));
375
376 });