Merge "PombaReqest and ServiceInstance improvements"
[vid.git] / vid-webpack-master / src / app / drawingBoard / service-planning / available-models-tree / available-models-tree.service.spec.ts
1 import {TestBed, getTestBed} from '@angular/core/testing';
2 import {
3   HttpClientTestingModule,
4   HttpTestingController
5 } from '@angular/common/http/testing';
6 import {AvailableModelsTreeService, AvailableNodeIcons} from './available-models-tree.service';
7 import {ServiceNodeTypes} from "../../../shared/models/ServiceNodeTypes";
8 import {DefaultDataGeneratorService} from "../../../shared/services/defaultDataServiceGenerator/default.data.generator.service";
9 import {MessageBoxService} from "../../../shared/components/messageBox/messageBox.service";
10 import {MessageBoxData} from "../../../shared/components/messageBox/messageBox.data";
11 import {SdcUiCommon} from "onap-ui-angular";
12 import {MockNgRedux, NgReduxTestingModule} from "@angular-redux/store/testing";
13 import {SharedTreeService} from "../objectsToTree/shared.tree.service";
14
15 describe('Available Models Tree Service', () => {
16
17   let injector;
18   let service: AvailableModelsTreeService;
19   let httpMock: HttpTestingController;
20
21   beforeAll(done => (async () => {
22     TestBed.configureTestingModule({
23       imports: [HttpClientTestingModule, NgReduxTestingModule],
24       providers: [AvailableModelsTreeService,
25         DefaultDataGeneratorService,
26         SharedTreeService,
27         MockNgRedux]
28     });
29     await TestBed.compileComponents();
30       injector = getTestBed();
31       service = injector.get(AvailableModelsTreeService);
32       httpMock = injector.get(HttpTestingController);
33   })().then(done).catch(done.fail));
34
35
36   test('addingAlertAddingNewVfModuleModal should open message modal', () => {
37     jest.spyOn(MessageBoxService.openModal, 'next');
38     service.addingAlertAddingNewVfModuleModal();
39
40     expect(MessageBoxService.openModal.next).toHaveBeenCalledWith(new MessageBoxData(
41       "Select a parent",  // modal title
42       "There are multiple instances on the right side that can contain this vf-module Please select the VNF instance, to add this vf-module to, on the right side and then click the + sign",
43       SdcUiCommon.ModalType.warning,
44       SdcUiCommon.ModalSize.medium,
45       [
46         {text: "Close", size: "medium", closeModal: true}
47       ]));
48   });
49
50
51
52   describe('#shouldOpenModalDialogOnAddInstance', () => {
53     let serviceHierarchy = getServiceServiceHierarchy();
54
55     test('should open popup on add instance', () => {
56       // add vnf should return true
57       let result = service.shouldOpenDialog(ServiceNodeTypes.VF, [], true);
58       expect(result).toBeTruthy();
59
60       //  add vfModule with user provided naming should return true
61       result = service.shouldOpenDialog(ServiceNodeTypes.VFmodule, [], false);
62       expect(result).toBeTruthy();
63
64       //  add vfModule with dynamicInputs without defaultValues should return true
65       result = service.shouldOpenDialog(ServiceNodeTypes.VFmodule, [{
66         id: '2017488_adiodvpe0_vnf_config_template_version',
67         type: 'string',
68         name: '2017488_adiodvpe0_vnf_config_template_version',
69         isRequired: true,
70         description: 'VPE Software Version'
71       }], true);
72       expect(result).toBeTruthy();
73
74       // add vfModule with dynamicInputs with defaultValues should return false
75       result = service.shouldOpenDialog(ServiceNodeTypes.VFmodule, [{
76         id: '2017488_adiodvpe0_vnf_config_template_version',
77         type: 'string',
78         name: '2017488_adiodvpe0_vnf_config_template_version',
79         value: '17.2',
80         isRequired: true,
81         description: 'VPE Software Version'
82       }], true);
83       expect(result).toBeFalsy();
84     });
85   });
86
87   function getServiceServiceHierarchy() {
88     return JSON.parse(JSON.stringify(
89       {
90         '6e59c5de-f052-46fa-aa7e-2fca9d674c44': {
91           'service': {
92             'uuid': '6e59c5de-f052-46fa-aa7e-2fca9d674c44',
93             'invariantUuid': 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0',
94             'name': 'ComplexService',
95             'version': '1.0',
96             'toscaModelURL': null,
97             'category': 'Emanuel',
98             'serviceType': '',
99             'serviceRole': '',
100             'description': 'ComplexService',
101             'serviceEcompNaming': 'true',
102             'instantiationType': 'Macro',
103             'inputs': {}
104           },
105           'vnfs': {
106             'VF_vMee 0': {
107               'uuid': 'd6557200-ecf2-4641-8094-5393ae3aae60',
108               'invariantUuid': '4160458e-f648-4b30-a176-43881ffffe9e',
109               'description': 'VSP_vMee',
110               'name': 'VF_vMee',
111               'version': '2.0',
112               'customizationUuid': '91415b44-753d-494c-926a-456a9172bbb9',
113               'inputs': {},
114               'commands': {},
115               'properties': {
116                 'max_instances': '3',
117                 'min_instances': '1',
118                 'gpb2_Internal2_mac': '00:11:22:EF:AC:DF',
119                 'sctp-b-ipv6-egress_src_start_port': '0',
120                 'sctp-a-ipv6-egress_rule_application': 'any',
121                 'Internal2_allow_transit': 'true',
122                 'sctp-b-IPv6_ethertype': 'IPv6',
123                 'sctp-a-egress_rule_application': 'any',
124                 'sctp-b-ingress_action': 'pass',
125                 'sctp-b-ingress_rule_protocol': 'icmp',
126                 'ncb2_Internal1_mac': '00:11:22:EF:AC:DF',
127                 'sctp-b-ipv6-ingress-src_start_port': '0.0',
128                 'ncb1_Internal2_mac': '00:11:22:EF:AC:DF',
129                 'fsb_volume_size_0': '320.0',
130                 'sctp-b-egress_src_addresses': 'local',
131                 'sctp-a-ipv6-ingress_ethertype': 'IPv4',
132                 'sctp-a-ipv6-ingress-dst_start_port': '0',
133                 'sctp-b-ipv6-ingress_rule_application': 'any',
134                 'domain_name': 'default-domain',
135                 'sctp-a-ingress_rule_protocol': 'icmp',
136                 'sctp-b-egress-src_start_port': '0.0',
137                 'sctp-a-egress_src_addresses': 'local',
138                 'sctp-b-display_name': 'epc-sctp-b-ipv4v6-sec-group',
139                 'sctp-a-egress-src_start_port': '0.0',
140                 'sctp-a-ingress_ethertype': 'IPv4',
141                 'sctp-b-ipv6-ingress-dst_end_port': '65535',
142                 'sctp-b-dst_subnet_prefix_v6': '::',
143                 'nf_naming': '{ecomp_generated_naming=true}',
144                 'sctp-a-ipv6-ingress_src_subnet_prefix': '0.0.0.0',
145                 'sctp-b-egress-dst_start_port': '0.0',
146                 'ncb_flavor_name': 'nv.c20r64d1',
147                 'gpb1_Internal1_mac': '00:11:22:EF:AC:DF',
148                 'sctp-b-egress_dst_subnet_prefix_len': '0.0',
149                 'Internal2_net_cidr': '10.0.0.10',
150                 'sctp-a-ingress-dst_start_port': '0.0',
151                 'sctp-a-egress-dst_start_port': '0.0',
152                 'fsb1_Internal2_mac': '00:11:22:EF:AC:DF',
153                 'sctp-a-egress_ethertype': 'IPv4',
154                 'vlc_st_service_mode': 'in-network-nat',
155                 'sctp-a-ipv6-egress_ethertype': 'IPv4',
156                 'sctp-a-egress-src_end_port': '65535.0',
157                 'sctp-b-ipv6-egress_rule_application': 'any',
158                 'sctp-b-egress_action': 'pass',
159                 'sctp-a-ingress-src_subnet_prefix_len': '0.0',
160                 'sctp-b-ipv6-ingress-src_end_port': '65535.0',
161                 'sctp-b-name': 'epc-sctp-b-ipv4v6-sec-group',
162                 'fsb2_Internal1_mac': '00:11:22:EF:AC:DF',
163                 'sctp-a-ipv6-ingress-src_start_port': '0.0',
164                 'sctp-b-ipv6-egress_ethertype': 'IPv4',
165                 'Internal1_net_cidr': '10.0.0.10',
166                 'sctp-a-egress_dst_subnet_prefix': '0.0.0.0',
167                 'fsb_flavor_name': 'nv.c20r64d1',
168                 'sctp_rule_protocol': '132',
169                 'sctp-b-ipv6-ingress_src_subnet_prefix_len': '0',
170                 'sctp-a-ipv6-ingress_rule_application': 'any',
171                 'sctp-a-IPv6_ethertype': 'IPv6',
172                 'vlc2_Internal1_mac': '00:11:22:EF:AC:DF',
173                 'vlc_st_virtualization_type': 'virtual-machine',
174                 'sctp-b-ingress-dst_start_port': '0.0',
175                 'sctp-b-ingress-dst_end_port': '65535.0',
176                 'sctp-a-ipv6-ingress-src_end_port': '65535.0',
177                 'sctp-a-display_name': 'epc-sctp-a-ipv4v6-sec-group',
178                 'sctp-b-ingress_rule_application': 'any',
179                 'int2_sec_group_name': 'int2-sec-group',
180                 'vlc_flavor_name': 'nd.c16r64d1',
181                 'sctp-b-ipv6-egress_src_addresses': 'local',
182                 'vlc_st_interface_type_int1': 'other1',
183                 'sctp-b-egress-src_end_port': '65535.0',
184                 'sctp-a-ipv6-egress-dst_start_port': '0',
185                 'vlc_st_interface_type_int2': 'other2',
186                 'sctp-a-ipv6-egress_rule_protocol': 'any',
187                 'Internal2_shared': 'false',
188                 'sctp-a-ipv6-egress_dst_subnet_prefix_len': '0',
189                 'Internal2_rpf': 'disable',
190                 'vlc1_Internal1_mac': '00:11:22:EF:AC:DF',
191                 'sctp-b-ipv6-egress_src_end_port': '65535',
192                 'sctp-a-ipv6-egress_src_addresses': 'local',
193                 'sctp-a-ingress-dst_end_port': '65535.0',
194                 'sctp-a-ipv6-egress_src_end_port': '65535',
195                 'Internal1_forwarding_mode': 'l2',
196                 'Internal2_dhcp': 'false',
197                 'sctp-a-dst_subnet_prefix_v6': '::',
198                 'pxe_image_name': 'MME_PXE-Boot_16ACP04_GA.qcow2',
199                 'vlc_st_interface_type_gtp': 'other0',
200                 'ncb1_Internal1_mac': '00:11:22:EF:AC:DF',
201                 'sctp-b-src_subnet_prefix_v6': '::',
202                 'sctp-a-egress_dst_subnet_prefix_len': '0.0',
203                 'int1_sec_group_name': 'int1-sec-group',
204                 'Internal1_dhcp': 'false',
205                 'sctp-a-ipv6-egress_dst_end_port': '65535',
206                 'Internal2_forwarding_mode': 'l2',
207                 'fsb2_Internal2_mac': '00:11:22:EF:AC:DF',
208                 'sctp-b-egress_dst_subnet_prefix': '0.0.0.0',
209                 'Internal1_net_cidr_len': '17',
210                 'gpb2_Internal1_mac': '00:11:22:EF:AC:DF',
211                 'sctp-b-ingress-src_subnet_prefix_len': '0.0',
212                 'sctp-a-ingress_dst_addresses': 'local',
213                 'sctp-a-egress_action': 'pass',
214                 'fsb_volume_type_0': 'SF-Default-SSD',
215                 'ncb2_Internal2_mac': '00:11:22:EF:AC:DF',
216                 'vlc_st_interface_type_sctp_a': 'left',
217                 'vlc_st_interface_type_sctp_b': 'right',
218                 'sctp-a-src_subnet_prefix_v6': '::',
219                 'vlc_st_version': '2',
220                 'sctp-b-egress_ethertype': 'IPv4',
221                 'sctp-a-ingress_rule_application': 'any',
222                 'gpb1_Internal2_mac': '00:11:22:EF:AC:DF',
223                 'instance_ip_family_v6': 'v6',
224                 'sctp-a-ipv6-egress_src_start_port': '0',
225                 'sctp-b-ingress-src_start_port': '0.0',
226                 'sctp-b-ingress_dst_addresses': 'local',
227                 'fsb1_Internal1_mac': '00:11:22:EF:AC:DF',
228                 'vlc_st_interface_type_oam': 'management',
229                 'multi_stage_design': 'false',
230                 'oam_sec_group_name': 'oam-sec-group',
231                 'Internal2_net_gateway': '10.0.0.10',
232                 'sctp-a-ipv6-ingress-dst_end_port': '65535',
233                 'sctp-b-ipv6-egress-dst_start_port': '0',
234                 'Internal1_net_gateway': '10.0.0.10',
235                 'sctp-b-ipv6-egress_rule_protocol': 'any',
236                 'gtp_sec_group_name': 'gtp-sec-group',
237                 'sctp-a-ipv6-egress_dst_subnet_prefix': '0.0.0.0',
238                 'sctp-b-ipv6-egress_dst_subnet_prefix_len': '0',
239                 'sctp-a-ipv6-ingress_dst_addresses': 'local',
240                 'sctp-a-egress_rule_protocol': 'icmp',
241                 'sctp-b-ipv6-egress_action': 'pass',
242                 'sctp-a-ipv6-egress_action': 'pass',
243                 'Internal1_shared': 'false',
244                 'sctp-b-ipv6-ingress_rule_protocol': 'any',
245                 'Internal2_net_cidr_len': '17',
246                 'sctp-a-name': 'epc-sctp-a-ipv4v6-sec-group',
247                 'sctp-a-ingress-src_end_port': '65535.0',
248                 'sctp-b-ipv6-ingress_src_subnet_prefix': '0.0.0.0',
249                 'sctp-a-egress-dst_end_port': '65535.0',
250                 'sctp-a-ingress_action': 'pass',
251                 'sctp-b-egress_rule_protocol': 'icmp',
252                 'sctp-b-ipv6-ingress_action': 'pass',
253                 'vlc_st_service_type': 'firewall',
254                 'sctp-b-ipv6-egress_dst_end_port': '65535',
255                 'sctp-b-ipv6-ingress-dst_start_port': '0',
256                 'vlc2_Internal2_mac': '00:11:22:EF:AC:DF',
257                 'vlc_st_availability_zone': 'true',
258                 'fsb_volume_image_name_1': 'MME_FSB2_16ACP04_GA.qcow2',
259                 'sctp-b-ingress-src_subnet_prefix': '0.0.0.0',
260                 'sctp-a-ipv6-ingress_src_subnet_prefix_len': '0',
261                 'Internal1_allow_transit': 'true',
262                 'gpb_flavor_name': 'nv.c20r64d1',
263                 'availability_zone_max_count': '1',
264                 'fsb_volume_image_name_0': 'MME_FSB1_16ACP04_GA.qcow2',
265                 'sctp-b-ipv6-ingress_dst_addresses': 'local',
266                 'sctp-b-ipv6-egress_dst_subnet_prefix': '0.0.0.0',
267                 'sctp-b-ipv6-ingress_ethertype': 'IPv4',
268                 'vlc1_Internal2_mac': '00:11:22:EF:AC:DF',
269                 'sctp-a-ingress-src_subnet_prefix': '0.0.0.0',
270                 'sctp-a-ipv6-ingress_action': 'pass',
271                 'Internal1_rpf': 'disable',
272                 'sctp-b-ingress_ethertype': 'IPv4',
273                 'sctp-b-egress_rule_application': 'any',
274                 'sctp-b-ingress-src_end_port': '65535.0',
275                 'sctp-a-ipv6-ingress_rule_protocol': 'any',
276                 'sctp-a-ingress-src_start_port': '0.0',
277                 'sctp-b-egress-dst_end_port': '65535.0'
278               },
279               'type': 'VF',
280               'modelCustomizationName': 'VF_vMee 0',
281               'vfModules': {
282                 'vf_vmee0..VfVmee..vmme_vlc..module-1': {
283                   'uuid': '522159d5-d6e0-4c2a-aa44-5a542a12a830',
284                   'invariantUuid': '98a7c88b-b577-476a-90e4-e25a5871e02b',
285                   'customizationUuid': '55b1be94-671a-403e-a26c-667e9c47d091',
286                   'description': null,
287                   'name': 'VfVmee..vmme_vlc..module-1',
288                   'version': '2',
289                   'modelCustomizationName': 'VfVmee..vmme_vlc..module-1',
290                   'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0},
291                   'commands': {},
292                   'volumeGroupAllowed': false
293                 },
294                 'vf_vmee0..VfVmee..vmme_gpb..module-2': {
295                   'uuid': '41708296-e443-4c71-953f-d9a010f059e1',
296                   'invariantUuid': '1cca90b8-3490-495e-87da-3f3e4c57d5b9',
297                   'customizationUuid': '6add59e0-7fe1-4bc4-af48-f8812422ae7c',
298                   'description': null,
299                   'name': 'VfVmee..vmme_gpb..module-2',
300                   'version': '2',
301                   'modelCustomizationName': 'VfVmee..vmme_gpb..module-2',
302                   'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0},
303                   'commands': {},
304                   'volumeGroupAllowed': false
305                 },
306                 'vf_vmee0..VfVmee..base_vmme..module-0': {
307                   'uuid': 'a27f5cfc-7f12-4f99-af08-0af9c3885c87',
308                   'invariantUuid': 'a6f9e51a-2b35-416a-ae15-15e58d61f36d',
309                   'customizationUuid': 'f8c040f1-7e51-4a11-aca8-acf256cfd861',
310                   'description': null,
311                   'name': 'VfVmee..base_vmme..module-0',
312                   'version': '2',
313                   'modelCustomizationName': 'VfVmee..base_vmme..module-0',
314                   'properties': {'minCountInstances': 1, 'maxCountInstances': 1, 'initialCount': 1},
315                   'commands': {},
316                   'volumeGroupAllowed': true
317                 }
318               },
319               'volumeGroups': {
320                 'vf_vmee0..VfVmee..base_vmme..module-0': {
321                   'uuid': 'a27f5cfc-7f12-4f99-af08-0af9c3885c87',
322                   'invariantUuid': 'a6f9e51a-2b35-416a-ae15-15e58d61f36d',
323                   'customizationUuid': 'f8c040f1-7e51-4a11-aca8-acf256cfd861',
324                   'description': null,
325                   'name': 'VfVmee..base_vmme..module-0',
326                   'version': '2',
327                   'modelCustomizationName': 'VfVmee..base_vmme..module-0',
328                   'properties': {'minCountInstances': 1, 'maxCountInstances': 1, 'initialCount': 1}
329                 }
330               }
331             }
332           },
333           'networks': {
334             'ExtVL 0': {
335               'uuid': 'ddc3f20c-08b5-40fd-af72-c6d14636b986',
336               'invariantUuid': '379f816b-a7aa-422f-be30-17114ff50b7c',
337               'description': 'ECOMP generic virtual link (network) base type for all other service-level and global networks',
338               'name': 'ExtVL',
339               'version': '37.0',
340               'customizationUuid': '94fdd893-4a36-4d70-b16a-ec29c54c184f',
341               'inputs': {},
342               'commands': {},
343               'properties': {
344                 'network_assignments': '{is_external_network=false, ipv4_subnet_default_assignment={min_subnets_count=1}, ecomp_generated_network_assignment=false, ipv6_subnet_default_assignment={min_subnets_count=1}}',
345                 'exVL_naming': '{ecomp_generated_naming=true}',
346                 'network_flows': '{is_network_policy=false, is_bound_to_vpn=false}',
347                 'network_homing': '{ecomp_selected_instance_node_target=false}'
348               },
349               'type': 'VL',
350               'modelCustomizationName': 'ExtVL 0'
351             }
352           },
353           'configurations': {
354             'Port Mirroring Configuration By Policy 0': {
355               'uuid': 'b4398538-e89d-4f13-b33d-ca323434ba50',
356               'invariantUuid': '6ef0ca40-f366-4897-951f-abd65d25f6f7',
357               'description': 'A port mirroring configuration by policy object',
358               'name': 'Port Mirroring Configuration By Policy',
359               'version': '27.0',
360               'customizationUuid': '3c3b7b8d-8669-4b3b-8664-61970041fad2',
361               'inputs': {},
362               'commands': {},
363               'properties': {},
364               'type': 'Configuration',
365               'modelCustomizationName': 'Port Mirroring Configuration By Policy 0',
366               'sourceNodes': [],
367               'collectorNodes': null,
368               'configurationByPolicy': false
369             }
370           },
371           'serviceProxies': {},
372           'vfModules': {
373             'vf_vmee0..VfVmee..vmme_vlc..module-1': {
374               'uuid': '522159d5-d6e0-4c2a-aa44-5a542a12a830',
375               'invariantUuid': '98a7c88b-b577-476a-90e4-e25a5871e02b',
376               'customizationUuid': '55b1be94-671a-403e-a26c-667e9c47d091',
377               'description': null,
378               'name': 'VfVmee..vmme_vlc..module-1',
379               'version': '2',
380               'modelCustomizationName': 'VfVmee..vmme_vlc..module-1',
381               'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0},
382               'commands': {},
383               'volumeGroupAllowed': false
384             },
385             'vf_vmee0..VfVmee..vmme_gpb..module-2': {
386               'uuid': '41708296-e443-4c71-953f-d9a010f059e1',
387               'invariantUuid': '1cca90b8-3490-495e-87da-3f3e4c57d5b9',
388               'customizationUuid': '6add59e0-7fe1-4bc4-af48-f8812422ae7c',
389               'description': null,
390               'name': 'VfVmee..vmme_gpb..module-2',
391               'version': '2',
392               'modelCustomizationName': 'VfVmee..vmme_gpb..module-2',
393               'properties': {'minCountInstances': 0, 'maxCountInstances': null, 'initialCount': 0},
394               'commands': {},
395               'volumeGroupAllowed': false
396             },
397             'vf_vmee0..VfVmee..base_vmme..module-0': {
398               'uuid': 'a27f5cfc-7f12-4f99-af08-0af9c3885c87',
399               'invariantUuid': 'a6f9e51a-2b35-416a-ae15-15e58d61f36d',
400               'customizationUuid': 'f8c040f1-7e51-4a11-aca8-acf256cfd861',
401               'description': null,
402               'name': 'VfVmee..base_vmme..module-0',
403               'version': '2',
404               'modelCustomizationName': 'VfVmee..base_vmme..module-0',
405               'properties': {'minCountInstances': 1, 'maxCountInstances': 1, 'initialCount': 1},
406               'commands': {},
407               'volumeGroupAllowed': true
408             }
409           },
410           'volumeGroups': {
411             'vf_vmee0..VfVmee..base_vmme..module-0': {
412               'uuid': 'a27f5cfc-7f12-4f99-af08-0af9c3885c87',
413               'invariantUuid': 'a6f9e51a-2b35-416a-ae15-15e58d61f36d',
414               'customizationUuid': 'f8c040f1-7e51-4a11-aca8-acf256cfd861',
415               'description': null,
416               'name': 'VfVmee..base_vmme..module-0',
417               'version': '2',
418               'modelCustomizationName': 'VfVmee..base_vmme..module-0',
419               'properties': {'minCountInstances': 1, 'maxCountInstances': 1, 'initialCount': 1}
420             }
421           },
422           'pnfs': {}
423         }
424       }
425     ));
426   }
427 });