summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/services/aaiService
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/shared/services/aaiService')
-rw-r--r--vid-webpack-master/src/app/shared/services/aaiService/aai.service.spec.ts37
-rw-r--r--vid-webpack-master/src/app/shared/services/aaiService/aai.service.ts10
2 files changed, 42 insertions, 5 deletions
diff --git a/vid-webpack-master/src/app/shared/services/aaiService/aai.service.spec.ts b/vid-webpack-master/src/app/shared/services/aaiService/aai.service.spec.ts
index f563cbc75..ad934cf79 100644
--- a/vid-webpack-master/src/app/shared/services/aaiService/aai.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/services/aaiService/aai.service.spec.ts
@@ -22,7 +22,7 @@ describe("AaiService", () => {
let httpMock: HttpTestingController;
let aaiService: AaiService;
let mockFeatureFlagsService: FeatureFlagsService = mock(FeatureFlagsService);
- let store : NgRedux<AppState>;
+ let store: NgRedux<AppState>;
beforeAll(done => (async () => {
TestBed.configureTestingModule({
@@ -42,8 +42,6 @@ describe("AaiService", () => {
})().then(done).catch(done.fail));
-
-
describe('#resolve tests', () => {
test('aai service resolve should return the right object', () => {
let serviceInstance = new ServiceInstance();
@@ -173,8 +171,37 @@ describe("AaiService", () => {
});
});
+ describe('#Pnf modelCustomizationName initialization tests', () => {
+
+ test('initializePnfModelCustomizationName should not reinitialize modelCustomizationName when it exists', () => {
+ let serviceHierarchy = {
+ "pnfs": {
+ "pnfInstance": {
+ "modelCustomizationName": "existingName"
+ }
+ }
+ }
+
+ aaiService.initializePnfModelCustomizationName(serviceHierarchy);
+
+ expect(serviceHierarchy.pnfs["pnfInstance"].modelCustomizationName).toBe("existingName");
+ });
+
+ test('initializePnfModelCustomizationName should initialize modelCustomizationName when it doesnt exist', () => {
+ let serviceHierarchy = {
+ "pnfs": {
+ "pnfInstance": {}
+ }
+ }
+
+ aaiService.initializePnfModelCustomizationName(serviceHierarchy);
+
+ expect((serviceHierarchy.pnfs["pnfInstance"] as any).modelCustomizationName).toBe("pnfInstance");
+ });
+ });
+
function getTopology() {
- return {
+ return {
"vnfs": {
"2017-388_PASQUALE-vPE 0": {
"vfModules": {},
@@ -398,7 +425,7 @@ describe("AaiService", () => {
}
}
- function getMockActiveNetworks(){
+ function getMockActiveNetworks() {
return [
{
networkInstanceName: "networkInstanceName",
diff --git a/vid-webpack-master/src/app/shared/services/aaiService/aai.service.ts b/vid-webpack-master/src/app/shared/services/aaiService/aai.service.ts
index adb7017be..2829a8981 100644
--- a/vid-webpack-master/src/app/shared/services/aaiService/aai.service.ts
+++ b/vid-webpack-master/src/app/shared/services/aaiService/aai.service.ts
@@ -58,6 +58,7 @@ export class AaiService {
getServiceModelById = (serviceModelId: string): Observable<any> => {
if (_.has(this.store.getState().service.serviceHierarchy, serviceModelId)) {
+ this.initializePnfModelCustomizationName(this.store.getState().service.serviceHierarchy[serviceModelId]);
return of(<any> JSON.parse(JSON.stringify(this.store.getState().service.serviceHierarchy[serviceModelId])));
}
let pathQuery: string = Constants.Path.SERVICES_PATH + serviceModelId;
@@ -321,6 +322,15 @@ export class AaiService {
return result;
}
+ initializePnfModelCustomizationName(serviceHierarchy) : void {
+ let pnfs = serviceHierarchy.pnfs;
+ for (let pnf in pnfs) {
+ if (!pnfs[pnf].modelCustomizationName){
+ pnfs[pnf].modelCustomizationName = pnf;
+ }
+ }
+ }
+
loadMockMembers(): any {
return [
{