1 import {ServiceInstance} from "../../../models/serviceInstance";
3 AddServiceAction, ChangeServiceDirty,
4 DeleteServiceInstanceAction,
6 CreateServiceInstanceAction,
7 UpdateServiceModelAction, UpdateServiceInstanceAction
8 } from "./service.actions";
9 import {serviceReducer} from "./service.reducers";
10 import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
12 describe('serviceReducer', () => {
14 test('#UPDATE_SERVICE_INSTANCE should update exiting instance without change his child', () => {
15 const serviceUuid: string = 'serviceUuid';
16 const actionName: ServiceInstanceActions = ServiceInstanceActions.Create;
18 const elemntThatShouldNotOverideOnUpdateService = {
20 "2017-388_ADIOD-vPE 0": {
23 "rollbackOnFailure": "true",
24 "originalName": "2017-388_ADIOD-vPE 0",
25 "isMissingData": false,
26 "trackById": "eymgwlevh54",
28 "vnfStoreKey": "2017-388_ADIOD-vPE 0",
29 "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168",
30 "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
31 "lcpCloudRegionId": "JANET25",
32 "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
33 "lineOfBusiness": "ONAP",
34 "platformName": "platform",
36 "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
37 "modelVersionId": "afacccf6-397d-45d6-b5ae-94c39734b168",
38 "modelName": "2017-388_ADIOD-vPE",
39 "modelVersion": "4.0",
40 "modelCustomizationId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c",
41 "modelCustomizationName": "2017-388_ADIOD-vPE 0",
42 "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168",
43 "modelUniqueId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c"
45 "instanceName": "2017-388_ADIOD-vPEAjXzainstanceName",
46 "legacyRegion": "some legacy region",
49 "vnf_config_template_version": "17.2",
50 "bandwidth_units": "Gbps",
52 "AIC_CLLI": "ATLMY8GA",
54 "vnf_instance_name": "mtnj309me6"
58 "2017-488_ADIOD-vPE 0": {
61 "rollbackOnFailure": "true",
62 "originalName": "2017-488_ADIOD-vPE 0",
63 "isMissingData": false,
64 "trackById": "xr6o2782z7",
66 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": {
67 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0wmkjw": {
68 "isMissingData": true,
69 "sdncPreReload": null,
71 "modelType": "VFmodule",
72 "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091",
73 "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db",
74 "modelName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
76 "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3",
77 "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
78 "modelUniqueId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3"
83 "trackById": "a19sjb1ez2"
87 "vnfStoreKey": "2017-488_ADIOD-vPE 0",
88 "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
89 "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
90 "lcpCloudRegionId": "JANET25",
91 "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
92 "lineOfBusiness": "ONAP",
93 "platformName": "platform",
95 "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
96 "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
97 "modelName": "2017-488_ADIOD-vPE",
98 "modelVersion": "5.0",
99 "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45",
100 "modelCustomizationName": "2017-488_ADIOD-vPE 0",
101 "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
102 "modelUniqueId": "1da7b585-5e61-4993-b95e-8e6606c81e45"
104 "instanceName": "2017-488_ADIOD-vPEVNFinstancename",
105 "legacyRegion": "some legacy region",
108 "vnf_config_template_version": "17.2",
109 "bandwidth_units": "Gbps",
111 "AIC_CLLI": "ATLMY8GA",
113 "vnf_instance_name": "mtnj309me6"
118 existingVNFCounterMap: {
119 "b3c76f73-eeb5-4fb6-9d31-72a889f1811c": 1,
120 "1da7b585-5e61-4993-b95e-8e6606c81e45": 1
122 existingVnfGroupCounterMap: {},
123 existingNetworksCounterMap: {},
124 optionalGroupMembersMap : {},
130 let service = serviceReducer(<any>{
132 "6b528779-44a3-4472-bdff-9cd15ec93450": {
135 "vnfs": elemntThatShouldNotOverideOnUpdateService.vnfs,
138 "2017488_adiodvpe0_ASN": "AV_vPE"
141 "validationCounter": 1,
143 "ajxzainstancename": "",
144 "2017-488_adiod-vpevnfinstancename": "",
145 "2017-388_adiod-vpeajxzainstancename": ""
147 "existingVNFCounterMap": elemntThatShouldNotOverideOnUpdateService.existingVNFCounterMap,
148 "existingVnfGroupCounterMap": elemntThatShouldNotOverideOnUpdateService.existingVnfGroupCounterMap,
149 "existingNetworksCounterMap": elemntThatShouldNotOverideOnUpdateService.existingNetworksCounterMap,
150 "optionalGroupMembersMap":elemntThatShouldNotOverideOnUpdateService.optionalGroupMembersMap,
151 "networks": elemntThatShouldNotOverideOnUpdateService.networks,
152 "vnfGroups": elemntThatShouldNotOverideOnUpdateService.vnfGroups,
154 "instanceName": "AjXzainstancename",
155 "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89",
156 "subscriptionServiceType": "TYLER SILVIA",
157 "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
158 "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
159 "lcpCloudRegionId": "hvf6",
160 "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
162 "projectName": "WATKINS",
163 "rollbackOnFailure": "true",
164 "aicZoneName": "NFTJSSSS-NFT1",
165 "owningEntityName": "WayneHolland",
166 "testApi": "VNF_API",
167 "tenantName": "AIN Web Tool-15-D-testalexandria",
169 "modelInvariantId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
170 "modelVersionId": "6b528779-44a3-4472-bdff-9cd15ec93450",
171 "modelName": "action-data",
172 "modelVersion": "1.0",
173 "uuid": "6b528779-44a3-4472-bdff-9cd15ec93450",
174 "modelUniqueId": "6b528779-44a3-4472-bdff-9cd15ec93450"
177 "name": "action-data",
181 "uuid": "6b528779-44a3-4472-bdff-9cd15ec93450",
182 "invariantUuid": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
186 "instantiationUI": "legacy",
187 "modelCategory": "other",
188 "viewEditUI": "legacy"
190 "isEcompGeneratedNaming": false,
191 "isMultiStepDesign": false
194 }, <UpdateServiceInstanceAction>{
195 type: ServiceActions.UPDATE_SERVICE_INSTANCE,
196 serviceUuid: "6b528779-44a3-4472-bdff-9cd15ec93450",
197 serviceInstance: <any>{
199 aicZoneName: "AAIATLTE-ATL53",
203 globalSubscriberId: "e433710f-9217-458d-a79d-1c7aff376d89",
204 instanceName: "yoav",
205 instanceParams: [{}],
206 invariantUuid: "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
208 isEcompGeneratedNaming: false,
209 isMultiStepDesign: false,
210 lcpCloudRegionId: "JANET25",
212 modelInvariantId: "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
213 modelVersionId: "6b528779-44a3-4472-bdff-9cd15ec93450",
214 modelName: "action-data",
218 owningEntityId: "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
219 owningEntityName: "WayneHolland",
220 productFamilyId: "d8a6ed93-251c-47ca-adc9-86671fd19f4c",
221 projectName: "WATKINS",
222 rollbackOnFailure: "true",
225 subscriptionServiceType: "TYLER SILVIA",
226 tenantId: "092eb9e8e4b7412e8787dd091bc58e86",
227 tenantName: "USP-SIP-IC-24335-T-01",
229 uuid: "6b528779-44a3-4472-bdff-9cd15ec93450",
231 vidNotions: {instantiationUI: "legacy", modelCategory: "other", viewEditUI: "legacy"}
234 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"]).toBeDefined();
236 for(const element in elemntThatShouldNotOverideOnUpdateService){
237 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"][element]).toEqual(elemntThatShouldNotOverideOnUpdateService[element]);
240 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].aicZoneId).toEqual("ATL53");
241 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].owningEntityId).toEqual("d61e6f2d-12fa-4cc2-91df-7c244011d6fc");
242 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].owningEntityName).toEqual("WayneHolland");
243 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].productFamilyId).toEqual("d8a6ed93-251c-47ca-adc9-86671fd19f4c");
244 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].projectName).toEqual("WATKINS");
245 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].rollbackOnFailure).toEqual("true");
246 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].subscriptionServiceType).toEqual("TYLER SILVIA");
247 expect(service.serviceInstance["6b528779-44a3-4472-bdff-9cd15ec93450"].tenantId).toEqual("092eb9e8e4b7412e8787dd091bc58e86");
251 test('#ADD_SERVICE_ACTION should add action to the service', () => {
252 const serviceUuid: string = 'serviceUuid';
253 const actionName: ServiceInstanceActions = ServiceInstanceActions.Create;
255 let service = serviceReducer(<any>{
259 }, <AddServiceAction>{
260 type: ServiceActions.ADD_SERVICE_ACTION,
261 serviceUuid: 'serviceUuid',
264 expect(service.serviceInstance[serviceUuid]['action']).toEqual(actionName);
267 test('#UPDATE_SERVICE_INSTANCE', () => {
268 const serviceUuid: string = 'serviceUuid';
270 let serviceInstanceObject: ServiceInstance = <any>{
272 instanceName: 'instanceName',
273 isEcompGeneratedNaming: false,
274 globalSubscriberId: 'globalSubscriberId',
275 productFamilyId: 'productFamilyId',
276 subscriptionServiceType: 'subscriptionServiceType',
277 lcpCloudRegionId: 'lcpCloudRegionId',
278 tenantId: 'tenantId',
279 tenantName: 'tenantName',
280 aicZoneId: 'aicZoneId',
281 aicZoneName: 'aicZoneName',
282 projectName: 'projectName',
283 owningEntityId: 'owningEntityId',
284 owningEntityName: 'owningEntityName',
285 existingVnfGroupCounterMap: {},
286 existingVNFCounterMap: {},
287 existingNetworksCounterMap: {},
294 rollbackOnFailure: false,
295 subscriberName: 'subscriberName',
296 validationCounter: 0,
298 action: ServiceInstanceActions.Create
301 let serviceState = serviceReducer(<any>{serviceInstance: {}},
302 <CreateServiceInstanceAction>{
303 type: ServiceActions.CREATE_SERVICE_INSTANCE,
304 serviceUuid: serviceUuid,
305 serviceInstance: serviceInstanceObject
306 }).serviceInstance[serviceUuid];
308 expect(serviceState.instanceName).toEqual(serviceInstanceObject.instanceName);
309 expect(serviceState.isEcompGeneratedNaming).toEqual(serviceInstanceObject.isEcompGeneratedNaming);
310 expect(serviceState.globalSubscriberId).toEqual(serviceInstanceObject.globalSubscriberId);
311 expect(serviceState.productFamilyId).toEqual(serviceInstanceObject.productFamilyId);
312 expect(serviceState.subscriptionServiceType).toEqual(serviceInstanceObject.subscriptionServiceType);
313 expect(serviceState.lcpCloudRegionId).toEqual(serviceInstanceObject.lcpCloudRegionId);
314 expect(serviceState.tenantId).toEqual(serviceInstanceObject.tenantId);
315 expect(serviceState.tenantName).toEqual(serviceInstanceObject.tenantName);
316 expect(serviceState.aicZoneId).toEqual(serviceInstanceObject.aicZoneId);
317 expect(serviceState.aicZoneName).toEqual(serviceInstanceObject.aicZoneName);
318 expect(serviceState.projectName).toEqual(serviceInstanceObject.projectName);
319 expect(serviceState.owningEntityId).toEqual(serviceInstanceObject.owningEntityId);
320 expect(serviceState.owningEntityName).toEqual(serviceInstanceObject.owningEntityName);
321 expect(serviceState.pause).toEqual(serviceInstanceObject.pause);
322 expect(serviceState.bulkSize).toEqual(serviceInstanceObject.bulkSize);
323 expect(serviceState.vnfs).toEqual(serviceInstanceObject.vnfs);
324 expect(serviceState.instanceParams).toEqual(serviceInstanceObject.instanceParams);
325 expect(serviceState.rollbackOnFailure).toEqual(serviceInstanceObject.rollbackOnFailure);
326 expect(serviceState.subscriberName).toEqual(serviceInstanceObject.subscriberName);
330 test('#DELETE_ALL_SERVICE_INSTANCES should delete all services', () => {
331 const state = serviceReducer(<any>{
337 <CreateServiceInstanceAction>{
338 type: ServiceActions.DELETE_ALL_SERVICE_INSTANCES
341 expect(state.serviceInstance['service-1']).toBeUndefined();
342 expect(state.serviceInstance['service-2']).toBeUndefined();
345 test('#DELETE_SERVICE_INSTANCE should delete service', () => {
346 const state = serviceReducer(<any>{
351 <DeleteServiceInstanceAction>{
352 type: ServiceActions.DELETE_ALL_SERVICE_INSTANCES
355 expect(state.serviceInstance['service-1']).toBeUndefined();
358 test('#UPDATE_MODEL should update service model ', () => {
359 const state = serviceReducer(<any>{
362 <UpdateServiceModelAction>{
363 type: ServiceActions.UPDATE_MODEL,
371 expect(state.serviceHierarchy['uuid-1'].service).toBeDefined();
374 test('#UPDATE_MODEL should update service model with vnfGroups ', () => {
375 const state = serviceReducer(<any>{
378 <UpdateServiceModelAction>{
379 type: ServiceActions.UPDATE_MODEL,
387 uuid: 'vnfGroup_uuid_1',
388 name: 'vnfGroup_name_1',
392 uuid: 'vnfGroup_uuid_2',
393 name: 'vnfGroup_name_2',
400 expect(state.serviceHierarchy['uuid-1']).toBeDefined();
401 expect(state.serviceHierarchy['uuid-1'].vnfGroups['vnfGrouop_1']).toBeDefined();
402 expect(state.serviceHierarchy['uuid-1'].vnfGroups['vnfGrouop_2']).toBeDefined();
405 test('#CHANGE_SERVICE_IS_DIRTY should update service isDirty flag : service is not dirty ', () => {
406 const state = serviceReducer(<any>{
409 action: ServiceInstanceActions.None,
412 action: ServiceInstanceActions.None
415 action: ServiceInstanceActions.None
422 <ChangeServiceDirty>{
423 type: ServiceActions.CHANGE_SERVICE_IS_DIRTY,
426 action: ServiceInstanceActions.None
429 action: ServiceInstanceActions.None
431 serviceId: 'serviceId'
435 expect(state.serviceInstance['serviceId'].isDirty).toBeFalsy();
438 test('#CHANGE_SERVICE_IS_DIRTY should update service isDirty flag : service is dirty should return true', () => {
439 const state = serviceReducer(<any>{
442 action: ServiceInstanceActions.Create
447 <ChangeServiceDirty>{
448 type: ServiceActions.CHANGE_SERVICE_IS_DIRTY,
451 action: ServiceInstanceActions.None
454 action: ServiceInstanceActions.None
456 serviceId: 'serviceId'
460 expect(state.serviceInstance['serviceId'].isDirty).toBeTruthy();
463 test('#CHANGE_SERVICE_IS_DIRTY should update service isDirty flag : vnf is dirty ', () => {
464 const state = serviceReducer(<any>{
467 action: ServiceInstanceActions.None,
470 action: ServiceInstanceActions.None
473 action: ServiceInstanceActions.Create
480 <ChangeServiceDirty>{
481 type: ServiceActions.CHANGE_SERVICE_IS_DIRTY,
484 action: ServiceInstanceActions.None
487 action: ServiceInstanceActions.Create
489 serviceId: 'serviceId'
493 expect(state.serviceInstance['serviceId'].isDirty).toBeTruthy();