2578d7b2d922f4a602dd4f418cdcd5bb92fccb9b
[vid.git] / vid-webpack-master / src / app / shared / resolvers / retry / retry.resolver.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 {ActivatedRouteSnapshot, convertToParamMap} from "@angular/router";
5 import {AppState} from "../../store/reducers";
6 import {RetryResolver} from "./retry.resolver";
7 import {AaiService} from "../../services/aaiService/aai.service";
8 import {FeatureFlagsService} from "../../services/featureFlag/feature-flags.service";
9 import {Observable, of} from "rxjs";
10
11 class MockAppStore<T> {
12   getState() {
13     return {
14       global:{
15         drawingBoardStatus: "VIEW"
16       },
17       service: {
18         serviceInstance: {}
19       }
20     }
21   }
22   dispatch(){
23
24   }
25 }
26
27
28 describe('View Edit resolver', () => {
29   let injector;
30   let aaiService: AaiService;
31   let resolver: RetryResolver;
32   let httpMock: HttpTestingController;
33   let store : NgRedux<AppState>;
34   let activatedRouteSnapshot: ActivatedRouteSnapshot;
35
36   beforeAll(done => (async () => {
37     TestBed.configureTestingModule({
38       imports: [HttpClientTestingModule],
39       providers: [
40         FeatureFlagsService,
41         RetryResolver,
42         AaiService,
43         {provide: NgRedux, useClass: MockAppStore},
44         {
45           provide: ActivatedRouteSnapshot, useValue: {
46             queryParamMap:
47               convertToParamMap({
48                 serviceModelId: 'serviceModelId',
49                 subscriberId: 'subscriberId',
50                 serviceType: 'serviceType',
51                 serviceInstanceId : 'serviceInstanceId',
52                 jobId : 'jobId'
53               })
54           },
55
56         }
57       ]
58     });
59     await TestBed.compileComponents();
60
61     injector = getTestBed();
62     aaiService = injector.get(AaiService);
63     resolver = injector.get(RetryResolver);
64     httpMock = injector.get(HttpTestingController);
65     activatedRouteSnapshot = injector.get(ActivatedRouteSnapshot);
66     store = injector.get(NgRedux)
67
68   })().then(done).catch(done.fail));
69
70
71   test("should call get all parameter's from url", () => {
72       expect(activatedRouteSnapshot.queryParamMap.get("serviceModelId")).toBe('serviceModelId');
73       expect(activatedRouteSnapshot.queryParamMap.get("subscriberId")).toBe('subscriberId');
74       expect(activatedRouteSnapshot.queryParamMap.get("serviceType")).toBe('serviceType');
75       expect(activatedRouteSnapshot.queryParamMap.get("serviceInstanceId")).toBe('serviceInstanceId');
76       expect(activatedRouteSnapshot.queryParamMap.get("jobId")).toBe('jobId');
77   });
78
79
80   test("should return retry topology", () => {
81       jest.spyOn(aaiService, 'getServiceModelById').mockReturnValue(of({}));
82       jest.spyOn(aaiService, 'retrieveAndStoreServiceInstanceTopology').mockReturnValue(of({
83         "vnfs": {
84           "2017-388_ADIOD-vPE 0": {
85             "vfModules": {},
86             "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168",
87             "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
88             "lcpCloudRegionId": "JANET25",
89             "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
90             "lineOfBusiness": "ONAP",
91             "platformName": "platform",
92             "modelInfo": {
93               "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
94               "modelVersionId": "afacccf6-397d-45d6-b5ae-94c39734b168",
95               "modelName": "2017-388_ADIOD-vPE",
96               "modelVersion": "4.0",
97               "modelCustomizationId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c",
98               "modelCustomizationName": "2017-388_ADIOD-vPE 0",
99               "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168"
100             },
101             "instanceName": "2017388_ADIODvPEmCaNkinstanceName",
102             "legacyRegion": "some legacy region"
103           },
104           "2017-488_ADIOD-vPE 0": {
105             "vfModules": {
106               "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": {
107                 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0uvfot": {
108                   "instanceName": "VFinstancenameZERO",
109                   "modelInfo": {
110                     "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091",
111                     "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db",
112                     "modelName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
113                     "modelVersion": "5",
114                     "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3",
115                     "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
116                     "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db"
117                   },
118                   "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db",
119                   "provStatus": "Prov Status",
120                   "orchStatus": "Active",
121                   "inMaint": true
122                 }
123               },
124               "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": {
125                 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1fshmc": {
126                   "instanceName": "VFinstancename",
127                   "volumeGroupName": "VFinstancename_vol_abc",
128                   "orchStatus": "Create",
129                   "provStatus": "Prov Status",
130                   "inMaint": false,
131                   "modelInfo": {
132                     "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
133                     "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5",
134                     "modelName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
135                     "modelVersion": "6",
136                     "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401",
137                     "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
138                     "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
139                   },
140                   "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
141                 }
142               }
143             },
144             "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
145             "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
146             "lcpCloudRegionId": "JANET25",
147             "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
148             "lineOfBusiness": "ONAP",
149             "platformName": "platform",
150             "modelInfo": {
151               "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
152               "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
153               "modelName": "2017-488_ADIOD-vPE",
154               "modelVersion": "5.0",
155               "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45",
156               "modelCustomizationName": "2017-488_ADIOD-vPE 0",
157               "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09"
158             },
159             "orchStatus": "Created",
160             "inMaint": false,
161             "instanceName": "2017488_ADIODvPEVNFinstancename",
162             "legacyRegion": "some legacy region"
163           },
164           "2017-488_ADIOD-vPE 0:0001": {
165             "vfModules": {
166               "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": {
167                 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0uvfot": {
168                   "instanceName": "VFinstancenameZERO_001",
169                   "provStatus": "Prov Status",
170                   "inMaint": true,
171                   "modelInfo": {
172                     "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091",
173                     "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db",
174                     "modelName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
175                     "modelVersion": "5",
176                     "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3",
177                     "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
178                     "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db"
179                   },
180                   "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db"
181                 }
182               },
183               "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": {
184                 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1fshmc": {
185                   "instanceName": "VFinstancename_001",
186                   "volumeGroupName": "VFinstancename_vol_abc_001",
187                   "modelInfo": {
188                     "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
189                     "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5",
190                     "modelName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
191                     "modelVersion": "6",
192                     "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401",
193                     "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
194                     "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
195                   },
196                   "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
197                 }
198               }
199             },
200
201             "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
202             "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
203             "lcpCloudRegionId": "JANET25",
204             "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
205             "lineOfBusiness": "ONAP",
206             "platformName": "platform",
207             "modelInfo": {
208               "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
209               "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
210               "modelName": "2017-488_ADIOD-vPE",
211               "modelVersion": "5.0",
212               "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45",
213               "modelCustomizationName": "2017-488_ADIOD-vPE 0",
214               "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09"
215             },
216             "instanceName": "2017488_ADIODvPEVNFinstancename_001",
217             "legacyRegion": "some legacy region"
218           },
219           "2017-488_ADIOD-vPE 0:0002": {
220             "vfModules": {
221               "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": {
222                 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0uvfot": {
223                   "instanceName": "VFinstancenameZERO_002",
224                   "modelInfo": {
225                     "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091",
226                     "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db",
227                     "modelName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
228                     "modelVersion": "5",
229                     "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3",
230                     "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
231                     "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db"
232                   },
233                   "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db"
234                 }
235               },
236               "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": {
237                 "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1fshmc": {
238                   "instanceName": "VFinstancename_002",
239                   "volumeGroupName": "VFinstancename_vol_abc_002",
240                   "modelInfo": {
241                     "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
242                     "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5",
243                     "modelName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
244                     "modelVersion": "6",
245                     "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401",
246                     "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1",
247                     "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
248                   },
249                   "uuid": "25284168-24bb-4698-8cb4-3f509146eca5"
250                 }
251               }
252             },
253             "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
254             "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
255             "lcpCloudRegionId": "JANET25",
256             "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
257             "lineOfBusiness": "ONAP",
258             "platformName": "platform",
259             "modelInfo": {
260               "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
261               "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
262               "modelName": "2017-488_ADIOD-vPE",
263               "modelVersion": "5.0",
264               "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45",
265               "modelCustomizationName": "2017-488_ADIOD-vPE 0",
266               "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09"
267             },
268             "instanceName": "2017488_ADIODvPEVNFinstancename_002",
269             "legacyRegion": "some legacy region"
270           }
271         },
272         "vnfGroups": {},
273         "existingVnfGroupCounterMap": {},
274         "validationCounter": 0,
275         "existingVNFCounterMap": {
276           "afacccf6-397d-45d6-b5ae-94c39734b168": 1,
277           "69e09f68-8b63-4cc9-b9ff-860960b5db09": 3
278         },
279         "existingNetworksCounterMap": {},
280         "instanceName": "mCaNkinstancename",
281         "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89",
282         "subscriptionServiceType": "TYLER SILVIA",
283         "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
284         "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
285         "lcpCloudRegionId": "hvf6",
286         "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
287         "aicZoneId": "NFT1",
288         "projectName": "WATKINS",
289         "rollbackOnFailure": "true",
290         "aicZoneName": "NFTJSSSS-NFT1",
291         "owningEntityName": "WayneHolland",
292         "tenantName": "AIN Web Tool-15-D-testalexandria",
293         "modelInfo": {
294           "modelInvariantId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
295           "modelVersionId": "6b528779-44a3-4472-bdff-9cd15ec93450",
296           "modelName": "action-data",
297           "modelVersion": "1.0",
298           "uuid": "6b528779-44a3-4472-bdff-9cd15ec93450"
299         },
300         "isALaCarte": false,
301         "orchStatus": "Active",
302         "modelInavariantId": "6b528779-44a3-4472-bdff-9cd15ec93450"
303       }));
304   });
305
306 });