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