1 import {ServiceInstance} from "../../../models/serviceInstance";
5 CreateServiceInstanceAction,
6 DeleteServiceInstanceAction,
8 UpdateServiceInstanceAction,
9 UpdateServiceModelAction, UpgradeServiceAction
10 } from "./service.actions";
11 import {serviceReducer} from "./service.reducers";
12 import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
13 import {VidNotions} from "../../../models/vidNotions";
15 describe('serviceReducer', () => {
17 test('#UPDATE_SERVICE_INSTANCE should update exiting instance without change his child', () => {
18 const serviceUuid: string = 'serviceUuid';
19 const actionName: ServiceInstanceActions = ServiceInstanceActions.Create;
21 const elemntThatShouldNotOverideOnUpdateService = {
23 "2017-388_PASQUALE-vPE 0": {
26 "rollbackOnFailure": "true",
27 "originalName": "2017-388_PASQUALE-vPE 0",
28 "isMissingData": false,
29 "trackById": "eymgwlevh54",
31 "vnfStoreKey": "2017-388_PASQUALE-vPE 0",
32 "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168",
33 "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
34 "lcpCloudRegionId": "AAIAIC25",
35 "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
36 "lineOfBusiness": "ONAP",
37 "platformName": "platform",
39 "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
40 "modelVersionId": "afacccf6-397d-45d6-b5ae-94c39734b168",
41 "modelName": "2017-388_PASQUALE-vPE",
42 "modelVersion": "4.0",
43 "modelCustomizationId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c",
44 "modelCustomizationName": "2017-388_PASQUALE-vPE 0",
45 "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168",
46 "modelUniqueId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c"
48 "instanceName": "2017-388_PASQUALE-vPEAjXzainstanceName",
49 "legacyRegion": "some legacy region",
52 "vnf_config_template_version": "17.2",
53 "bandwidth_units": "Gbps",
55 "AIC_CLLI": "ATLMY8GA",
57 "vnf_instance_name": "mtnj309me6"
61 "2017-488_PASQUALE-vPE 0": {
64 "rollbackOnFailure": "true",
65 "originalName": "2017-488_PASQUALE-vPE 0",
66 "isMissingData": false,
67 "trackById": "xr6o2782z7",
69 "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": {
70 "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0wmkjw": {
71 "isMissingData": true,
72 "sdncPreReload": null,
74 "modelType": "VFmodule",
75 "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091",
76 "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db",
77 "modelName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
79 "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3",
80 "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
81 "modelUniqueId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3"
86 "trackById": "a19sjb1ez2"
90 "vnfStoreKey": "2017-488_PASQUALE-vPE 0",
91 "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
92 "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
93 "lcpCloudRegionId": "AAIAIC25",
94 "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
95 "lineOfBusiness": "ONAP",
96 "platformName": "platform",
98 "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
99 "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
100 "modelName": "2017-488_PASQUALE-vPE",
101 "modelVersion": "5.0",
102 "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45",
103 "modelCustomizationName": "2017-488_PASQUALE-vPE 0",
104 "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
105 "modelUniqueId": "1da7b585-5e61-4993-b95e-8e6606c81e45"
107 "instanceName": "2017-488_PASQUALE-vPEVNFinstancename",
108 "legacyRegion": "some legacy region",
111 "vnf_config_template_version": "17.2",
112 "bandwidth_units": "Gbps",
114 "AIC_CLLI": "ATLMY8GA",
116 "vnf_instance_name": "mtnj309me6"
121 existingVNFCounterMap: {
122 "b3c76f73-eeb5-4fb6-9d31-72a889f1811c": 1,
123 "1da7b585-5e61-4993-b95e-8e6606c81e45": 1
125 existingVnfGroupCounterMap: {},
126 existingNetworksCounterMap: {},
127 optionalGroupMembersMap : {},
133 let service = serviceReducer(<any>{
135 "6b528779-44a3-4472-bdff-9cd15ec93450": {
138 "vnfs": elemntThatShouldNotOverideOnUpdateService.vnfs,
141 "2017488_pasqualevpe0_ASN": "AV_vPE"
144 "validationCounter": 1,
146 "ajxzainstancename": "",
147 "2017-488_pasquale-vpevnfinstancename": "",
148 "2017-388_pasquale-vpeajxzainstancename": ""
150 "existingVNFCounterMap": elemntThatShouldNotOverideOnUpdateService.existingVNFCounterMap,
151 "existingVnfGroupCounterMap": elemntThatShouldNotOverideOnUpdateService.existingVnfGroupCounterMap,
152 "existingNetworksCounterMap": elemntThatShouldNotOverideOnUpdateService.existingNetworksCounterMap,
153 "optionalGroupMembersMap":elemntThatShouldNotOverideOnUpdateService.optionalGroupMembersMap,
154 "networks": elemntThatShouldNotOverideOnUpdateService.networks,
155 "vnfGroups": elemntThatShouldNotOverideOnUpdateService.vnfGroups,
157 "instanceName": "AjXzainstancename",
158 "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89",
159 "subscriptionServiceType": "TYLER SILVIA",
160 "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
161 "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
162 "lcpCloudRegionId": "hvf6",
163 "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
165 "projectName": "WATKINS",
166 "rollbackOnFailure": "true",
167 "aicZoneName": "NFTJSSSS-NFT1",
168 "owningEntityName": "WayneHolland",
169 "testApi": "VNF_API",
170 "tenantName": "AIN Web Tool-15-D-testalexandria",
172 "modelInvariantId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
173 "modelVersionId": "6b528779-44a3-4472-bdff-9cd15ec93450",
174 "modelName": "action-data",
175 "modelVersion": "1.0",
176 "uuid": "6b528779-44a3-4472-bdff-9cd15ec93450",
177 "modelUniqueId": "6b528779-44a3-4472-bdff-9cd15ec93450"
180 "name": "action-data",
184 "uuid": "6b528779-44a3-4472-bdff-9cd15ec93450",
185 "invariantUuid": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
189 "instantiationUI": "legacy",
190 "modelCategory": "other",
191 "viewEditUI": "legacy"
193 "isEcompGeneratedNaming": false,
194 "isMultiStepDesign": false
197 }, <UpdateServiceInstanceAction>{
198 type: ServiceActions.UPDATE_SERVICE_INSTANCE,
199 serviceUuid: "6b528779-44a3-4472-bdff-9cd15ec93450",
200 serviceInstance: <any>{
202 aicZoneName: "AAIATLTE-ATL53",
206 globalSubscriberId: "e433710f-9217-458d-a79d-1c7aff376d89",
207 instanceName: "yoav",
208 instanceParams: [{}],
209 invariantUuid: "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
211 isEcompGeneratedNaming: false,
212 isMultiStepDesign: false,
213 lcpCloudRegionId: "AAIAIC25",
215 modelInvariantId: "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
216 modelVersionId: "6b528779-44a3-4472-bdff-9cd15ec93450",
217 modelName: "action-data",
221 owningEntityId: "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
222 owningEntityName: "WayneHolland",
223 productFamilyId: "d8a6ed93-251c-47ca-adc9-86671fd19f4c",
224 projectName: "WATKINS",
225 rollbackOnFailure: "true",
228 subscriptionServiceType: "TYLER SILVIA",
229 tenantId: "092eb9e8e4b7412e8787dd091bc58e86",
230 tenantName: "USP-SIP-IC-24335-T-01",
232 uuid: "6b528779-44a3-4472-bdff-9cd15ec93450",
234 vidNotions: {instantiationUI: "legacy", modelCategory: "other", viewEditUI: "legacy"}
237 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"]).toBeDefined();
239 for(const element in elemntThatShouldNotOverideOnUpdateService){
240 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"][element]).toEqual(elemntThatShouldNotOverideOnUpdateService[element]);
243 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].aicZoneId).toEqual("ATL53");
244 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].owningEntityId).toEqual("d61e6f2d-12fa-4cc2-91df-7c244011d6fc");
245 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].owningEntityName).toEqual("WayneHolland");
246 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].productFamilyId).toEqual("d8a6ed93-251c-47ca-adc9-86671fd19f4c");
247 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].projectName).toEqual("WATKINS");
248 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].rollbackOnFailure).toEqual("true");
249 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].subscriptionServiceType).toEqual("TYLER SILVIA");
250 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].tenantId).toEqual("092eb9e8e4b7412e8787dd091bc58e86");
254 test('#ADD_SERVICE_ACTION should add action to the service', () => {
255 const serviceUuid: string = 'serviceUuid';
256 const actionName: ServiceInstanceActions = ServiceInstanceActions.Create;
258 let service = serviceReducer(<any>{
262 }, <AddServiceAction>{
263 type: ServiceActions.ADD_SERVICE_ACTION,
264 serviceUuid: 'serviceUuid',
267 expect(service.serviceInstance[serviceUuid]['action']).toEqual(actionName);
270 test('#CREATE_SERVICE_INSTANCE shall put the instance on state with all its values ', () => {
271 const serviceUuid: string = 'serviceUuid';
272 const vidNotions:VidNotions = {
273 instantiationUI: "some5G",
274 modelCategory: "5G Provider Network",
275 viewEditUI: "legacy",
276 instantiationType: "ALaCarte"
279 let serviceInstanceObject: ServiceInstance = <any>{
281 instanceName: 'instanceName',
282 isEcompGeneratedNaming: false,
283 globalSubscriberId: 'globalSubscriberId',
284 productFamilyId: 'productFamilyId',
285 subscriptionServiceType: 'subscriptionServiceType',
286 lcpCloudRegionId: 'lcpCloudRegionId',
287 tenantId: 'tenantId',
288 tenantName: 'tenantName',
289 aicZoneId: 'aicZoneId',
290 aicZoneName: 'aicZoneName',
291 projectName: 'projectName',
292 owningEntityId: 'owningEntityId',
293 owningEntityName: 'owningEntityName',
294 existingVnfGroupCounterMap: {},
295 existingVNFCounterMap: {},
296 existingNetworksCounterMap: {},
303 rollbackOnFailure: false,
304 subscriberName: 'subscriberName',
305 validationCounter: 0,
307 action: ServiceInstanceActions.Create
310 let serviceState = serviceReducer(
316 vidNotions: vidNotions
321 <CreateServiceInstanceAction>{
322 type: ServiceActions.CREATE_SERVICE_INSTANCE,
323 serviceUuid: serviceUuid,
324 serviceInstance: serviceInstanceObject
325 }).serviceInstance[serviceUuid];
327 expect(serviceState.instanceName).toEqual(serviceInstanceObject.instanceName);
328 expect(serviceState.isEcompGeneratedNaming).toEqual(serviceInstanceObject.isEcompGeneratedNaming);
329 expect(serviceState.globalSubscriberId).toEqual(serviceInstanceObject.globalSubscriberId);
330 expect(serviceState.productFamilyId).toEqual(serviceInstanceObject.productFamilyId);
331 expect(serviceState.subscriptionServiceType).toEqual(serviceInstanceObject.subscriptionServiceType);
332 expect(serviceState.lcpCloudRegionId).toEqual(serviceInstanceObject.lcpCloudRegionId);
333 expect(serviceState.tenantId).toEqual(serviceInstanceObject.tenantId);
334 expect(serviceState.tenantName).toEqual(serviceInstanceObject.tenantName);
335 expect(serviceState.aicZoneId).toEqual(serviceInstanceObject.aicZoneId);
336 expect(serviceState.aicZoneName).toEqual(serviceInstanceObject.aicZoneName);
337 expect(serviceState.projectName).toEqual(serviceInstanceObject.projectName);
338 expect(serviceState.owningEntityId).toEqual(serviceInstanceObject.owningEntityId);
339 expect(serviceState.owningEntityName).toEqual(serviceInstanceObject.owningEntityName);
340 expect(serviceState.pause).toEqual(serviceInstanceObject.pause);
341 expect(serviceState.bulkSize).toEqual(serviceInstanceObject.bulkSize);
342 expect(serviceState.vnfs).toEqual(serviceInstanceObject.vnfs);
343 expect(serviceState.instanceParams).toEqual(serviceInstanceObject.instanceParams);
344 expect(serviceState.rollbackOnFailure).toEqual(serviceInstanceObject.rollbackOnFailure);
345 expect(serviceState.subscriberName).toEqual(serviceInstanceObject.subscriberName);
346 expect(serviceState.vidNotions).toEqual(vidNotions);
350 test('#DELETE_ALL_SERVICE_INSTANCES should delete all services', () => {
351 const state = serviceReducer(<any>{
357 <CreateServiceInstanceAction>{
358 type: ServiceActions.DELETE_ALL_SERVICE_INSTANCES
361 expect(state.serviceInstance['service-1']).toBeUndefined();
362 expect(state.serviceInstance['service-2']).toBeUndefined();
365 test('#DELETE_SERVICE_INSTANCE should delete service', () => {
366 const state = serviceReducer(<any>{
371 <DeleteServiceInstanceAction>{
372 type: ServiceActions.DELETE_ALL_SERVICE_INSTANCES
375 expect(state.serviceInstance['service-1']).toBeUndefined();
378 test('#UPDATE_MODEL should update service model ', () => {
379 const state = serviceReducer(<any>{
382 <UpdateServiceModelAction>{
383 type: ServiceActions.UPDATE_MODEL,
391 expect(state.serviceHierarchy['uuid-1'].service).toBeDefined();
394 test('#UPDATE_MODEL should update service model with vnfGroups ', () => {
395 const state = serviceReducer(<any>{
398 <UpdateServiceModelAction>{
399 type: ServiceActions.UPDATE_MODEL,
407 uuid: 'vnfGroup_uuid_1',
408 name: 'vnfGroup_name_1',
412 uuid: 'vnfGroup_uuid_2',
413 name: 'vnfGroup_name_2',
420 expect(state.serviceHierarchy['uuid-1']).toBeDefined();
421 expect(state.serviceHierarchy['uuid-1'].vnfGroups['vnfGrouop_1']).toBeDefined();
422 expect(state.serviceHierarchy['uuid-1'].vnfGroups['vnfGrouop_2']).toBeDefined();
425 test('#CHANGE_SERVICE_IS_DIRTY should update service isDirty flag : service is not dirty ', () => {
426 const state = serviceReducer(<any>{
429 action: ServiceInstanceActions.None,
432 action: ServiceInstanceActions.None
435 action: ServiceInstanceActions.None
442 <ChangeServiceDirty>{
443 type: ServiceActions.CHANGE_SERVICE_IS_DIRTY,
446 action: ServiceInstanceActions.None
449 action: ServiceInstanceActions.None
451 serviceId: 'serviceId'
455 expect(state.serviceInstance['serviceId'].isDirty).toBeFalsy();
458 test('#CHANGE_SERVICE_IS_DIRTY should update service isDirty flag : service is dirty should return true', () => {
459 const state = serviceReducer(<any>{
462 action: ServiceInstanceActions.Create
467 <ChangeServiceDirty>{
468 type: ServiceActions.CHANGE_SERVICE_IS_DIRTY,
471 action: ServiceInstanceActions.None
474 action: ServiceInstanceActions.None
476 serviceId: 'serviceId'
480 expect(state.serviceInstance['serviceId'].isDirty).toBeTruthy();
483 test('#CHANGE_SERVICE_IS_DIRTY should update service isDirty flag : vnf is dirty ', () => {
484 const state = serviceReducer(<any>{
487 action: ServiceInstanceActions.None,
490 action: ServiceInstanceActions.None
493 action: ServiceInstanceActions.Create
500 <ChangeServiceDirty>{
501 type: ServiceActions.CHANGE_SERVICE_IS_DIRTY,
504 action: ServiceInstanceActions.None
507 action: ServiceInstanceActions.Create
509 serviceId: 'serviceId'
513 expect(state.serviceInstance['serviceId'].isDirty).toBeTruthy();
516 test('#UPGRADE_SERVICE should update service action to _Upgrade', () => {
517 const state = serviceReducer(<any>{
520 action: ServiceInstanceActions.None,
521 upgradedVFMSonsCounter: 0,
524 action: ServiceInstanceActions.None
527 action: ServiceInstanceActions.Create
534 <UpgradeServiceAction> {
535 type: ServiceActions.UPGRADE_SERVICE_ACTION,
536 serviceUuid: 'serviceId'
539 expect(state.serviceInstance['serviceId'].isUpgraded).toBeTruthy();
540 expect(state.serviceInstance['serviceId'].action).toEqual(ServiceInstanceActions.None_Upgrade);
541 expect(state.serviceInstance['serviceId'].upgradedVFMSonsCounter).toEqual(1);
545 test('#UNDO_UPGRADE_SERVICE should cancel the upgrade action back to None', () => {
546 const state = serviceReducer(<any>{
550 upgradedVFMSonsCounter: 1,
551 action: ServiceInstanceActions.None_Upgrade,
554 action: ServiceInstanceActions.None_Upgrade
557 action: ServiceInstanceActions.Create
564 <UpgradeServiceAction> {
565 type: ServiceActions.UNDO_UPGRADE_SERVICE_ACTION,
566 serviceUuid: 'serviceId'
569 expect(state.serviceInstance['serviceId'].isUpgraded).toBeFalsy();
570 expect(state.serviceInstance['serviceId'].action).toEqual(ServiceInstanceActions.None);
571 expect(state.serviceInstance['serviceId'].upgradedVFMSonsCounter).toEqual(0);