vfModule.model.info getModel use vfModule constructor 04/99704/4
authorEylon Malin <eylon.malin@intl.att.com>
Tue, 17 Dec 2019 10:07:32 +0000 (12:07 +0200)
committerEylon Malin <eylon.malin@intl.att.com>
Wed, 18 Dec 2019 05:59:38 +0000 (05:59 +0000)
Fix bug of show wrong value in Component Info for VfModule
with maxCountInstances

Issue-ID: VID-726
Change-Id: I909218c9c7bb4121bcbfdb9f4f436571f1e83ebe
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.spec.ts
vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts
vid-webpack-master/src/app/shared/models/vfModule.ts

index b62794f..54bc778 100644 (file)
@@ -19,6 +19,7 @@ import {FeatureFlagsService} from "../../../../../shared/services/featureFlag/fe
 import {VfModuleUpgradePopupService} from "../../../../../shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service";
 import {instance, mock, when} from "ts-mockito";
 import each from "jest-each";
+import {VfModule} from "../../../../../shared/models/vfModule";
 
 class MockAppStore<T> {
   getState() {
@@ -30,12 +31,6 @@ class MockAppStore<T> {
   }
 }
 
-class MockFeatureFlagsService extends  FeatureFlagsService{
-  getAllFlags(): { [p: string]: boolean } {
-    return {};
-  }
-}
-
 describe('VFModule Model Info', () => {
   let injector;
   let  _dynamicInputsService : DynamicInputsService;
@@ -133,8 +128,16 @@ describe('VFModule Model Info', () => {
   });
 
   test('getModel should return Module model', () => {
-    let model = vfModuleModel.getModel('2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1',{}, getServiceHierarchy());
+    let model = vfModuleModel.getModel('2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1',null, getServiceHierarchy());
     expect(model.uuid).toEqual('25284168-24bb-4698-8cb4-3f509146eca5');
+    expect(model.min).toBe(2);
+    expect(model.max).toBe(3);
+    expect(model.baseModule).toBeFalsy();
+    expect(model.inputs).toEqual(
+      {"vnf_config_template_version": {
+        "type": "string"
+      }});
+    expect(model.volumeGroupAllowed).toBeTruthy();
   });
 
   test('showNodeIcons should return false false if reachLimit of max', ()=>{
@@ -510,7 +513,7 @@ describe('VFModule Model Info', () => {
     expect(vfModuleModel.isVFModuleReachedLimit(node, serviceHierarchy, 'servicedId', currentNodeCount)).toEqual(expected);
   });
 
-  function getVFModule(){
+  function getVFModule(): Partial<VfModule>{
     return {
       "uuid":"522159d5-d6e0-4c2a-aa44-5a542a12a830",
       "invariantUuid":"98a7c88b-b577-476a-90e4-e25a5871e02b",
@@ -519,13 +522,10 @@ describe('VFModule Model Info', () => {
       "name":"VfVgeraldine..vflorence_vlc..module-1",
       "version":"2",
       "modelCustomizationName":"VfVgeraldine..vflorence_vlc..module-1",
-      "properties":{
-        "minCountInstances":0,
-        "maxCountInstances":null,
-        "initialCount":0,
-        "vfModuleLabel":"vflorence_vlc",
-        "baseModule":false
-      },
+      "min":0,
+      "max":null,
+      "initial":0,
+      "baseModule":false,
       "inputs":{},
       "volumeGroupAllowed":false
     };
@@ -1151,7 +1151,7 @@ describe('VFModule Model Info', () => {
           "type": "VF",
           "modelCustomizationName": "2017-488_PASQUALE-vPE 0",
           "vfModules": {
-            "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1": {
+            "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1":{
               "uuid": "25284168-24bb-4698-8cb4-3f509146eca5",
               "invariantUuid": "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1",
               "customizationUuid": "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401",
@@ -1160,82 +1160,15 @@ describe('VFModule Model Info', () => {
               "version": "6",
               "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
               "properties": {
-                "minCountInstances": 0,
-                "maxCountInstances": null,
+                "minCountInstances": 2,
+                "maxCountInstances": 3,
                 "initialCount": 0,
                 "vfModuleLabel": "PASQUALE_vRE_BV",
                 "baseModule": false
               },
               "inputs": {
                 "vnf_config_template_version": {
-                  "type": "string",
-                  "description": "VPE Software Version",
-                  "entry_schema": null,
-                  "inputProperties": {
-                    "sourceType": "HEAT",
-                    "vfModuleLabel": "PASQUALE_vRE_BV",
-                    "paramName": "vnf_config_template_version"
-                  },
-                  "fromInputName": "2017488_pasqualevpe0_vnf_config_template_version",
-                  "constraints": null,
-                  "required": true,
-                  "default": "17.2"
-                },
-                "bandwidth_units": {
-                  "type": "string",
-                  "description": "Units of bandwidth",
-                  "entry_schema": null,
-                  "inputProperties": {
-                    "sourceType": "HEAT",
-                    "vfModuleLabel": "PASQUALE_vRE_BV",
-                    "paramName": "bandwidth_units"
-                  },
-                  "fromInputName": "pasqualevpe0_bandwidth_units",
-                  "constraints": null,
-                  "required": true,
-                  "default": "Gbps"
-                },
-                "bandwidth": {
-                  "type": "string",
-                  "description": "Requested VPE bandwidth",
-                  "entry_schema": null,
-                  "inputProperties": {
-                    "sourceType": "HEAT",
-                    "vfModuleLabel": "PASQUALE_vRE_BV",
-                    "paramName": "bandwidth"
-                  },
-                  "fromInputName": "pasqualevpe0_bandwidth",
-                  "constraints": null,
-                  "required": true,
-                  "default": "10"
-                },
-                "AIC_CLLI": {
-                  "type": "string",
-                  "description": "AIC Site CLLI",
-                  "entry_schema": null,
-                  "inputProperties": {
-                    "sourceType": "HEAT",
-                    "vfModuleLabel": "PASQUALE_vRE_BV",
-                    "paramName": "AIC_CLLI"
-                  },
-                  "fromInputName": "2017488_pasqualevpe0_AIC_CLLI",
-                  "constraints": null,
-                  "required": true,
-                  "default": "ATLMY8GA"
-                },
-                "vnf_instance_name": {
-                  "type": "string",
-                  "description": "The hostname assigned to the vpe.",
-                  "entry_schema": null,
-                  "inputProperties": {
-                    "sourceType": "HEAT",
-                    "vfModuleLabel": "PASQUALE_vRE_BV",
-                    "paramName": "vnf_instance_name"
-                  },
-                  "fromInputName": "2017488_pasqualevpe0_vnf_instance_name",
-                  "constraints": null,
-                  "required": true,
-                  "default": "mtnj309me6"
+                  "type": "string"
                 }
               },
               "volumeGroupAllowed": true
@@ -1402,82 +1335,15 @@ describe('VFModule Model Info', () => {
           "version": "6",
           "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1",
           "properties": {
-            "minCountInstances": 0,
-            "maxCountInstances": null,
+            "minCountInstances": 2,
+            "maxCountInstances": 3,
             "initialCount": 0,
             "vfModuleLabel": "PASQUALE_vRE_BV",
             "baseModule": false
           },
           "inputs": {
             "vnf_config_template_version": {
-              "type": "string",
-              "description": "VPE Software Version",
-              "entry_schema": null,
-              "inputProperties": {
-                "sourceType": "HEAT",
-                "vfModuleLabel": "PASQUALE_vRE_BV",
-                "paramName": "vnf_config_template_version"
-              },
-              "fromInputName": "2017488_pasqualevpe0_vnf_config_template_version",
-              "constraints": null,
-              "required": true,
-              "default": "17.2"
-            },
-            "bandwidth_units": {
-              "type": "string",
-              "description": "Units of bandwidth",
-              "entry_schema": null,
-              "inputProperties": {
-                "sourceType": "HEAT",
-                "vfModuleLabel": "PASQUALE_vRE_BV",
-                "paramName": "bandwidth_units"
-              },
-              "fromInputName": "pasqualevpe0_bandwidth_units",
-              "constraints": null,
-              "required": true,
-              "default": "Gbps"
-            },
-            "bandwidth": {
-              "type": "string",
-              "description": "Requested VPE bandwidth",
-              "entry_schema": null,
-              "inputProperties": {
-                "sourceType": "HEAT",
-                "vfModuleLabel": "PASQUALE_vRE_BV",
-                "paramName": "bandwidth"
-              },
-              "fromInputName": "pasqualevpe0_bandwidth",
-              "constraints": null,
-              "required": true,
-              "default": "10"
-            },
-            "AIC_CLLI": {
-              "type": "string",
-              "description": "AIC Site CLLI",
-              "entry_schema": null,
-              "inputProperties": {
-                "sourceType": "HEAT",
-                "vfModuleLabel": "PASQUALE_vRE_BV",
-                "paramName": "AIC_CLLI"
-              },
-              "fromInputName": "2017488_pasqualevpe0_AIC_CLLI",
-              "constraints": null,
-              "required": true,
-              "default": "ATLMY8GA"
-            },
-            "vnf_instance_name": {
-              "type": "string",
-              "description": "The hostname assigned to the vpe.",
-              "entry_schema": null,
-              "inputProperties": {
-                "sourceType": "HEAT",
-                "vfModuleLabel": "PASQUALE_vRE_BV",
-                "paramName": "vnf_instance_name"
-              },
-              "fromInputName": "2017488_pasqualevpe0_vnf_instance_name",
-              "constraints": null,
-              "required": true,
-              "default": "mtnj309me6"
+              "type": "string"
             }
           },
           "volumeGroupAllowed": true
index bb56b14..a82cd49 100644 (file)
@@ -67,10 +67,10 @@ export class VFModuleModelInfo implements ILevelNodeInfo {
    * @param instance
    * @param serviceHierarchy - serviceHierarchy
    ************************************************************/
-  getModel = (vfModuleModelId: string, instance, serviceHierarchy): any => {
+  getModel = (vfModuleModelId: string, instance, serviceHierarchy): Partial<VfModule> => {
     if (!_.isNil(serviceHierarchy)) {
       if (!_.isNil(serviceHierarchy[this.name]) && !_.isNil(serviceHierarchy[this.name][vfModuleModelId])) {
-        return serviceHierarchy[this.name][vfModuleModelId];
+        return new VfModule(serviceHierarchy[this.name][vfModuleModelId], this._featureFlagsService.getAllFlags());
       }
     }
     return {};
@@ -414,12 +414,12 @@ export class VFModuleModelInfo implements ILevelNodeInfo {
     return (!_.isNil(instance) && !_.isNil(instance[deepDynamicName])) ? instance[deepDynamicName].position : null;
   }
 
-  getInfo(model, instance): ModelInformationItem[] {
-    const modelInformation = !_.isEmpty(model) && !_.isEmpty(model.properties) ? [
-      ModelInformationItem.createInstance("Base module", model.properties.baseModule),
-      ModelInformationItem.createInstance("Min instances", !_.isNull(model.properties.minCountInstances) ? String(model.properties.minCountInstances) : null),
+  getInfo(model:Partial<VfModule>, instance): ModelInformationItem[] {
+    const modelInformation = !_.isEmpty(model) ? [
+      ModelInformationItem.createInstance("Base module", model.baseModule),
+      ModelInformationItem.createInstance("Min instances", !_.isNull(model.min) ? String(model.min) : null),
       this._sharedTreeService.createMaximumToInstantiateModelInformationItem(model),
-      ModelInformationItem.createInstance("Initial instances count", !_.isNull(model.properties.initialCount) ? String(model.properties.initialCount) : null)
+      ModelInformationItem.createInstance("Initial instances count", !_.isNull(model.initial) ? String(model.initial) : null)
     ] : [];
 
     const instanceInfo = [];
index dd73060..a942a0d 100644 (file)
@@ -6,13 +6,15 @@ export interface Properties{
   initialCount: number;
   maxCountInstances: number;
   minCountInstances: number;
+  baseModule: boolean;
 }
 
 export interface VFModuleResponseInterface extends NodeModelResponseInterface {
   customizationUuid: string;
   modelCustomizationName: string;
   volumeGroupAllowed : boolean;
-  properties: Properties
+  properties: Properties;
+  inputs: any;
 }
 
 export class VfModule extends NodeModel {
@@ -22,6 +24,8 @@ export class VfModule extends NodeModel {
   customizationUuid: string;
   modelCustomizationName: string;
   volumeGroupAllowed : boolean;
+  baseModule : boolean;
+  inputs: any;
 
   constructor(vf?: VFModuleResponseInterface, flags?: { [key: string]: boolean }) {
     super(vf);
@@ -29,12 +33,14 @@ export class VfModule extends NodeModel {
       this.customizationUuid = vf.customizationUuid;
       this.modelCustomizationName = vf.modelCustomizationName;
       this.volumeGroupAllowed = vf.volumeGroupAllowed || false;
+      this.inputs = vf.inputs;
     }
     if (vf && vf.properties) {
       this.min = vf.properties.minCountInstances;
       this.max = Utils.getMaxVfModule(vf.properties, flags);
       this.initial = vf.properties.initialCount;
-      this.rollbackOnFailure = true
+      this.rollbackOnFailure = true;
+      this.baseModule = vf.properties.baseModule;
     }
   }
 }