summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/drawingBoard
diff options
context:
space:
mode:
authorYoav Schneiderman <yoav.schneiderman@intl.att.com>2019-12-17 22:13:48 +0200
committerEylon Malin <eylon.malin@intl.att.com>2019-12-17 21:07:03 +0000
commit72a9733f9ecc0171841bc10f03e662d693bec77c (patch)
tree6e7267c8c475f3f87f3f347e707f865c2a7702c7 /vid-webpack-master/src/app/drawingBoard
parent4bfa2df6e5735b0060a88e4661f38b955094d1a1 (diff)
Fixing node count icon VfModule + unit tests.
Issue-ID: VID-726 Signed-off-by: Yoav Schneiderman <yoav.schneiderman@intl.att.com> Change-Id: I07538d9e77ff3e983da35f90f73eb62c9fdfce4b
Diffstat (limited to 'vid-webpack-master/src/app/drawingBoard')
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts115
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts20
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);