diff options
Diffstat (limited to 'vid-webpack-master/src/app/drawingBoard')
2 files changed, 125 insertions, 10 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts index b62794ff8..a14e3f8c9 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts @@ -413,7 +413,33 @@ describe('VFModule Model Info', () => { 'modelInfo' : { modelVersionId : 'vfModuleId' } + }, + 'vnfModuleName_111_1': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + } + } + } + }, + 'vnfName_1' :{ + 'action': 'Create', + 'originalName' : 'vnfName', + 'vfModules' : { + 'vfModuleName' : { + 'vnfModuleName_111': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + }, + 'vnfModuleName_111_1': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' } + } } } } @@ -438,6 +464,95 @@ describe('VFModule Model Info', () => { } }; let result = vfModuleModel.getNodeCount(<any>node , serviceId); + expect(result).toEqual(2); + }); + + + test('getNodeCount should return number of nodes : there is selectedVNF', ()=>{ + let serviceId : string = 'servicedId'; + jest.spyOn(MockNgRedux.getInstance(), 'getState').mockReturnValue({ + global : {}, + service : { + serviceHierarchy : { + 'servicedId' : { + 'vnfs' : { + 'vnfName' : { + 'properties' : { + 'max_instances' : 1 + } + } + }, + 'vfModules' : { + 'vfModuleName' : { + 'properties' : { + maxCountInstances : 2 + } + } + } + } + }, + serviceInstance : { + 'servicedId' : { + 'existingVNFCounterMap' : { + 'vnfId' : 1 + }, + 'vnfs' : { + 'vnfName' :{ + 'action': 'Create', + 'originalName' : 'vnfName', + 'vfModules' : { + 'vfModuleName' : { + 'vnfModuleName_111': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + }, + 'vnfModuleName_111_1': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + } + } + } + }, + 'vnfName_1' :{ + 'action': 'Create', + 'originalName' : 'vnfName', + 'vfModules' : { + 'vfModuleName' : { + 'vnfModuleName_111': { + 'action': 'Create', + 'modelInfo' : { + modelVersionId : 'vfModuleId' + } + } + } + } + } + } + } + } + } + }); + jest.spyOn(_sharedTreeService, 'getSelectedVNF').mockReturnValue('vnfName_1'); + + let node = { + data : { + id : 'vfModuleId', + name : 'vfModuleName', + 'action': 'Create', + }, + parent : { + data : { + id : 'vnfId', + name : 'vnfName_1', + 'action': 'Create', + } + } + }; + let result = vfModuleModel.getNodeCount(<any>node , serviceId); expect(result).toEqual(1); }); diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts index bb56b14d0..3d3797353 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts @@ -177,12 +177,16 @@ export class VFModuleModelInfo implements ILevelNodeInfo { * @param serviceModelId - current service id ************************************************************/ getNodeCount(node: ITreeNode, serviceModelId: string): number { + const vnfs = this._store.getState().service.serviceInstance[serviceModelId].vnfs; let count: number = 0; if (!_.isNil(this._store.getState().service.serviceInstance) && !_.isNil(this._store.getState().service.serviceInstance[serviceModelId])) { - const vnfs = this._store.getState().service.serviceInstance[serviceModelId].vnfs; - - for (let vnfKey in vnfs) { - count += this.countNumberOfVFModule(vnfs[vnfKey], node); + const selectedVNF: string = this._sharedTreeService.getSelectedVNF(); + if (selectedVNF) { + count += this.countNumberOfVFModule(vnfs[selectedVNF], node); + }else { + for (let vnfKey in vnfs) { + count += this.countNumberOfVFModule(vnfs[vnfKey], node); + } } return count; } @@ -206,11 +210,8 @@ export class VFModuleModelInfo implements ILevelNodeInfo { getCountVFModuleOfSelectedVNF(node: ITreeNode, vnfStoreKey: string, serviceModelId: string): number { let count: number = 0; if (!_.isNil(this._store.getState().service.serviceInstance) && !_.isNil(this._store.getState().service.serviceInstance[serviceModelId])) { - const vnfs = this._store.getState().service.serviceInstance[serviceModelId].vnfs; - - for (let vnfKey in vnfs) { - count += this.countNumberOfVFModule(vnfs[vnfKey], node); - } + const vnf = this._store.getState().service.serviceInstance[serviceModelId].vnfs[vnfStoreKey]; + count += this.countNumberOfVFModule(vnf, node); return count; } return count; @@ -238,7 +239,6 @@ export class VFModuleModelInfo implements ILevelNodeInfo { showVFModuleOnSelectedVNF(node: ITreeNode, selectedVNF: string, serviceModelId: string): AvailableNodeIcons { - if (!_.isNil(this._store.getState().service.serviceInstance[serviceModelId].vnfs[selectedVNF]) && node.parent.data.name === this._store.getState().service.serviceInstance[serviceModelId].vnfs[selectedVNF].originalName) { const existingVFModules = this.getCountVFModuleOfSelectedVNF(node, selectedVNF, serviceModelId); const reachedLimit = this.isVFModuleReachedLimit(node, this._store.getState().service.serviceHierarchy, serviceModelId, existingVFModules); |