diff options
author | Ittay Stern <ittay.stern@att.com> | 2018-08-29 17:01:32 +0300 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-02-18 18:35:30 +0200 |
commit | 6f900cc45d7dd7f97430812b86b5c1d1693c8ae3 (patch) | |
tree | 936005c364dc5a7264d6304d4777c3d83494db22 /vid-webpack-master/src/app/shared/resolvers | |
parent | 67d99f816cc583643c35193197594cf78d8ce60a (diff) |
merge from ecomp a88f0072 - Modern UI
Issue-ID: VID-378
Change-Id: Ibcb23dd27f550cf32ce2fe0239f0f496ae014ff6
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/resolvers')
6 files changed, 530 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.spec.ts b/vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.spec.ts new file mode 100644 index 000000000..930562ce0 --- /dev/null +++ b/vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.spec.ts @@ -0,0 +1,61 @@ +import {TestBed, getTestBed} from '@angular/core/testing'; +import { + HttpClientTestingModule, + HttpTestingController +} from '@angular/common/http/testing'; +import {NgRedux} from "@angular-redux/store"; +import {FeatureFlagsService} from "../../services/featureFlag/feature-flags.service"; +import {ActivatedRouteSnapshot, convertToParamMap} from "@angular/router"; +import {FlagsResolve} from "./flag.resolver"; +import {ConfigurationService} from "../../services/configuration.service"; + +class MockAppStore<T> { + getState() { + return { + service: { + serviceInstance: {} + } + } + } +} + + +describe('Flag resolver', () => { + let injector; + let resolver: FlagsResolve; + let configurationService: ConfigurationService; + let httpMock: HttpTestingController; + + let activatedRouteSnapshot: ActivatedRouteSnapshot; + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [ + FlagsResolve, + ConfigurationService, + FeatureFlagsService, + {provide: NgRedux, useClass: MockAppStore}, + { + provide: ActivatedRouteSnapshot, useValue: { + queryParamMap: + convertToParamMap({ }) + } + }, + ] + }); + await TestBed.compileComponents(); + + injector = getTestBed(); + resolver = injector.get(FlagsResolve); + httpMock = injector.get(HttpTestingController); + activatedRouteSnapshot = injector.get(ActivatedRouteSnapshot); + configurationService = injector.get(ConfigurationService); + + })().then(done).catch(done.fail)); + + test('should update flags', () => { + spyOn(configurationService, 'getFlags'); + resolver.resolve(activatedRouteSnapshot); + expect(configurationService.getFlags).toHaveBeenCalled(); + }); +}); diff --git a/vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.ts b/vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.ts new file mode 100644 index 000000000..7ebce8bde --- /dev/null +++ b/vid-webpack-master/src/app/shared/resolvers/flag/flag.resolver.ts @@ -0,0 +1,14 @@ +import {ActivatedRouteSnapshot, Resolve} from "@angular/router"; +import {Injectable} from "@angular/core"; +import {Observable} from "rxjs"; +import {ConfigurationService} from "../../services/configuration.service"; + +@Injectable() +export class FlagsResolve implements Resolve<Observable< { [key: string]: boolean }>> { + + constructor(private _configurationService: ConfigurationService) {} + + resolve(route: ActivatedRouteSnapshot) { + return this._configurationService.getFlags(); + } +} diff --git a/vid-webpack-master/src/app/shared/resolvers/retry/retry.resolver.spec.ts b/vid-webpack-master/src/app/shared/resolvers/retry/retry.resolver.spec.ts new file mode 100644 index 000000000..2578d7b2d --- /dev/null +++ b/vid-webpack-master/src/app/shared/resolvers/retry/retry.resolver.spec.ts @@ -0,0 +1,306 @@ +import {getTestBed, TestBed} from '@angular/core/testing'; +import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; +import {NgRedux} from "@angular-redux/store"; +import {ActivatedRouteSnapshot, convertToParamMap} from "@angular/router"; +import {AppState} from "../../store/reducers"; +import {RetryResolver} from "./retry.resolver"; +import {AaiService} from "../../services/aaiService/aai.service"; +import {FeatureFlagsService} from "../../services/featureFlag/feature-flags.service"; +import {Observable, of} from "rxjs"; + +class MockAppStore<T> { + getState() { + return { + global:{ + drawingBoardStatus: "VIEW" + }, + service: { + serviceInstance: {} + } + } + } + dispatch(){ + + } +} + + +describe('View Edit resolver', () => { + let injector; + let aaiService: AaiService; + let resolver: RetryResolver; + let httpMock: HttpTestingController; + let store : NgRedux<AppState>; + let activatedRouteSnapshot: ActivatedRouteSnapshot; + + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [ + FeatureFlagsService, + RetryResolver, + AaiService, + {provide: NgRedux, useClass: MockAppStore}, + { + provide: ActivatedRouteSnapshot, useValue: { + queryParamMap: + convertToParamMap({ + serviceModelId: 'serviceModelId', + subscriberId: 'subscriberId', + serviceType: 'serviceType', + serviceInstanceId : 'serviceInstanceId', + jobId : 'jobId' + }) + }, + + } + ] + }); + await TestBed.compileComponents(); + + injector = getTestBed(); + aaiService = injector.get(AaiService); + resolver = injector.get(RetryResolver); + httpMock = injector.get(HttpTestingController); + activatedRouteSnapshot = injector.get(ActivatedRouteSnapshot); + store = injector.get(NgRedux) + + })().then(done).catch(done.fail)); + + + test("should call get all parameter's from url", () => { + expect(activatedRouteSnapshot.queryParamMap.get("serviceModelId")).toBe('serviceModelId'); + expect(activatedRouteSnapshot.queryParamMap.get("subscriberId")).toBe('subscriberId'); + expect(activatedRouteSnapshot.queryParamMap.get("serviceType")).toBe('serviceType'); + expect(activatedRouteSnapshot.queryParamMap.get("serviceInstanceId")).toBe('serviceInstanceId'); + expect(activatedRouteSnapshot.queryParamMap.get("jobId")).toBe('jobId'); + }); + + + test("should return retry topology", () => { + jest.spyOn(aaiService, 'getServiceModelById').mockReturnValue(of({})); + jest.spyOn(aaiService, 'retrieveAndStoreServiceInstanceTopology').mockReturnValue(of({ + "vnfs": { + "2017-388_ADIOD-vPE 0": { + "vfModules": {}, + "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168", + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "lcpCloudRegionId": "JANET25", + "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", + "lineOfBusiness": "ONAP", + "platformName": "platform", + "modelInfo": { + "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "modelVersionId": "afacccf6-397d-45d6-b5ae-94c39734b168", + "modelName": "2017-388_ADIOD-vPE", + "modelVersion": "4.0", + "modelCustomizationId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c", + "modelCustomizationName": "2017-388_ADIOD-vPE 0", + "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168" + }, + "instanceName": "2017388_ADIODvPEmCaNkinstanceName", + "legacyRegion": "some legacy region" + }, + "2017-488_ADIOD-vPE 0": { + "vfModules": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0uvfot": { + "instanceName": "VFinstancenameZERO", + "modelInfo": { + "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091", + "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db", + "modelName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", + "modelVersion": "5", + "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3", + "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db" + }, + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db", + "provStatus": "Prov Status", + "orchStatus": "Active", + "inMaint": true + } + }, + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1fshmc": { + "instanceName": "VFinstancename", + "volumeGroupName": "VFinstancename_vol_abc", + "orchStatus": "Create", + "provStatus": "Prov Status", + "inMaint": false, + "modelInfo": { + "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1", + "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5", + "modelName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1", + "modelVersion": "6", + "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401", + "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1", + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + }, + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + } + } + }, + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "lcpCloudRegionId": "JANET25", + "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", + "lineOfBusiness": "ONAP", + "platformName": "platform", + "modelInfo": { + "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "5.0", + "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45", + "modelCustomizationName": "2017-488_ADIOD-vPE 0", + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09" + }, + "orchStatus": "Created", + "inMaint": false, + "instanceName": "2017488_ADIODvPEVNFinstancename", + "legacyRegion": "some legacy region" + }, + "2017-488_ADIOD-vPE 0:0001": { + "vfModules": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0uvfot": { + "instanceName": "VFinstancenameZERO_001", + "provStatus": "Prov Status", + "inMaint": true, + "modelInfo": { + "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091", + "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db", + "modelName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", + "modelVersion": "5", + "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3", + "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db" + }, + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db" + } + }, + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1fshmc": { + "instanceName": "VFinstancename_001", + "volumeGroupName": "VFinstancename_vol_abc_001", + "modelInfo": { + "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1", + "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5", + "modelName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1", + "modelVersion": "6", + "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401", + "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1", + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + }, + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + } + } + }, + + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "lcpCloudRegionId": "JANET25", + "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", + "lineOfBusiness": "ONAP", + "platformName": "platform", + "modelInfo": { + "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "5.0", + "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45", + "modelCustomizationName": "2017-488_ADIOD-vPE 0", + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09" + }, + "instanceName": "2017488_ADIODvPEVNFinstancename_001", + "legacyRegion": "some legacy region" + }, + "2017-488_ADIOD-vPE 0:0002": { + "vfModules": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0uvfot": { + "instanceName": "VFinstancenameZERO_002", + "modelInfo": { + "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091", + "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db", + "modelName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", + "modelVersion": "5", + "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3", + "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0", + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db" + }, + "uuid": "f8360508-3f17-4414-a2ed-6bc71161e8db" + } + }, + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1": { + "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_vRE_BV..module-1fshmc": { + "instanceName": "VFinstancename_002", + "volumeGroupName": "VFinstancename_vol_abc_002", + "modelInfo": { + "modelInvariantId": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1", + "modelVersionId": "25284168-24bb-4698-8cb4-3f509146eca5", + "modelName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1", + "modelVersion": "6", + "modelCustomizationId": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401", + "modelCustomizationName": "2017488AdiodVpe..ADIOD_vRE_BV..module-1", + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + }, + "uuid": "25284168-24bb-4698-8cb4-3f509146eca5" + } + } + }, + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "lcpCloudRegionId": "JANET25", + "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", + "lineOfBusiness": "ONAP", + "platformName": "platform", + "modelInfo": { + "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", + "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09", + "modelName": "2017-488_ADIOD-vPE", + "modelVersion": "5.0", + "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45", + "modelCustomizationName": "2017-488_ADIOD-vPE 0", + "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09" + }, + "instanceName": "2017488_ADIODvPEVNFinstancename_002", + "legacyRegion": "some legacy region" + } + }, + "vnfGroups": {}, + "existingVnfGroupCounterMap": {}, + "validationCounter": 0, + "existingVNFCounterMap": { + "afacccf6-397d-45d6-b5ae-94c39734b168": 1, + "69e09f68-8b63-4cc9-b9ff-860960b5db09": 3 + }, + "existingNetworksCounterMap": {}, + "instanceName": "mCaNkinstancename", + "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89", + "subscriptionServiceType": "TYLER SILVIA", + "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", + "productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89", + "lcpCloudRegionId": "hvf6", + "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054", + "aicZoneId": "NFT1", + "projectName": "WATKINS", + "rollbackOnFailure": "true", + "aicZoneName": "NFTJSSSS-NFT1", + "owningEntityName": "WayneHolland", + "tenantName": "AIN Web Tool-15-D-testalexandria", + "modelInfo": { + "modelInvariantId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0", + "modelVersionId": "6b528779-44a3-4472-bdff-9cd15ec93450", + "modelName": "action-data", + "modelVersion": "1.0", + "uuid": "6b528779-44a3-4472-bdff-9cd15ec93450" + }, + "isALaCarte": false, + "orchStatus": "Active", + "modelInavariantId": "6b528779-44a3-4472-bdff-9cd15ec93450" + })); + }); + +}); diff --git a/vid-webpack-master/src/app/shared/resolvers/retry/retry.resolver.ts b/vid-webpack-master/src/app/shared/resolvers/retry/retry.resolver.ts new file mode 100644 index 000000000..5e2250ad7 --- /dev/null +++ b/vid-webpack-master/src/app/shared/resolvers/retry/retry.resolver.ts @@ -0,0 +1,27 @@ +import {ActivatedRouteSnapshot, Resolve} from "@angular/router"; +import {Injectable} from "@angular/core"; +import {Observable} from "rxjs"; +import {AaiService} from "../../services/aaiService/aai.service"; +import {forkJoin} from "rxjs/observable/forkJoin"; +import {AppState} from "../../store/reducers"; +import {NgRedux} from "@angular-redux/store"; +import {createServiceInstance} from "../../storeUtil/utils/service/service.actions"; + +@Injectable() +export class RetryResolver implements Resolve<Observable<boolean>> { + + constructor(private _aaiService: AaiService, private _store: NgRedux<AppState>) {} + + resolve(route: ActivatedRouteSnapshot): Observable<boolean> { + const serviceModelId: string = route.queryParamMap.get("serviceModelId"); + const jobId: string = route.queryParamMap.get("jobId"); + + let serviceModelApi = this._aaiService.getServiceModelById(serviceModelId); + + let serviceInstanceApi = this._aaiService.retrieveAndStoreServiceInstanceRetryTopology(jobId, serviceModelId); + return forkJoin([serviceModelApi, serviceInstanceApi]).map(([serviceModel, serviceInstance ]) => { + this._store.dispatch(createServiceInstance( serviceInstance, serviceModelId)); + return true; + }); + } +} diff --git a/vid-webpack-master/src/app/shared/resolvers/viewEdit/viewEdit.resolver.spec.ts b/vid-webpack-master/src/app/shared/resolvers/viewEdit/viewEdit.resolver.spec.ts new file mode 100644 index 000000000..6e8fdc757 --- /dev/null +++ b/vid-webpack-master/src/app/shared/resolvers/viewEdit/viewEdit.resolver.spec.ts @@ -0,0 +1,82 @@ +import {getTestBed, TestBed} from '@angular/core/testing'; +import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; +import {NgRedux} from "@angular-redux/store"; +import {ViewEditResolver} from "./viewEdit.resolver"; +import {AaiService} from "../../services/aaiService/aai.service"; +import {FeatureFlagsService} from "../../services/featureFlag/feature-flags.service"; +import {ActivatedRouteSnapshot, convertToParamMap} from "@angular/router"; +import {AppState} from "../../store/reducers"; +import {UpdateDrawingBoardStatusAction} from "../../storeUtil/utils/global/global.actions"; + +class MockAppStore<T> { + getState() { + return { + global:{ + drawingBoardStatus: "VIEW" + }, + service: { + serviceInstance: {} + } + } + } + dispatch(){ + + } +} + + +describe('View Edit resolver', () => { + let injector; + let aaiService: AaiService; + let resolver: ViewEditResolver; + let httpMock: HttpTestingController; + let store : NgRedux<AppState>; + + let activatedRouteSnapshot: ActivatedRouteSnapshot; + let updateDrawingBoardStatusAction: UpdateDrawingBoardStatusAction; + + beforeAll(done => (async () => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [ + ViewEditResolver, + AaiService, + FeatureFlagsService, + {provide: NgRedux, useClass: MockAppStore}, + { + provide: ActivatedRouteSnapshot, useValue: { + queryParamMap: + convertToParamMap({ + serviceModelId: 'serviceModelId', + subscriberId: 'subscriberId', + serviceType: 'serviceType', + serviceInstanceId : 'serviceInstanceId' + }) + }, + + } + ] + }); + await TestBed.compileComponents(); + + injector = getTestBed(); + aaiService = injector.get(AaiService); + resolver = injector.get(ViewEditResolver); + httpMock = injector.get(HttpTestingController); + activatedRouteSnapshot = injector.get(ActivatedRouteSnapshot); + store = injector.get(NgRedux) + + })().then(done).catch(done.fail)); + + + test('should call both api', () => { + // spyOn(aaiService, 'getServiceModelById'); + // spyOn(aaiService, 'retrieveAndStoreServiceInstanceTopology'); + // spyOn(store, 'dispatch'); + // resolver.resolve(activatedRouteSnapshot); + // + // expect(aaiService.getServiceModelById).toHaveBeenCalledWith('serviceModelId'); + // expect(aaiService.retrieveAndStoreServiceInstanceTopology).toHaveBeenCalledWith('serviceInstanceId', 'subscriberId', 'serviceType', 'serviceModelId'); + }); + +}); diff --git a/vid-webpack-master/src/app/shared/resolvers/viewEdit/viewEdit.resolver.ts b/vid-webpack-master/src/app/shared/resolvers/viewEdit/viewEdit.resolver.ts new file mode 100644 index 000000000..d4aef1937 --- /dev/null +++ b/vid-webpack-master/src/app/shared/resolvers/viewEdit/viewEdit.resolver.ts @@ -0,0 +1,40 @@ +import {ActivatedRouteSnapshot, Resolve} from "@angular/router"; +import {Injectable} from "@angular/core"; +import {Observable} from "rxjs"; +import {AaiService} from "../../services/aaiService/aai.service"; +import {forkJoin} from "rxjs/observable/forkJoin"; +import {AppState} from "../../store/reducers"; +import {NgRedux} from "@angular-redux/store"; +import {createServiceInstance} from "../../storeUtil/utils/service/service.actions"; + +@Injectable() +export class ViewEditResolver implements Resolve<Observable<boolean>> { + + constructor(private _aaiService: AaiService, private _store: NgRedux<AppState>) { + } + + resolve(route: ActivatedRouteSnapshot): Observable<boolean> { + const serviceModeId: string = route.queryParamMap.get("serviceModelId"); + const serviceInstanceId: string = route.queryParamMap.get("serviceInstanceId"); + const subscriberId: string = route.queryParamMap.get("subscriberId"); + const serviceType: string = route.queryParamMap.get("serviceType"); + let serviceModelApi = this._aaiService.getServiceModelById(serviceModeId); + let serviceInstanceApi = this._aaiService.retrieveAndStoreServiceInstanceTopology(serviceInstanceId, subscriberId, serviceType, serviceModeId); + return forkJoin([serviceModelApi, serviceInstanceApi]).map(([serviceModel, serviceInstance ]) => { + this.setIsALaCarte(serviceInstance,serviceModel.service.instantiationType ); + this.setTestApi(serviceInstance); + this._store.dispatch(createServiceInstance( serviceInstance, serviceModeId)); + return true; + }); + } + + setTestApi = (service: any) => { + if (this._store.getState().global.flags['FLAG_ADD_MSO_TESTAPI_FIELD'] && service.isALaCarte) { + service.testApi = sessionStorage.getItem("msoRequestParametersTestApiValue"); + } + }; + setIsALaCarte = (service: any, instantiationType) => { + service.isALaCarte = instantiationType === 'A-La-Carte'; + }; + +} |