ca041e04552da0d0d3949f6ea72629a4a884ab93
[vid.git] / vid-webpack-master / src / app / drawingBoard / service-planning / objectsToTree / models / pnf / pnf.model.info.spec.ts
1 import {ComponentInfoService} from "../../../component-info/component-info.service";
2 import {AppState} from "../../../../../shared/store/reducers";
3 import {NgRedux} from "@angular-redux/store";
4 import {PnfModelInfo} from "./pnf.model.info";
5 import {getTestBed, TestBed} from "@angular/core/testing";
6 import {DynamicInputsService} from "../../dynamicInputs.service";
7 import {SharedTreeService} from "../../shared.tree.service";
8 import {DuplicateService} from "../../../duplicate/duplicate.service";
9 import {AaiService} from "../../../../../shared/services/aaiService/aai.service";
10 import {FeatureFlagsService} from "../../../../../shared/services/featureFlag/feature-flags.service";
11 import {IframeService} from "../../../../../shared/utils/iframe.service";
12 import {HttpClientTestingModule} from "@angular/common/http/testing";
13 import {MockNgRedux, NgReduxTestingModule} from "@angular-redux/store/testing";
14 import {HttpClient, HttpHandler} from "@angular/common/http";
15 import {CollectionResourceModel} from "../../../../../shared/models/collectionResourceModel";
16 import {ComponentInfoType} from "../../../component-info/component-info-model";
17
18
19 describe('PNF model info', () => {
20   let injector;
21   let _componentInfoService: ComponentInfoService;
22   let _store: NgRedux<AppState>;
23   let pnfModel: PnfModelInfo =  new PnfModelInfo();
24   beforeEach(() => {
25     TestBed.configureTestingModule({
26       imports: [HttpClientTestingModule, NgReduxTestingModule],
27       providers: [
28         MockNgRedux,
29         DynamicInputsService,
30         SharedTreeService,
31         DuplicateService,
32         AaiService,
33         HttpClient,
34         HttpHandler,
35         FeatureFlagsService,
36         ComponentInfoService,
37         IframeService]
38     }).compileComponents();
39
40     injector = getTestBed();
41     _store = injector.get(NgRedux);
42     _componentInfoService = injector.get(ComponentInfoService);
43   });
44
45   test('pnf model should be defined', () => {
46     expect(pnfModel).toBeDefined();
47   });
48
49   test('pnf model should defined extra details', () => {
50     expect(pnfModel.name).toEqual('pnfs');
51     expect(pnfModel.type).toEqual('PNF');
52     expect(pnfModel.typeName).toEqual('PNF');
53     expect(pnfModel.componentInfoType).toEqual(ComponentInfoType.PNF);
54   });
55
56   test('getTooltip should return "PNF"', () => {
57     let tooltip: string = pnfModel.getTooltip();
58     expect(tooltip).toEqual('PNF');
59   });
60
61   test('getType should return "pnf"', () => {
62     let tooltip: string = pnfModel.getType();
63     expect(tooltip).toEqual('pnf');
64   });
65
66   test('getNextLevelObject should be null', () => {
67     let nextLevel: any = pnfModel.getNextLevelObject();
68     expect(nextLevel).toBeNull();
69   });
70
71   test('isEcompGeneratedNaming should return false', () => {
72     let isEcompGeneratedNaming: boolean = pnfModel.isEcompGeneratedNaming(<any>{});
73     expect(isEcompGeneratedNaming).toBeFalsy();
74   });
75
76   test('getModel should return pnf model', () => {
77     let model: CollectionResourceModel = pnfModel.getModel('PNF1', <any>{
78       originalName : 'PNF1'
79     }, getServiceHierarchy());
80     expect(model.type).toEqual('PNF');
81   });
82
83   function getServiceHierarchy(){
84     return {
85       "service": {
86         "uuid": "12550cd7-7708-4f53-a09e-41d3d6327ebc",
87         "invariantUuid": "561faa57-7bbb-40ec-a81c-c0d4133e98d4",
88         "name": "AIM Transport SVC_ym161f",
89         "version": "1.0",
90         "toscaModelURL": null,
91         "category": "Network L1-3",
92         "serviceType": "TRANSPORT",
93         "serviceRole": "AIM",
94         "description": "AIM Transport service",
95         "serviceEcompNaming": "true",
96         "instantiationType": "Macro",
97         "inputs": {},
98         "vidNotions": {
99           "instantiationUI": "legacy",
100           "modelCategory": "other",
101           "viewEditUI": "legacy"
102         }
103       },
104       "vnfs": {},
105       "networks": {},
106       "collectionResources": {},
107       "configurations": {},
108       "fabricConfigurations": {},
109       "serviceProxies": {},
110       "vfModules": {},
111       "volumeGroups": {},
112       "pnfs": {
113         "PNF1": {
114           "uuid": "1c831fa9-28a6-4778-8c1d-80b9e769f2ed",
115           "invariantUuid": "74e13a12-dac9-4fba-b102-cd242d9e7f02",
116           "description": "AIM Transport service",
117           "name": "AIM PNF Model",
118           "version": "1.0",
119           "customizationUuid": "dce78da7-c842-47a1-aba2-2de1cd03ab7a",
120           "inputs": {},
121           "commands": {},
122           "properties": {
123             "nf_function": "SDNGW",
124             "nf_role": "pD2IPE",
125             "ecomp_generated_naming": "false",
126             "nf_type": "ROUTER"
127           },
128           "type": "PNF"
129         }
130       },
131       "vnfGroups": {}
132     }
133   }
134 })