1 import {HttpClientTestingModule} from "@angular/common/http/testing";
2 import {getTestBed, TestBed} from "@angular/core/testing";
3 import {MockNgRedux, NgReduxTestingModule} from "@angular-redux/store/testing";
4 import {VnfGroupingModelInfo} from "./vnfGrouping.model.info";
5 import {DynamicInputsService} from "../../dynamicInputs.service";
6 import {SharedTreeService} from "../../shared.tree.service";
7 import {VnfGroupPopupService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service";
8 import {DialogService} from "ng2-bootstrap-modal";
9 import {AvailableNodeIcons} from "../../../available-models-tree/available-models-tree.service";
10 import {VnfGroupModel} from "../../../../../shared/models/vnfGroupModel";
11 import {IframeService} from "../../../../../shared/utils/iframe.service";
12 import {RouterTestingModule} from "@angular/router/testing";
13 import {DrawingBoardModes} from "../../../drawing-board.modes";
14 import {AaiService} from "../../../../../shared/services/aaiService/aai.service";
15 import {FeatureFlagsService} from "../../../../../shared/services/featureFlag/feature-flags.service";
16 import {ITableContent} from "../../../../../shared/components/searchMembersModal/members-table/element-table-row.model";
18 describe('VnfGroupingModelInfo Model Info', () => {
20 let _dialogService : DialogService;
21 let _vnfGroupPopupService : VnfGroupPopupService;
22 let _dynamicInputsService : DynamicInputsService;
23 let _sharedTreeService : SharedTreeService;
24 let _iframeService : IframeService;
25 let vnfGroupModel: VnfGroupingModelInfo;
26 let _aaiService : AaiService;
27 beforeAll(done => (async () => {
28 TestBed.configureTestingModule({
29 imports: [HttpClientTestingModule, NgReduxTestingModule, RouterTestingModule],
40 await TestBed.compileComponents();
41 injector = getTestBed();
42 _sharedTreeService = injector.get(SharedTreeService);
43 _aaiService = injector.get(AaiService);
45 vnfGroupModel = new VnfGroupingModelInfo(_dynamicInputsService, _sharedTreeService, _dialogService, _vnfGroupPopupService, _iframeService, _aaiService, MockNgRedux.getInstance());
46 })().then(done).catch(done.fail));
49 test('VnfGroupingModelInfo should be defined', () => {
50 expect(vnfGroupModel).toBeDefined();
53 test('VnfGroupingModelInfo should defined extra details', () => {
54 expect(vnfGroupModel.name).toEqual('vnfGroups');
55 expect(vnfGroupModel.type).toEqual('VnfGroup');
58 test('isEcompGeneratedNaming should return true if vnf group has isEcompGeneratedNaming is "true" ', () => {
59 let isEcompGeneratedNaming : boolean = vnfGroupModel.isEcompGeneratedNaming({
61 ecomp_generated_naming: 'true'
64 expect(isEcompGeneratedNaming).toBeTruthy();
67 test('getTooltip should return "vnfGrouping"', () => {
68 let tooltip: string = vnfGroupModel.getTooltip();
69 expect(tooltip).toEqual('VnfGroup');
72 test('getType should return "vnfGrouping"', () => {
73 let tooltip: string = vnfGroupModel.getType();
74 expect(tooltip).toEqual('VnfGroup');
77 test('getNextLevelObject should return null', () => {
78 let nextLevel = vnfGroupModel.getNextLevelObject();
79 expect(nextLevel).not.toBeNull();
82 test('showNodeIcons should return true if not reachLimit of max', ()=>{
83 let serviceId : string = 'servicedId';
90 jest.spyOn(MockNgRedux.getInstance(), 'getState').mockReturnValue({
92 drawingBoardStatus: "EDIT"
107 'existingVnfGroupCounterMap' : {
120 let result = vnfGroupModel.showNodeIcons(<any>node, serviceId);
121 expect(result).toEqual(new AvailableNodeIcons(true , false));
124 test('getNodeCount should return number of nodes', ()=>{
125 let serviceId : string = 'servicedId';
126 jest.spyOn(_sharedTreeService, 'getExistingInstancesWithDeleteMode').mockReturnValue(0);
127 jest.spyOn(MockNgRedux.getInstance(), 'getState').mockReturnValue({
142 'existingVnfGroupCounterMap' : {
147 'originalName' : 'vnfGroupName'
158 name : 'vnfGroupName',
159 modelUniqueId: 'vnfGroupId',
162 let result = vnfGroupModel.getNodeCount(<any>node , serviceId);
163 expect(result).toEqual(1);
165 node.data.modelUniqueId = 'vnfGroupId_notExist';
166 result = vnfGroupModel.getNodeCount(<any>node , serviceId);
167 expect(result).toEqual(0);
169 result = vnfGroupModel.getNodeCount(<any>node , serviceId + '_notExist');
170 expect(result).toEqual(0);
173 test('getModel should return VnfGroup model', () => {
174 let model: VnfGroupModel = vnfGroupModel.getModel('ResourceGroup0', <any>{
175 originalName : 'ResourceGroup0'
176 }, getServiceHierarchy());
177 expect(model.type).toEqual('VnfGroup');
180 test('getMenuAction: showAuditInfoVnfGroup', ()=>{
182 jest.spyOn(MockNgRedux.getInstance(), 'getState').mockReturnValue({
184 "drawingBoardStatus": DrawingBoardModes.RETRY
187 jest.spyOn(_sharedTreeService, 'isRetryMode').mockReturnValue(true);
190 "modelId": "6b528779-44a3-4472-bdff-9cd15ec93450",
195 let serviceModelId = "6b528779-44a3-4472-bdff-9cd15ec93450";
196 let result = vnfGroupModel.getMenuAction(<any>node, serviceModelId);
197 spyOn(result['showAuditInfo'], 'method');
198 expect(result['showAuditInfo']).toBeDefined();
199 expect(result['showAuditInfo'].visible(node)).toBeTruthy();
200 expect(result['showAuditInfo'].enable(node)).toBeTruthy();
201 result['showAuditInfo']['method'](node, serviceModelId);
202 expect(result['showAuditInfo']['method']).toHaveBeenCalledWith(node, serviceModelId);
206 test('generateRelatedMemberTableContent', ()=> {
207 const tableContents: ITableContent[] = vnfGroupModel.generateRelatedMemberTableContent();
208 expect(tableContents).toEqual([
212 id: ['instanceName'],
213 value: ['instanceName']
216 value: ["instanceId"],
223 id: ['modelInfo', 'modelVersion'],
224 value: ['modelInfo', 'modelVersion']
230 id: ['modelInfo', 'modelName'],
231 value: ['modelInfo', 'modelName']
238 value: ['provStatus']
242 id: 'serviceInstance',
244 id: ['serviceInstanceName'],
245 value: ['serviceInstanceName']
247 id: ['serviceInstanceId'],
248 value: ["serviceInstanceId"],
255 id: ['lcpCloudRegionId'],
256 value: ['lcpCloudRegionId']
263 value: ['tenantName']
269 function getServiceHierarchy(){
272 "uuid": "6b528779-44a3-4472-bdff-9cd15ec93450",
273 "invariantUuid": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
274 "name": "action-data",
276 "toscaModelURL": null,
281 "serviceEcompNaming": "false",
282 "instantiationType": "Macro",
284 "2017488_pasqualevpe0_ASN": {
286 "description": "AV/PE",
287 "entry_schema": null,
288 "inputProperties": null,
295 "instantiationUI": "legacy",
296 "modelCategory": "other"
302 "uuid": "0903e1c0-8e03-4936-b5c2-260653b96413",
303 "invariantUuid": "00beb8f9-6d39-452f-816d-c709b9cbb87d",
305 "name": "ResourceGroup0",
306 "modelCustomizationName": "ResourceGroup0",
308 "contained_resource_type": "VF",
309 "role": "SERVICE-ACCESS",
311 "description": "DDD0",
315 "vdorothea_svc_vprs_proxy 0": {
316 "uuid": "65fadfa8-a0d9-443f-95ad-836cd044e26c",
317 "invariantUuid": "f4baae0c-b3a5-4ca1-a777-afbffe7010bc",
318 "description": "A Proxy for Service vDOROTHEA_Svc_vPRS",
319 "name": "vDOROTHEA_Svc_vPRS Service Proxy",
321 "customizationUuid": "bdb63d23-e132-4ce7-af2c-a493b4cafac9",
325 "type": "Service Proxy",
326 "sourceModelUuid": "da7827a2-366d-4be6-8c68-a69153c61274",
327 "sourceModelInvariant": "24632e6b-584b-4f45-80d4-fefd75fd9f14",
328 "sourceModelName": "vDOROTHEA_Svc_vPRS"
330 "vdorothea_svc_vprs_proxy 1": {
331 "uuid": "111dfa8-a0d9-443f-95ad-836cd044e26c",
332 "invariantUuid": "111ae0c-b3a5-4ca1-a777-afbffe7010bc",
333 "description": "A Proxy for Service vDOROTHEA_Svc_vPRS",
334 "name": "111_Svc_vPRS Service Proxy",
336 "customizationUuid": "1113d23-e132-4ce7-af2c-a493b4cafac9",
340 "type": "Service Proxy",
341 "sourceModelUuid": "11127a2-366d-4be6-8c68-a69153c61274",
342 "sourceModelInvariant": "1112e6b-584b-4f45-80d4-fefd75fd9f14",
343 "sourceModelName": "111_Svc_vPRS"
349 "collectionResources": {},
350 "configurations": {},
351 "fabricConfigurations": {},
352 "serviceProxies": {},
359 function loadMockMembers(): any[] {
363 "instanceName": "VNF1_INSTANCE_NAME",
364 "instanceId": "VNF1_INSTANCE_ID",
366 "productFamilyId": null,
367 "lcpCloudRegionId": "hvf23b",
368 "tenantId": "3e9a20a3e89e45f884e09df0cc2d2d2a",
369 "tenantName": "APPC-24595-T-IST-02C",
371 "modelInvariantId": "vnf-instance-model-invariant-id",
372 "modelVersionId": "7a6ee536-f052-46fa-aa7e-2fca9d674c44",
373 "modelVersion": "2.0",
374 "modelName": "vf_vEPDG",
377 "instanceType": "VNF1_INSTANCE_TYPE",
380 "uuid": "7a6ee536-f052-46fa-aa7e-2fca9d674c44",
381 "originalName": null,
382 "legacyRegion": null,
383 "lineOfBusiness": null,
384 "platformName": null,
385 "trackById": "7a6ee536-f052-46fa-aa7e-2fca9d674c44:002",
386 "serviceInstanceId": "service-instance-id1",
387 "serviceInstanceName": "service-instance-name"
391 "instanceName": "VNF2_INSTANCE_NAME",
392 "instanceId": "VNF2_INSTANCE_ID",
394 "productFamilyId": null,
395 "lcpCloudRegionId": "hvf23b",
396 "tenantId": "3e9a20a3e89e45f884e09df0cc2d2d2a",
397 "tenantName": "APPC-24595-T-IST-02C",
399 "modelInvariantId": "vnf-instance-model-invariant-id",
400 "modelVersionId": "eb5f56bf-5855-4e61-bd00-3e19a953bf02",
401 "modelVersion": "1.0",
402 "modelName": "vf_vEPDG",
405 "instanceType": "VNF2_INSTANCE_TYPE",
408 "uuid": "eb5f56bf-5855-4e61-bd00-3e19a953bf02",
409 "originalName": null,
410 "legacyRegion": null,
411 "lineOfBusiness": null,
412 "platformName": null,
413 "trackById": "eb5f56bf-5855-4e61-bd00-3e19a953bf02:003",
414 "serviceInstanceId": "service-instance-id2",
415 "serviceInstanceName": "service-instance-name"