Merge "Add filter for serviceInfo by service model id"
[vid.git] / vid-webpack-master / src / app / shared / components / genericForm / formControlsServices / service.control.generator.spec.ts
1 import {getTestBed, TestBed} from '@angular/core/testing';
2 import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
3 import {NgRedux} from '@angular-redux/store';
4 import {FormControlNames, ServiceControlGenerator} from "./service.control.generator";
5 import {BasicControlGenerator} from "./basic.control.generator";
6 import {AaiService} from "../../../services/aaiService/aai.service";
7 import {GenericFormService} from "../generic-form.service";
8 import {FormBuilder} from "@angular/forms";
9 import {FormControlModel, ValidatorModel, ValidatorOptions} from "../../../models/formControlModels/formControl.model";
10 import {LogService} from "../../../utils/log/log.service";
11 import {FormControlType} from "../../../models/formControlModels/formControlTypes.enum";
12 import {DropdownFormControl} from "../../../models/formControlModels/dropdownFormControl.model";
13 import {FeatureFlagsService} from "../../../services/featureFlag/feature-flags.service";
14 import each from 'jest-each';
15 import {VidNotions} from "../../../models/vidNotions";
16
17 class MockAppStore<T> {
18   getState() {
19     return {
20       "global": {
21         "name": null,
22         "flags": {
23           "FLAG_NETWORK_TO_ASYNC_INSTANTIATION": false,
24           "FLAG_SHOW_ASSIGNMENTS": true,
25           "FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS": true,
26           "FLAG_SHOW_VERIFY_SERVICE": false,
27           "FLAG_SERVICE_MODEL_CACHE": true,
28           "FLAG_ADD_MSO_TESTAPI_FIELD": true
29         },
30         "type": "[FLAGS] Update"
31       },
32       "service": {
33         "serviceHierarchy": {
34           "6e59c5de-f052-46fa-aa7e-2fca9d674c44": {
35             "service": {
36               "uuid": "6e59c5de-f052-46fa-aa7e-2fca9d674c44",
37               "invariantUuid": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
38               "name": "ComplexService",
39               "version": "1.0",
40               "toscaModelURL": null,
41               "category": "Emanuel",
42               "serviceType": "",
43               "serviceRole": "",
44               "description": "ComplexService",
45               "serviceEcompNaming": "false",
46               "instantiationType": "Macro",
47               "inputs": {}
48             },
49             "vnfs": {
50               "VF_vGeraldine 0": {
51                 "uuid": "d6557200-ecf2-4641-8094-5393ae3aae60",
52                 "invariantUuid": "4160458e-f648-4b30-a176-43881ffffe9e",
53                 "description": "VSP_vGeraldine",
54                 "name": "VF_vGeraldine",
55                 "version": "2.0",
56                 "customizationUuid": "91415b44-753d-494c-926a-456a9172bbb9",
57                 "inputs": {},
58                 "commands": {},
59                 "properties": {
60                   "max_instances": 10,
61                   "min_instances": 1,
62                   "gpb2_Internal2_mac": "00:11:22:EF:AC:DF",
63                   "sctp-b-ipv6-egress_src_start_port": "0",
64                   "sctp-a-ipv6-egress_rule_application": "any",
65                   "Internal2_allow_transit": "true",
66                   "sctp-b-IPv6_ethertype": "IPv6",
67                   "sctp-a-egress_rule_application": "any",
68                   "sctp-b-ingress_action": "pass",
69                   "sctp-b-ingress_rule_protocol": "icmp",
70                   "ncb2_Internal1_mac": "00:11:22:EF:AC:DF",
71                   "sctp-b-ipv6-ingress-src_start_port": "0.0",
72                   "ncb1_Internal2_mac": "00:11:22:EF:AC:DF",
73                   "fsb_volume_size_0": "320.0",
74                   "sctp-b-egress_src_addresses": "local",
75                   "sctp-a-ipv6-ingress_ethertype": "IPv4",
76                   "sctp-a-ipv6-ingress-dst_start_port": "0",
77                   "sctp-b-ipv6-ingress_rule_application": "any",
78                   "domain_name": "default-domain",
79                   "sctp-a-ingress_rule_protocol": "icmp",
80                   "sctp-b-egress-src_start_port": "0.0",
81                   "sctp-a-egress_src_addresses": "local",
82                   "sctp-b-display_name": "epc-sctp-b-ipv4v6-sec-group",
83                   "sctp-a-egress-src_start_port": "0.0",
84                   "sctp-a-ingress_ethertype": "IPv4",
85                   "sctp-b-ipv6-ingress-dst_end_port": "65535",
86                   "sctp-b-dst_subnet_prefix_v6": "::",
87                   "nf_naming": "{ecomp_generated_naming=true}",
88                   "sctp-a-ipv6-ingress_src_subnet_prefix": "0.0.0.0",
89                   "sctp-b-egress-dst_start_port": "0.0",
90                   "ncb_flavor_name": "nv.c20r64d1",
91                   "gpb1_Internal1_mac": "00:11:22:EF:AC:DF",
92                   "sctp-b-egress_dst_subnet_prefix_len": "0.0",
93                   "Internal2_net_cidr": "10.0.0.10",
94                   "sctp-a-ingress-dst_start_port": "0.0",
95                   "sctp-a-egress-dst_start_port": "0.0",
96                   "fsb1_Internal2_mac": "00:11:22:EF:AC:DF",
97                   "sctp-a-egress_ethertype": "IPv4",
98                   "vlc_st_service_mode": "in-network-nat",
99                   "sctp-a-ipv6-egress_ethertype": "IPv4",
100                   "sctp-a-egress-src_end_port": "65535.0",
101                   "sctp-b-ipv6-egress_rule_application": "any",
102                   "sctp-b-egress_action": "pass",
103                   "sctp-a-ingress-src_subnet_prefix_len": "0.0",
104                   "sctp-b-ipv6-ingress-src_end_port": "65535.0",
105                   "sctp-b-name": "epc-sctp-b-ipv4v6-sec-group",
106                   "fsb2_Internal1_mac": "00:11:22:EF:AC:DF",
107                   "sctp-a-ipv6-ingress-src_start_port": "0.0",
108                   "sctp-b-ipv6-egress_ethertype": "IPv4",
109                   "Internal1_net_cidr": "10.0.0.10",
110                   "sctp-a-egress_dst_subnet_prefix": "0.0.0.0",
111                   "fsb_flavor_name": "nv.c20r64d1",
112                   "sctp_rule_protocol": "132",
113                   "sctp-b-ipv6-ingress_src_subnet_prefix_len": "0",
114                   "sctp-a-ipv6-ingress_rule_application": "any",
115                   "ecomp_generated_naming": "false",
116                   "sctp-a-IPv6_ethertype": "IPv6",
117                   "vlc2_Internal1_mac": "00:11:22:EF:AC:DF",
118                   "vlc_st_virtualization_type": "virtual-machine",
119                   "sctp-b-ingress-dst_start_port": "0.0",
120                   "sctp-b-ingress-dst_end_port": "65535.0",
121                   "sctp-a-ipv6-ingress-src_end_port": "65535.0",
122                   "sctp-a-display_name": "epc-sctp-a-ipv4v6-sec-group",
123                   "sctp-b-ingress_rule_application": "any",
124                   "int2_sec_group_name": "int2-sec-group",
125                   "vlc_flavor_name": "nd.c16r64d1",
126                   "sctp-b-ipv6-egress_src_addresses": "local",
127                   "vlc_st_interface_type_int1": "other1",
128                   "sctp-b-egress-src_end_port": "65535.0",
129                   "sctp-a-ipv6-egress-dst_start_port": "0",
130                   "vlc_st_interface_type_int2": "other2",
131                   "sctp-a-ipv6-egress_rule_protocol": "any",
132                   "Internal2_shared": "false",
133                   "sctp-a-ipv6-egress_dst_subnet_prefix_len": "0",
134                   "Internal2_rpf": "disable",
135                   "vlc1_Internal1_mac": "00:11:22:EF:AC:DF",
136                   "sctp-b-ipv6-egress_src_end_port": "65535",
137                   "sctp-a-ipv6-egress_src_addresses": "local",
138                   "sctp-a-ingress-dst_end_port": "65535.0",
139                   "sctp-a-ipv6-egress_src_end_port": "65535",
140                   "Internal1_forwarding_mode": "l2",
141                   "Internal2_dhcp": "false",
142                   "sctp-a-dst_subnet_prefix_v6": "::",
143                   "pxe_image_name": "MME_PXE-Boot_16ACP04_GA.qcow2",
144                   "vlc_st_interface_type_gtp": "other0",
145                   "ncb1_Internal1_mac": "00:11:22:EF:AC:DF",
146                   "sctp-b-src_subnet_prefix_v6": "::",
147                   "sctp-a-egress_dst_subnet_prefix_len": "0.0",
148                   "int1_sec_group_name": "int1-sec-group",
149                   "Internal1_dhcp": "false",
150                   "sctp-a-ipv6-egress_dst_end_port": "65535",
151                   "Internal2_forwarding_mode": "l2",
152                   "fsb2_Internal2_mac": "00:11:22:EF:AC:DF",
153                   "sctp-b-egress_dst_subnet_prefix": "0.0.0.0",
154                   "Internal1_net_cidr_len": "17",
155                   "gpb2_Internal1_mac": "00:11:22:EF:AC:DF",
156                   "sctp-b-ingress-src_subnet_prefix_len": "0.0",
157                   "sctp-a-ingress_dst_addresses": "local",
158                   "sctp-a-egress_action": "pass",
159                   "fsb_volume_type_0": "SF-Default-SSD",
160                   "ncb2_Internal2_mac": "00:11:22:EF:AC:DF",
161                   "vlc_st_interface_type_sctp_a": "left",
162                   "vlc_st_interface_type_sctp_b": "right",
163                   "sctp-a-src_subnet_prefix_v6": "::",
164                   "vlc_st_version": "2",
165                   "sctp-b-egress_ethertype": "IPv4",
166                   "sctp-a-ingress_rule_application": "any",
167                   "gpb1_Internal2_mac": "00:11:22:EF:AC:DF",
168                   "instance_ip_family_v6": "v6",
169                   "sctp-a-ipv6-egress_src_start_port": "0",
170                   "sctp-b-ingress-src_start_port": "0.0",
171                   "sctp-b-ingress_dst_addresses": "local",
172                   "fsb1_Internal1_mac": "00:11:22:EF:AC:DF",
173                   "vlc_st_interface_type_oam": "management",
174                   "multi_stage_design": "true",
175                   "oam_sec_group_name": "oam-sec-group",
176                   "Internal2_net_gateway": "10.0.0.10",
177                   "sctp-a-ipv6-ingress-dst_end_port": "65535",
178                   "sctp-b-ipv6-egress-dst_start_port": "0",
179                   "Internal1_net_gateway": "10.0.0.10",
180                   "sctp-b-ipv6-egress_rule_protocol": "any",
181                   "gtp_sec_group_name": "gtp-sec-group",
182                   "sctp-a-ipv6-egress_dst_subnet_prefix": "0.0.0.0",
183                   "sctp-b-ipv6-egress_dst_subnet_prefix_len": "0",
184                   "sctp-a-ipv6-ingress_dst_addresses": "local",
185                   "sctp-a-egress_rule_protocol": "icmp",
186                   "sctp-b-ipv6-egress_action": "pass",
187                   "sctp-a-ipv6-egress_action": "pass",
188                   "Internal1_shared": "false",
189                   "sctp-b-ipv6-ingress_rule_protocol": "any",
190                   "Internal2_net_cidr_len": "17",
191                   "sctp-a-name": "epc-sctp-a-ipv4v6-sec-group",
192                   "sctp-a-ingress-src_end_port": "65535.0",
193                   "sctp-b-ipv6-ingress_src_subnet_prefix": "0.0.0.0",
194                   "sctp-a-egress-dst_end_port": "65535.0",
195                   "sctp-a-ingress_action": "pass",
196                   "sctp-b-egress_rule_protocol": "icmp",
197                   "sctp-b-ipv6-ingress_action": "pass",
198                   "vlc_st_service_type": "firewall",
199                   "sctp-b-ipv6-egress_dst_end_port": "65535",
200                   "sctp-b-ipv6-ingress-dst_start_port": "0",
201                   "vlc2_Internal2_mac": "00:11:22:EF:AC:DF",
202                   "vlc_st_availability_zone": "true",
203                   "fsb_volume_image_name_1": "MME_FSB2_16ACP04_GA.qcow2",
204                   "sctp-b-ingress-src_subnet_prefix": "0.0.0.0",
205                   "sctp-a-ipv6-ingress_src_subnet_prefix_len": "0",
206                   "Internal1_allow_transit": "true",
207                   "gpb_flavor_name": "nv.c20r64d1",
208                   "availability_zone_max_count": "1",
209                   "fsb_volume_image_name_0": "MME_FSB1_16ACP04_GA.qcow2",
210                   "sctp-b-ipv6-ingress_dst_addresses": "local",
211                   "sctp-b-ipv6-egress_dst_subnet_prefix": "0.0.0.0",
212                   "sctp-b-ipv6-ingress_ethertype": "IPv4",
213                   "vlc1_Internal2_mac": "00:11:22:EF:AC:DF",
214                   "sctp-a-ingress-src_subnet_prefix": "0.0.0.0",
215                   "sctp-a-ipv6-ingress_action": "pass",
216                   "Internal1_rpf": "disable",
217                   "sctp-b-ingress_ethertype": "IPv4",
218                   "sctp-b-egress_rule_application": "any",
219                   "sctp-b-ingress-src_end_port": "65535.0",
220                   "sctp-a-ipv6-ingress_rule_protocol": "any",
221                   "sctp-a-ingress-src_start_port": "0.0",
222                   "sctp-b-egress-dst_end_port": "65535.0"
223                 },
224                 "type": "VF",
225                 "modelCustomizationName": "VF_vGeraldine 0",
226                 "vfModules": {
227                   "vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1": {
228                     "uuid": "522159d5-d6e0-4c2a-aa44-5a542a12a830",
229                     "invariantUuid": "98a7c88b-b577-476a-90e4-e25a5871e02b",
230                     "customizationUuid": "55b1be94-671a-403e-a26c-667e9c47d091",
231                     "description": null,
232                     "name": "VfVgeraldine..vflorence_vlc..module-1",
233                     "version": "2",
234                     "modelCustomizationName": "VfVgeraldine..vflorence_vlc..module-1",
235                     "properties": {
236                       "minCountInstances": 0,
237                       "maxCountInstances": null,
238                       "initialCount": 0,
239                       "vfModuleLabel": "vflorence_vlc"
240                     },
241                     "inputs": {},
242                     "volumeGroupAllowed": true
243                   },
244                   "vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2": {
245                     "uuid": "41708296-e443-4c71-953f-d9a010f059e1",
246                     "invariantUuid": "1cca90b8-3490-495e-87da-3f3e4c57d5b9",
247                     "customizationUuid": "6add59e0-7fe1-4bc4-af48-f8812422ae7c",
248                     "description": null,
249                     "name": "VfVgeraldine..vflorence_gpb..module-2",
250                     "version": "2",
251                     "modelCustomizationName": "VfVgeraldine..vflorence_gpb..module-2",
252                     "properties": {
253                       "minCountInstances": 0,
254                       "maxCountInstances": null,
255                       "initialCount": 0,
256                       "vfModuleLabel": "vflorence_gpb"
257                     },
258                     "inputs": {},
259                     "volumeGroupAllowed": false
260                   },
261                   "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0": {
262                     "uuid": "a27f5cfc-7f12-4f99-af08-0af9c3885c87",
263                     "invariantUuid": "a6f9e51a-2b35-416a-ae15-15e58d61f36d",
264                     "customizationUuid": "f8c040f1-7e51-4a11-aca8-acf256cfd861",
265                     "description": null,
266                     "name": "VfVgeraldine..base_vflorence..module-0",
267                     "version": "2",
268                     "modelCustomizationName": "VfVgeraldine..base_vflorence..module-0",
269                     "properties": {
270                       "minCountInstances": 1,
271                       "maxCountInstances": 1,
272                       "initialCount": 1,
273                       "vfModuleLabel": "base_vflorence"
274                     },
275                     "inputs": {},
276                     "volumeGroupAllowed": true
277                   }
278                 },
279                 "volumeGroups": {
280                   "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0": {
281                     "uuid": "a27f5cfc-7f12-4f99-af08-0af9c3885c87",
282                     "invariantUuid": "a6f9e51a-2b35-416a-ae15-15e58d61f36d",
283                     "customizationUuid": "f8c040f1-7e51-4a11-aca8-acf256cfd861",
284                     "description": null,
285                     "name": "VfVgeraldine..base_vflorence..module-0",
286                     "version": "2",
287                     "modelCustomizationName": "VfVgeraldine..base_vflorence..module-0",
288                     "properties": {
289                       "minCountInstances": 1,
290                       "maxCountInstances": 1,
291                       "initialCount": 1,
292                       "vfModuleLabel": "base_vflorence"
293                     },
294                     "inputs": {}
295                   }
296                 },
297                 "vfcInstanceGroups": {}
298               }
299             },
300             "networks": {
301               "ExtVL 0": {
302                 "uuid": "ddc3f20c-08b5-40fd-af72-c6d14636b986",
303                 "invariantUuid": "379f816b-a7aa-422f-be30-17114ff50b7c",
304                 "description": "ECOMP generic virtual link (network) base type for all other service-level and global networks",
305                 "name": "ExtVL",
306                 "version": "37.0",
307                 "customizationUuid": "94fdd893-4a36-4d70-b16a-ec29c54c184f",
308                 "inputs": {},
309                 "commands": {},
310                 "properties": {
311                   "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}}",
312                   "exVL_naming": "{ecomp_generated_naming=true}",
313                   "network_flows": "{is_network_policy=false, is_bound_to_vpn=false}",
314                   "network_homing": "{ecomp_selected_instance_node_target=false}"
315                 },
316                 "type": "VL",
317                 "modelCustomizationName": "ExtVL 0"
318               }
319             },
320             "collectionResources": {},
321             "configurations": {
322               "Port Mirroring Configuration By Policy 0": {
323                 "uuid": "b4398538-e89d-4f13-b33d-ca323434ba50",
324                 "invariantUuid": "6ef0ca40-f366-4897-951f-abd65d25f6f7",
325                 "description": "A port mirroring configuration by policy object",
326                 "name": "Port Mirroring Configuration By Policy",
327                 "version": "27.0",
328                 "customizationUuid": "3c3b7b8d-8669-4b3b-8664-61970041fad2",
329                 "inputs": {},
330                 "commands": {},
331                 "properties": {},
332                 "type": "Configuration",
333                 "modelCustomizationName": "Port Mirroring Configuration By Policy 0",
334                 "sourceNodes": [],
335                 "collectorNodes": null,
336                 "configurationByPolicy": false
337               }
338             },
339             "serviceProxies": {},
340             "vfModules": {
341               "vf_vgeraldine0..VfVgeraldine..vflorence_vlc..module-1": {
342                 "uuid": "522159d5-d6e0-4c2a-aa44-5a542a12a830",
343                 "invariantUuid": "98a7c88b-b577-476a-90e4-e25a5871e02b",
344                 "customizationUuid": "55b1be94-671a-403e-a26c-667e9c47d091",
345                 "description": null,
346                 "name": "VfVgeraldine..vflorence_vlc..module-1",
347                 "version": "2",
348                 "modelCustomizationName": "VfVgeraldine..vflorence_vlc..module-1",
349                 "properties": {
350                   "minCountInstances": 0,
351                   "maxCountInstances": null,
352                   "initialCount": 0,
353                   "vfModuleLabel": "vflorence_vlc"
354                 },
355                 "inputs": {},
356                 "volumeGroupAllowed": true
357               },
358               "vf_vgeraldine0..VfVgeraldine..vflorence_gpb..module-2": {
359                 "uuid": "41708296-e443-4c71-953f-d9a010f059e1",
360                 "invariantUuid": "1cca90b8-3490-495e-87da-3f3e4c57d5b9",
361                 "customizationUuid": "6add59e0-7fe1-4bc4-af48-f8812422ae7c",
362                 "description": null,
363                 "name": "VfVgeraldine..vflorence_gpb..module-2",
364                 "version": "2",
365                 "modelCustomizationName": "VfVgeraldine..vflorence_gpb..module-2",
366                 "properties": {
367                   "minCountInstances": 0,
368                   "maxCountInstances": null,
369                   "initialCount": 0,
370                   "vfModuleLabel": "vflorence_gpb"
371                 },
372                 "inputs": {},
373                 "volumeGroupAllowed": false
374               },
375               "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0": {
376                 "uuid": "a27f5cfc-7f12-4f99-af08-0af9c3885c87",
377                 "invariantUuid": "a6f9e51a-2b35-416a-ae15-15e58d61f36d",
378                 "customizationUuid": "f8c040f1-7e51-4a11-aca8-acf256cfd861",
379                 "description": null,
380                 "name": "VfVgeraldine..base_vflorence..module-0",
381                 "version": "2",
382                 "modelCustomizationName": "VfVgeraldine..base_vflorence..module-0",
383                 "properties": {
384                   "minCountInstances": 1,
385                   "maxCountInstances": 1,
386                   "initialCount": 1,
387                   "vfModuleLabel": "base_vflorence"
388                 },
389                 "inputs": {},
390                 "volumeGroupAllowed": true
391               }
392             },
393             "volumeGroups": {
394               "vf_vgeraldine0..VfVgeraldine..base_vflorence..module-0": {
395                 "uuid": "a27f5cfc-7f12-4f99-af08-0af9c3885c87",
396                 "invariantUuid": "a6f9e51a-2b35-416a-ae15-15e58d61f36d",
397                 "customizationUuid": "f8c040f1-7e51-4a11-aca8-acf256cfd861",
398                 "description": null,
399                 "name": "VfVgeraldine..base_vflorence..module-0",
400                 "version": "2",
401                 "modelCustomizationName": "VfVgeraldine..base_vflorence..module-0",
402                 "properties": {
403                   "minCountInstances": 1,
404                   "maxCountInstances": 1,
405                   "initialCount": 1,
406                   "vfModuleLabel": "base_vflorence"
407                 },
408                 "inputs": {}
409               }
410             },
411             "pnfs": {}
412           },
413           "7e59c5de-f052-46fa-aa7e-2fca9d674c43": {
414             "service": {
415               "uuid": "6e59c5de-f052-46fa-aa7e-2fca9d674c44",
416               "invariantUuid": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
417               "name": "ComplexService",
418               "version": "1.0",
419               "toscaModelURL": null,
420               "category": "Emanuel",
421               "serviceType": "Transport",
422               "serviceRole": "",
423               "description": "ComplexService",
424               "serviceEcompNaming": "false",
425               "instantiationType": "Macro",
426               "vidNotions": {
427                 "instantiationUI": "TRANSPORT_SERVICE",
428                 "modelCategory": "Transport",
429                 "viewEditUI": "TRANSPORT_SERVICE",
430                 "instantiationType": "Macro"
431               },
432               "inputs": {}
433             },
434             "vnfs": {},
435             "networks": {},
436             "collectionResources": {},
437             "configurations": {},
438             "serviceProxies": {},
439             "vfModules": {},
440             "volumeGroups": {},
441             "pnfs": {
442               "PNF4": {
443                 "uuid": "1c831fa9-28a6-4778-8c1d-80b9e769f2ed",
444                 "invariantUuid": "74e13a12-dac9-4fba-b102-cd242d9e7f02",
445                 "description": "AIM Transport service",
446                 "name": "AIM PNF Model",
447                 "version": "1.0",
448                 "customizationUuid": "ce2453ef-4e8e-4108-944c-57bef89cfab0",
449                 "inputs": {},
450                 "commands": {},
451                 "properties": {
452                   "nf_function": "AIM CE",
453                   "nf_role": "pCE",
454                   "ecomp_generated_naming": "false",
455                   "nf_type": "ROUTER"
456                 },
457                 "type": "PNF"
458               },
459               "PNF1": {
460                 "uuid": "1c831fa9-28a6-4778-8c1d-80b9e769f2ed",
461                 "invariantUuid": "74e13a12-dac9-4fba-b102-cd242d9e7f02",
462                 "description": "AIM Transport service",
463                 "name": "AIM PNF Model",
464                 "version": "1.0",
465                 "customizationUuid": "dce78da7-c842-47a1-aba2-2de1cd03ab7a",
466                 "inputs": {},
467                 "commands": {},
468                 "properties": {
469                   "nf_function": "SDNGW",
470                   "nf_role": "pD2IPE",
471                   "ecomp_generated_naming": "false",
472                   "nf_type": "ROUTER"
473                 },
474                 "type": "PNF"
475               }
476             }
477           }
478         },
479         "serviceInstance": {},
480         "lcpRegionsAndTenants": {
481           "lcpRegionList": [
482             {
483               "id": "AAIAIC25",
484               "name": "AAIAIC25",
485               "isPermitted": true
486             },
487             {
488               "id": "hvf6",
489               "name": "hvf6",
490               "isPermitted": true
491             }
492           ],
493           "lcpRegionsTenantsMap": {
494             "AAIAIC25": [
495               {
496                 "id": "092eb9e8e4b7412e8787dd091bc58e86",
497                 "name": "USP-SIP-IC-24335-T-01",
498                 "isPermitted": true
499               }
500             ],
501             "hvf6": [
502               {
503                 "id": "bae71557c5bb4d5aac6743a4e5f1d054",
504                 "name": "AIN Web Tool-15-D-testalexandria",
505                 "isPermitted": true
506               },
507               {
508                 "id": "d0a3e3f2964542259d155a81c41aadc3",
509                 "name": "test-hvf6-09",
510                 "isPermitted": true
511               },
512               {
513                 "id": "fa45ca53c80b492fa8be5477cd84fc2b",
514                 "name": "ro-T112",
515                 "isPermitted": true
516               },
517               {
518                 "id": "4914ab0ab3a743e58f0eefdacc1dde77",
519                 "name": "DN5242-Nov21-T1",
520                 "isPermitted": true
521               },
522               {
523                 "id": "d0a3e3f2964542259d155a81c41aadc3",
524                 "name": "test-hvf6-09",
525                 "isPermitted": true
526               },
527               {
528                 "id": "cbb99fe4ada84631b7baf046b6fd2044",
529                 "name": "DN5242-Nov16-T3",
530                 "isPermitted": true
531               }
532             ]
533           }
534         },
535         "productFamilies": [
536           {
537             "id": "ebc3bc3d-62fd-4a3f-a037-f619df4ff034",
538             "name": "ERICA",
539             "isPermitted": true
540           },
541           {
542             "id": "17cc1042-527b-11e6-beb8-9e71128cae77",
543             "name": "IGNACIO",
544             "isPermitted": true
545           },
546           {
547             "id": "36b4733a-53f4-4cc8-8ff0-9172e5fc4b8e",
548             "name": "Christie",
549             "isPermitted": true
550           },
551           {
552             "id": "a4f6f2ae-9bf5-4ed7-b904-06b2099c4bd7",
553             "name": "Enhanced Services",
554             "isPermitted": true
555           },
556           {
557             "id": "vTerrance",
558             "name": "vTerrance",
559             "isPermitted": true
560           },
561           {
562             "id": "323d69d9-2efe-4r45-ay0a-89ea7ard4e6f",
563             "name": "vEsmeralda",
564             "isPermitted": true
565           },
566           {
567             "id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
568             "name": "Emanuel",
569             "isPermitted": true
570           },
571           {
572             "id": "d8a6ed93-251c-47ca-adc9-86671fd19f4c",
573             "name": "BVOIP",
574             "isPermitted": true
575           },
576           {
577             "id": "db171b8f-115c-4992-a2e3-ee04cae357e0",
578             "name": "LINDSEY",
579             "isPermitted": true
580           },
581           {
582             "id": "LRSI-OSPF",
583             "name": "LRSI-OSPF",
584             "isPermitted": true
585           },
586           {
587             "id": "vRosemarie",
588             "name": "HNGATEWAY",
589             "isPermitted": true
590           },
591           {
592             "id": "vHNPaas",
593             "name": "WILKINS",
594             "isPermitted": true
595           },
596           {
597             "id": "e433710f-9217-458d-a79d-1c7aff376d89",
598             "name": "TYLER SILVIA",
599             "isPermitted": true
600           },
601           {
602             "id": "b6a3f28c-eebf-494c-a900-055cc7c874ce",
603             "name": "VROUTER",
604             "isPermitted": true
605           },
606           {
607             "id": "vMuriel",
608             "name": "vMuriel",
609             "isPermitted": true
610           },
611           {
612             "id": "0ee8c1bc-7cbd-4b0a-a1ac-e9999255abc1",
613             "name": "CARA Griffin",
614             "isPermitted": true
615           },
616           {
617             "id": "c7611ebe-c324-48f1-8085-94aef0c6ef3d",
618             "name": "DARREN MCGEE",
619             "isPermitted": true
620           },
621           {
622             "id": "e30755dc-5673-4b6b-9dcf-9abdd96b93d1",
623             "name": "Transport",
624             "isPermitted": true
625           },
626           {
627             "id": "vSalvatore",
628             "name": "vSalvatore",
629             "isPermitted": true
630           },
631           {
632             "id": "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4",
633             "name": "JOSEFINA",
634             "isPermitted": true
635           },
636           {
637             "id": "vHubbard",
638             "name": "vHubbard",
639             "isPermitted": true
640           },
641           {
642             "id": "12a96a9d-4b4c-4349-a950-fe1159602621",
643             "name": "DARREN MCGEE",
644             "isPermitted": true
645           }
646         ],
647         "serviceTypes": {
648           "e433710f-9217-458d-a79d-1c7aff376d89": [
649             {
650               "id": "0",
651               "name": "vRichardson",
652               "isPermitted": false
653             },
654             {
655               "id": "1",
656               "name": "TYLER SILVIA",
657               "isPermitted": true
658             },
659             {
660               "id": "2",
661               "name": "Emanuel",
662               "isPermitted": false
663             },
664             {
665               "id": "3",
666               "name": "vJamie",
667               "isPermitted": false
668             },
669             {
670               "id": "4",
671               "name": "vVoiceMail",
672               "isPermitted": false
673             },
674             {
675               "id": "5",
676               "name": "Kennedy",
677               "isPermitted": false
678             },
679             {
680               "id": "6",
681               "name": "vPorfirio",
682               "isPermitted": false
683             },
684             {
685               "id": "7",
686               "name": "vVM",
687               "isPermitted": false
688             },
689             {
690               "id": "8",
691               "name": "vOTA",
692               "isPermitted": false
693             },
694             {
695               "id": "9",
696               "name": "vFLORENCE",
697               "isPermitted": false
698             },
699             {
700               "id": "10",
701               "name": "vMNS",
702               "isPermitted": false
703             },
704             {
705               "id": "11",
706               "name": "vEsmeralda",
707               "isPermitted": false
708             },
709             {
710               "id": "12",
711               "name": "VPMS",
712               "isPermitted": false
713             },
714             {
715               "id": "13",
716               "name": "vWINIFRED",
717               "isPermitted": false
718             },
719             {
720               "id": "14",
721               "name": "SSD",
722               "isPermitted": false
723             },
724             {
725               "id": "15",
726               "name": "vMOG",
727               "isPermitted": false
728             },
729             {
730               "id": "16",
731               "name": "LINDSEY",
732               "isPermitted": false
733             },
734             {
735               "id": "17",
736               "name": "JOHANNA_SANTOS",
737               "isPermitted": false
738             },
739             {
740               "id": "18",
741               "name": "vCarroll",
742               "isPermitted": false
743             }
744           ]
745         },
746         "aicZones": [
747           {
748             "id": "NFT1",
749             "name": "NFTJSSSS-NFT1"
750           },
751           {
752             "id": "JAG1",
753             "name": "YUDFJULP-JAG1"
754           },
755           {
756             "id": "YYY1",
757             "name": "UUUAIAAI-YYY1"
758           },
759           {
760             "id": "AVT1",
761             "name": "AVTRFLHD-AVT1"
762           },
763           {
764             "id": "ATL34",
765             "name": "ATLSANAI-ATL34"
766           }
767         ],
768         "categoryParameters": {
769           "owningEntityList": [
770             {
771               "id": "aaa1",
772               "name": "aaa1"
773             },
774             {
775               "id": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
776               "name": "WayneHolland"
777             },
778             {
779               "id": "Melissa",
780               "name": "Melissa"
781             }
782           ],
783           "projectList": [
784             {
785               "id": "WATKINS",
786               "name": "WATKINS"
787             },
788             {
789               "id": "x1",
790               "name": "x1"
791             },
792             {
793               "id": "yyy1",
794               "name": "yyy1"
795             }
796           ],
797           "lineOfBusinessList": [
798             {
799               "id": "ONAP",
800               "name": "ONAP"
801             },
802             {
803               "id": "zzz1",
804               "name": "zzz1"
805             }
806           ],
807           "platformList": [
808             {
809               "id": "platform",
810               "name": "platform"
811             },
812             {
813               "id": "xxx1",
814               "name": "xxx1"
815             }
816           ]
817         },
818         "type": "[LCP_REGIONS_AND_TENANTS] Update",
819         "subscribers": [
820           {
821             "id": "CAR_2020_ER",
822             "name": "CAR_2020_ER",
823             "isPermitted": true
824           },
825           {
826             "id": "21014aa2-526b-11e6-beb8-9e71128cae77",
827             "name": "JULIO ERICKSON",
828             "isPermitted": false
829           },
830           {
831             "id": "DHV1707-TestSubscriber-2",
832             "name": "DALE BRIDGES",
833             "isPermitted": false
834           },
835           {
836             "id": "DHV1707-TestSubscriber-1",
837             "name": "LLOYD BRIDGES",
838             "isPermitted": false
839           },
840           {
841             "id": "jimmy-example",
842             "name": "JimmyExampleCust-20161102",
843             "isPermitted": false
844           },
845           {
846             "id": "jimmy-example2",
847             "name": "JimmyExampleCust-20161103",
848             "isPermitted": false
849           },
850           {
851             "id": "ERICA5779-TestSub-PWT-102",
852             "name": "ERICA5779-TestSub-PWT-102",
853             "isPermitted": false
854           },
855           {
856             "id": "ERICA5779-TestSub-PWT-101",
857             "name": "ERICA5779-TestSub-PWT-101",
858             "isPermitted": false
859           },
860           {
861             "id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
862             "name": "Emanuel",
863             "isPermitted": false
864           },
865           {
866             "id": "ERICA5779-Subscriber-4",
867             "name": "ERICA5779-Subscriber-5",
868             "isPermitted": false
869           },
870           {
871             "id": "ERICA5779-TestSub-PWT-103",
872             "name": "ERICA5779-TestSub-PWT-103",
873             "isPermitted": false
874           },
875           {
876             "id": "ERICA5779-Subscriber-2",
877             "name": "ERICA5779-Subscriber-2",
878             "isPermitted": false
879           },
880           {
881             "id": "e433710f-9217-458d-a79d-1c7aff376d89",
882             "name": "SILVIA ROBBINS",
883             "isPermitted": true
884           },
885           {
886             "id": "ERICA5779-Subscriber-3",
887             "name": "ERICA5779-Subscriber-3",
888             "isPermitted": false
889           },
890           {
891             "id": "31739f3e-526b-11e6-beb8-9e71128cae77",
892             "name": "CRAIG/ROBERTS",
893             "isPermitted": false
894           }
895         ]
896       }
897     }
898   }
899 }
900
901 class MockFeatureFlagsService {
902 }
903
904 describe('Service Control Generator', () => {
905   let injector;
906   let service: ServiceControlGenerator;
907   let httpMock: HttpTestingController;
908
909
910   beforeAll(done => (async () => {
911     TestBed.configureTestingModule({
912       imports: [HttpClientTestingModule],
913       providers: [ServiceControlGenerator,
914         GenericFormService,
915         BasicControlGenerator,
916         AaiService,
917         FormBuilder,
918         LogService,
919         {provide: FeatureFlagsService, useClass: MockFeatureFlagsService},
920         {provide: NgRedux, useClass: MockAppStore}]
921     });
922     await TestBed.compileComponents();
923
924     injector = getTestBed();
925     service = injector.get(ServiceControlGenerator);
926     httpMock = injector.get(HttpTestingController);
927
928   })().then(done).catch(done.fail));
929
930
931   test('ServiceControlGenerator should return the correct controls with correct order', () => {
932     const serviceId: string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
933     const controls: FormControlModel[] = service.getMacroFormControls(serviceId);
934     const globalSubscriberIdControl: DropdownFormControl = <DropdownFormControl>controls.find(item => item.controlName === FormControlNames.GLOBAL_SUBSCRIBER_ID);
935
936     expect(globalSubscriberIdControl.validations.find(val => val.validatorName === ValidatorOptions.required)).toBeDefined();
937     expect(globalSubscriberIdControl.dataTestId).toEqual('subscriberName');
938     expect(globalSubscriberIdControl.type).toEqual(FormControlType.DROPDOWN);
939     expect(globalSubscriberIdControl.isDisabled).toBeFalsy();
940     expect(globalSubscriberIdControl.placeHolder).toEqual('Select Subscriber Name');
941     expect(globalSubscriberIdControl.displayName).toEqual('Subscriber name');
942     expect(globalSubscriberIdControl.onInit).toBeDefined();
943     expect(globalSubscriberIdControl.onChange).toBeDefined();
944
945     const serviceTypeControl: DropdownFormControl = <DropdownFormControl>controls.find(item => item.controlName === FormControlNames.SUBSCRIPTION_SERVICE_TYPE);
946     expect(serviceTypeControl.validations.find(val => val.validatorName === ValidatorOptions.required)).toBeDefined();
947     expect(serviceTypeControl.dataTestId).toEqual('serviceType');
948     expect(serviceTypeControl.type).toEqual(FormControlType.DROPDOWN);
949     expect(serviceTypeControl.isDisabled).toBeTruthy();
950     expect(serviceTypeControl.placeHolder).toEqual('Select Service Type');
951     expect(serviceTypeControl.displayName).toEqual('Service type');
952     expect(serviceTypeControl.onInit).toBeDefined();
953     expect(serviceTypeControl.onChange).toBeDefined();
954
955     const productFamilyControl: DropdownFormControl = <DropdownFormControl>controls.find(item => item.controlName === FormControlNames.PRODUCT_FAMILY_ID);
956     expect(productFamilyControl.validations.find(val => val.validatorName === ValidatorOptions.required)).toBeDefined();
957     expect(productFamilyControl.dataTestId).toEqual('productFamily');
958     expect(productFamilyControl.type).toEqual(FormControlType.DROPDOWN);
959     expect(productFamilyControl.isDisabled).toBeFalsy();
960     expect(productFamilyControl.placeHolder).toEqual('Select Product Family');
961     expect(productFamilyControl.displayName).toEqual('Product family');
962     expect(productFamilyControl.onInit).toBeDefined();
963
964     const lcpRegionControl: DropdownFormControl = <DropdownFormControl>controls.find(item => item.controlName === FormControlNames.LCPCLOUD_REGION_ID);
965     expect(lcpRegionControl.validations.find(val => val.validatorName === ValidatorOptions.required)).toBeDefined();
966     expect(lcpRegionControl.dataTestId).toEqual('lcpRegion');
967     expect(lcpRegionControl.type).toEqual(FormControlType.DROPDOWN);
968     expect(lcpRegionControl.isDisabled).toBeTruthy();
969     expect(lcpRegionControl.placeHolder).toEqual('Select LCP Region');
970     expect(lcpRegionControl.displayName).toEqual('LCP region');
971     expect(lcpRegionControl.onInit).toBeDefined();
972     expect(lcpRegionControl.onChange).toBeDefined();
973
974     const tenantControl: DropdownFormControl = <DropdownFormControl>controls.find(item => item.controlName === FormControlNames.TENANT_ID);
975     expect(tenantControl.validations.find(val => val.validatorName === ValidatorOptions.required)).toBeDefined();
976     expect(tenantControl.dataTestId).toEqual('tenant');
977     expect(tenantControl.type).toEqual(FormControlType.DROPDOWN);
978     expect(tenantControl.isDisabled).toBeTruthy();
979     expect(tenantControl.placeHolder).toEqual('Select Tenant');
980     expect(tenantControl.displayName).toEqual('Tenant');
981     expect(tenantControl.onInit).toBeDefined();
982     expect(tenantControl.onChange).toBeDefined();
983
984     const instanceNameControl: FormControlModel = <FormControlModel>controls.find(item => item.controlName === FormControlNames.INSTANCE_NAME);
985     const instanceNameValidator: ValidatorModel = instanceNameControl.validations.find(val => val.validatorName === ValidatorOptions.pattern);
986     expect(instanceNameValidator.validatorArg).toEqual(/^[a-zA-Z0-9._-]*$/);
987   });
988
989
990   test('getMacroFormControls should return the correct order of controls', () => {
991     // Order the fields
992     // 1.       Instance name
993     // 2.       Subscriber name
994     // 3.       Service type
995     // 4.       Owning entity (fix Entity to entity)
996     // 5.       Product family
997     // 6.       LCP region
998     // 7.       Tenant
999     // 8.       AIC zone (fix Zone to zone)
1000     // 9.       Pause on pause points
1001     // 10.      Project
1002     // 11.      Rollback on failure
1003     const serviceId: string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
1004     const controls: FormControlModel[] = service.getMacroFormControls(serviceId);
1005
1006
1007     const controlsOrderNames = [
1008       FormControlNames.INSTANCE_NAME,
1009       FormControlNames.GLOBAL_SUBSCRIBER_ID,
1010       FormControlNames.SUBSCRIPTION_SERVICE_TYPE,
1011       FormControlNames.OWNING_ENTITY_ID,
1012       FormControlNames.PRODUCT_FAMILY_ID,
1013       FormControlNames.LCPCLOUD_REGION_ID,
1014       FormControlNames.TENANT_ID,
1015       FormControlNames.AICZONE_ID,
1016       FormControlNames.PAUSE,
1017       FormControlNames.PROJECT_NAME,
1018       FormControlNames.ROLLBACK_ON_FAILURE];
1019     expect(controls.length).toEqual(11);
1020     for (let i = 0; i < controls.length; i++) {
1021       expect(controls[i].controlName).toEqual(controlsOrderNames[i]);
1022     }
1023   });
1024
1025   test('getAlacartFormControls should return the correct order of controls', () => {
1026     // Order the fields
1027     // 1.       Instance name
1028     // 2.       Subscriber name
1029     // 3.       Service type
1030     // 4.       Owning entity (fix Entity to entity)
1031     // 5.       Project
1032     // 6.       Rollback on failure
1033     const serviceId: string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
1034     const controls: FormControlModel[] = service.getAlaCartControls(serviceId);
1035     const controlsOrderNames = [
1036       FormControlNames.INSTANCE_NAME,
1037       FormControlNames.GLOBAL_SUBSCRIBER_ID,
1038       FormControlNames.SUBSCRIPTION_SERVICE_TYPE,
1039       FormControlNames.OWNING_ENTITY_ID,
1040       FormControlNames.PROJECT_NAME,
1041       FormControlNames.ROLLBACK_ON_FAILURE];
1042
1043     expect(controls.length).toEqual(6);
1044     for (let i = 0; i < controls.length; i++) {
1045       expect(controls[i].controlName).toEqual(controlsOrderNames[i]);
1046     }
1047   });
1048
1049   test('getMacroFormControls for Transport service type should return optional for lcp region and tenant', () => {
1050     const serviceId: string = "7e59c5de-f052-46fa-aa7e-2fca9d674c43";
1051     const controls: FormControlModel[] = service.getMacroFormControls(serviceId);
1052
1053     const lcpRegionControl: DropdownFormControl = <DropdownFormControl>controls.find(item => item.controlName === FormControlNames.LCPCLOUD_REGION_ID);
1054     expect(lcpRegionControl.validations.length).toEqual(0);
1055     expect(lcpRegionControl.dataTestId).toEqual('lcpRegion');
1056     expect(lcpRegionControl.type).toEqual(FormControlType.DROPDOWN);
1057     expect(lcpRegionControl.isDisabled).toBeTruthy();
1058     expect(lcpRegionControl.placeHolder).toEqual('Select LCP Region');
1059     expect(lcpRegionControl.displayName).toEqual('LCP region');
1060     expect(lcpRegionControl.onInit).toBeDefined();
1061     expect(lcpRegionControl.onChange).toBeDefined();
1062
1063     const tenantControl: DropdownFormControl = <DropdownFormControl>controls.find(item => item.controlName === FormControlNames.TENANT_ID);
1064     expect(tenantControl.validations.length).toEqual(0);
1065     expect(tenantControl.dataTestId).toEqual('tenant');
1066     expect(tenantControl.type).toEqual(FormControlType.DROPDOWN);
1067     expect(tenantControl.isDisabled).toBeTruthy();
1068     expect(tenantControl.placeHolder).toEqual('Select Tenant');
1069     expect(tenantControl.displayName).toEqual('Tenant');
1070     expect(tenantControl.onInit).toBeDefined();
1071     expect(tenantControl.onChange).toBeDefined();
1072   });
1073
1074   const isRegionAndTenantOptionalProvider = [
1075     [{modelCategory:"Transport"}, true],
1076     [{modelCategory:"dontKnow"}, false],
1077     [undefined, false],
1078     [{}, false]
1079   ];
1080
1081   each(isRegionAndTenantOptionalProvider).test(`isRegionAndTenantOptional shall be as expected`, (vidNotions:VidNotions, expectedResult:boolean)=>{
1082     expect(service.isRegionAndTenantOptional(vidNotions)).toEqual(expectedResult);
1083   });
1084
1085 });
1086