VID - Feature flag for PNF in modern UI
[vid.git] / vid-webpack-master / src / app / drawingBoard / service-planning / objectsToTree / shared.tree.service.spec.ts
index 89e20a2..9a35d48 100644 (file)
@@ -8,11 +8,11 @@ import {DefaultDataGeneratorService} from "../../../shared/services/defaultDataS
 import {DynamicInputsService} from "./dynamicInputs.service";
 import {DialogService} from "ng2-bootstrap-modal";
 import {VnfPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service";
-import {BasicControlGenerator} from "../../../shared/components/genericForm/formControlsServices/basic.control.generator";
+import {ControlGeneratorUtil} from "../../../shared/components/genericForm/formControlsServices/control.generator.util.service";
 import {AaiService} from "../../../shared/services/aaiService/aai.service";
 import {NetworkPopupService} from "../../../shared/components/genericFormPopup/genericFormServices/network/network.popup.service";
 import {NetworkControlGenerator} from "../../../shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator";
-import {VfModulePopuopService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service";
+import {VfModulePopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popup.service";
 import {VfModuleControlGenerator} from "../../../shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator";
 import {VnfGroupControlGenerator} from "../../../shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator";
 import {FeatureFlagsService} from "../../../shared/services/featureFlag/feature-flags.service";
@@ -40,6 +40,11 @@ import {ComponentInfoModel, ComponentInfoType} from "../component-info/component
 import {ModelInformationItem} from "../../../shared/components/model-information/model-information.component";
 import {VpnStepService} from "./models/vrf/vrfModal/vpnStep/vpn.step.service";
 import {NetworkStepService} from "./models/vrf/vrfModal/networkStep/network.step.service";
+import {VfModuleUpgradePopupService} from "../../../shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service";
+import {SharedControllersService} from "../../../shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service";
+import {ModalService} from "../../../shared/components/customModal/services/modal.service";
+import {CreateDynamicComponentService} from "../../../shared/components/customModal/services/create-dynamic-component.service";
+import { PnfPopupService } from "../../../shared/components/genericFormPopup/genericFormServices/pnf/pnf.popup.service";
 
 class MockAppStore<T> {
   getState() {
@@ -59,7 +64,7 @@ function getNodeWithData(menuAction:string){
   };
   nodeData['menuActions'][menuAction] =  {
     method: (node, serviceModelId) => {}
-  }
+  };
   const node = {
     parent: {
       data: nodeData,
@@ -76,16 +81,19 @@ describe('Shared Tree Service', () => {
   let service: SharedTreeService;
   let _objectToInstanceTreeService: ObjectToInstanceTreeService;
   let store: NgRedux<AppState>;
+
   beforeAll(done => (async () => {
     TestBed.configureTestingModule({
       imports: [HttpClientTestingModule, NgReduxTestingModule, SdcUiComponentsModule],
       providers: [
         SharedTreeService,
+        SharedControllersService,
         ObjectToTreeService,
         DefaultDataGeneratorService,
         DialogService,
         VnfPopupService,
-        BasicControlGenerator,
+        PnfPopupService,
+        ControlGeneratorUtil,
         AaiService,
         LogService,
         BasicPopupService,
@@ -95,7 +103,8 @@ describe('Shared Tree Service', () => {
         DynamicInputsService,
         NetworkPopupService,
         NetworkControlGenerator,
-        VfModulePopuopService,
+        VfModulePopupService,
+        VfModuleUpgradePopupService,
         VfModuleControlGenerator,
         VnfGroupControlGenerator,
         DialogService,
@@ -110,6 +119,8 @@ describe('Shared Tree Service', () => {
         ComponentInfoService,
         NetworkStepService,
         VpnStepService,
+        ModalService,
+        CreateDynamicComponentService,
         {provide: NgRedux, useClass: MockAppStore}
       ]
     });
@@ -126,7 +137,7 @@ describe('Shared Tree Service', () => {
 
   test('SharedTreeService upgradeBottomUp should call redux actions', () => {
     const serviceModelId = "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd";
-    const node = getNodeWithData("upgrade")
+    const node = getNodeWithData("upgrade");
     spyOn(node.parent.data.menuActions['upgrade'], 'method');
     service.upgradeBottomUp(node, serviceModelId);
     expect(node.parent.data.menuActions['upgrade'].method).toBeCalledWith(node.parent, serviceModelId);
@@ -136,7 +147,7 @@ describe('Shared Tree Service', () => {
 
   test('SharedTreeService undoUpgradeBottomUp should call redux actions', () => {
     const serviceModelId = "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd";
-    const node = getNodeWithData("undoUpgrade")
+    const node = getNodeWithData("undoUpgrade");
     spyOn(node.parent.data.menuActions['undoUpgrade'], 'method');
     service.undoUpgradeBottomUp(node, serviceModelId);
     expect(node.parent.data.menuActions['undoUpgrade'].method).toBeCalledWith(node.parent, serviceModelId);
@@ -158,12 +169,42 @@ describe('Shared Tree Service', () => {
     expect(MessageBoxService.openModal.next).toHaveBeenCalled();
   });
 
-  test('openAuditInfoModal should open modal for failed instance', () => {
+  each([
+    ['volumeGroups by entry name', "volumeGroups",
+      "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_vRE_BV..module-1", "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1"],
+    ['vfmodule by customizationUuid', "vfModules",
+      "f7e7c365-60cf-49a9-9ebf-a1aa11b9d401", "2017488PasqualeVpe..PASQUALE_vRE_BV..module-1"],
+    ['vnf by customizationUuid', "vnfs",
+      "1da7b585-5e61-4993-b95e-8e6606c81e45", "2017-488_PASQUALE-vPE 0"],
+    ['vnfGroups by invariantUuid because no customizationUuid', "vnfGroups",
+      "4bb2e27e-ddab-4790-9c6d-1f731bc14a45", "groupingservicefortest..ResourceInstanceGroup..0"],
+  ]).test('modelByIdentifier should success: %s', (description, modelTypeName, modelUniqueIdOrName, expectedModelCustomizationName) => {
+    let serviceModelFromHierarchy =
+      getStore().service.serviceHierarchy["1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"];
+
+    expect(service.modelByIdentifiers(serviceModelFromHierarchy, modelTypeName, modelUniqueIdOrName))
+      .toHaveProperty("modelCustomizationName", expectedModelCustomizationName);
+  });
+
+  each([
+    ['vfmodule by invariantUuid when there is customizationUuid', "vfModules", "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1"],
+    ['network by non-existing modelUniqueIdOrName', "networks", "7253ff5c-97f0-4b8b-937c-77aeb4d79aa1"],
+    ['collectionResource has no resource', "collectionResources", "whatever"],
+    ['non-existing model-type', "fooBar", "whatever"],
+  ]).test('modelByIdentifier should fail: %s', (description, modelTypeName, modelUniqueIdOrName) => {
+    let serviceModelFromHierarchy =
+      getStore().service.serviceHierarchy["1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"];
+
+    expect(service.modelByIdentifiers(serviceModelFromHierarchy, modelTypeName, modelUniqueIdOrName))
+      .toBeUndefined();
+  });
+
+  test('openAuditInfoModalInsideIframe should open modal for failed instance', () => {
     jest.spyOn(AuditInfoModalComponent.openInstanceAuditInfoModal, 'next');
 
     let modelInfoServiceMock: ILevelNodeInfo = new VnfModelInfo(null, null,
-      null, null, null, null,
-      null, null, null, null,null);
+      null, null, null, null, null,
+      null, null, null, null,null, null);
     const modelMock = {"a": "a"};
     const instanceMock = {"instance": "instance", "trackById": "123456789"};
     const instanceTypeMock = "instanceTypeMock";
@@ -184,6 +225,14 @@ describe('Shared Tree Service', () => {
         "type": instanceTypeMock
       });
   });
+  each([
+    ['undefined', 'Unlimited (default)', {}],
+    ['null', 'Unlimited (default)', {max:null}],
+    ['3', '3', {max:3}],
+    ]).
+  test("when there is %s max instances in model , shell return %s text", (desc, expected, model) =>{
+    expect(service.createMaximumToInstantiateModelInformationItem(model).values[0]).toBe(expected);
+  });
 
   test('shouldShowDeleteInstanceWithChildrfenModal should not open modal if all childs with action None', () => {
     let foo = () => {
@@ -204,11 +253,11 @@ describe('Shared Tree Service', () => {
     let specificNetworkInfo = [
       ModelInformationItem.createInstance('Network role', "network role 1, network role 2")
     ];
-    const actualInfoModel: ComponentInfoModel = service.addGeneralInfoItems(specificNetworkInfo,ComponentInfoType.NETWORK, getNetworkModel(),getNetworkInstance());
+    const actualInfoModel: ComponentInfoModel = service.addGeneralInfoItems(specificNetworkInfo,ComponentInfoType.NETWORK, getNetworkModelInfoFromHierarchy(),getNetworkInstance());
 
     let expectedGeneralInfo = [
-      ModelInformationItem.createInstance('Model version', '37.0'),
-      ModelInformationItem.createInstance('Model customization ID', '94fdd893-4a36-4d70-b16a-ec29c54c184f'),
+      ModelInformationItem.createInstance('Model version', '2.0'),
+      ModelInformationItem.createInstance('Model customization ID', 'customization-id-from-hierarchy'),
       ModelInformationItem.createInstance('Instance ID', 'NETWORK4_INSTANCE_ID'),
       ModelInformationItem.createInstance('Instance type', 'CONTRAIL30_HIMELGUARD'),
       ModelInformationItem.createInstance('In maintenance', false),
@@ -217,27 +266,137 @@ describe('Shared Tree Service', () => {
     expect(actualInfoModel.modelInfoItems).toEqual(expectedGeneralInfo);
   });
 
+  each([
+    ['model version from hierarchy', null, getNetworkModelInfoFromHierarchy(), '2.0'],
+    ['undefined model', null, null, undefined],
+    ['model version from instance', getSelectedModelInfo(), null, '5.0'],
+    ['model version from instance', getSelectedModelInfo(), getNetworkModelInfoFromHierarchy(), '5.0'],
+  ]).
+  test ('getModelVersionEitherFromInstanceOrFromHierarchy should return %s ' ,
+    (description, instance, model, expectedResult) =>{
+    let actualResult = service.getModelVersionEitherFromInstanceOrFromHierarchy(instance, model);
+    expect(actualResult).toEqual(expectedResult);
+  });
 
+  each([
+    ['model CustomizationId from hierarchy', null, getNetworkModelInfoFromHierarchy(), 'customization-id-from-hierarchy'],
+    ['undefined model', null, null, undefined],
+    ['model CustomizationId from instance', getSelectedModelInfo(), null, 'model-customization-id-from-instance'],
+    ['model CustomizationId from instance', getSelectedModelInfo(), getNetworkModelInfoFromHierarchy(), 'model-customization-id-from-instance'],
+  ]).
+  test ('getCustomizationIdEitherFromInstanceOrFromHierarchy should return %s ' ,
+    (description, instance, model, expectedResult) =>{
+      let actualResult = service.getModelCustomizationIdEitherFromInstanceOrFromHierarchy(instance, model);
+      expect(actualResult).toEqual(expectedResult);
+    });
+
+  each([
+    ['UUID from instance', getSelectedModelInfo(), getNetworkModelInfoFromHierarchy(),"UUID-from-instance" ],
+    ['UUID from instance', getSelectedModelInfo(), null,"UUID-from-instance" ],
+    ['UUID from hierarchy', null, getNetworkModelInfoFromHierarchy(),"UUID-from-hierarchy" ],
+    ['UUID undefined', null, null, undefined],
+
+  ]).
+  test('getModelVersionIdEitherFromInstanceOrFromHierarchy should %s', (description, instance, model, expectedResult) => {
+    let actualUuid = service.getModelVersionIdEitherFromInstanceOrFromHierarchy(instance, model);
+    expect(actualUuid).toEqual(expectedResult);
+  });
+
+  each([
+    ['from instance', getSelectedModelInfo(), getNetworkModelInfoFromHierarchy(), 'invariantId-from-instance'],
+    ['from instance', getSelectedModelInfo(), null, 'invariantId-from-instance'],
+    ['from hierarchy', null, getNetworkModelInfoFromHierarchy(), 'invariantId-from-hierarchy'],
+    ['undefined', null, null, undefined],
+  ]).
+  test('getModelInvariantIdEitherFromInstanceOrFromHierarchy should return invariantId %s', (description, instance, model, expectedInvariantId) =>{
+    let actualInvariantId = service.getModelInvariantIdEitherFromInstanceOrFromHierarchy(instance, model);
+    expect(actualInvariantId).toEqual(expectedInvariantId);
+  });
 
   test('statusProperties should be prop on node according to node properties', () => {
-    let node = service.addingStatusProperty({orchStatus: 'completed', provStatus: 'inProgress', inMaint: false});
+
+    let node = service.addingStatusProperty({orchStatus: 'completed', provStatus: 'inProgress', type: 'VFmodule', instanceModelInfo:{modelVersion: '1'}, inMaint: false});
     expect(node.statusProperties).toBeDefined();
     expect(node.statusProperties).toEqual([Object({
-      key: 'Prov Status:',
+      key: 'Prov Status: ',
       value: 'inProgress',
       testId: 'provStatus'
-    }), Object({key: 'Orch Status:', value: 'completed', testId: 'orchStatus'})]);
-    node = service.addingStatusProperty({orchStatus: 'completed', provStatus: 'inProgress', inMaint: true});
+    }), Object({
+      key: 'Orch Status: ',
+      value: 'completed',
+      testId: 'orchStatus'
+    }),
+    Object({
+      key: 'Model Version: ',
+      value: '1',
+      testId: 'modelVersion'
+    })]);
+    node = service.addingStatusProperty({orchStatus: 'completed', provStatus: 'inProgress',type: 'VFmodule',  instanceModelInfo:{}, inMaint: true});
     expect(node.statusProperties).toEqual([Object({
-      key: 'Prov Status:',
+      key: 'Prov Status: ',
       value: 'inProgress',
       testId: 'provStatus'
-    }), Object({key: 'Orch Status:', value: 'completed', testId: 'orchStatus'}), Object({
+    }), Object({
+      key: 'Orch Status: ',
+      value: 'completed',
+      testId: 'orchStatus'
+    }), Object({
+      key: 'Model Version: ',
+      value: undefined,
+      testId: 'modelVersion'
+    }), Object({
       key: 'In-maintenance',
       value: '',
       testId: 'inMaint'
-    })]);
+    })
+]);
+  });
+  each([
+    ['version 2', '2', '2'],
+    ['undefined', null, undefined]
+  ]).
+  test('getNodeModelVersion should return %s',  (description, nodeVersion, expectedVersion) => {
+    let node = <any>{
+      instanceModelInfo:{
+        modelVersion: nodeVersion
+      }
+    };
+    let actualVersion = service.getNodeModelVersion(node);
+    expect(actualVersion).toEqual(expectedVersion);
+  });
+
+  each([
+    [false, 'method is not in menu actions', ServiceInstanceActions.None, DrawingBoardModes.EDIT, {}, true],
+    [false, 'there is no action in node', null, DrawingBoardModes.EDIT, {someMethod: "someValue"}, true],
+    [true, 'edit mode, action is none, method in menu action', ServiceInstanceActions.None, DrawingBoardModes.EDIT, {someMethod: "someValue"}, true],
+    [false, 'edit mode, action is none, method in menu action, macro service', ServiceInstanceActions.None, DrawingBoardModes.EDIT, {someMethod: "someValue"}, false],
+    [false, 'edit mode, action is not none, method in menu action', ServiceInstanceActions.Resume, DrawingBoardModes.EDIT, {someMethod: "someValue"}, true],
+    [false, 'edit mode, action is CREATE, method in menu action', ServiceInstanceActions.Resume, DrawingBoardModes.EDIT, {someMethod: "someValue"}, true]
+  ]).test('shouldShowButtonGeneric return %s if %s ', (expected, description, action, mode, menuActions, isALaCarte) => {
+    jest.spyOn(store, 'getState').mockReturnValue(<any>{
+      global: {
+        drawingBoardStatus: mode
+      },
+      service : {
+        serviceInstance: {
+          someModelId : {
+            isALaCarte
+          }
+        }
+
+      }
+    });
+    let node = <any>{
+      data:{
+        action: action,
+        menuActions: menuActions
+      },
+    };
+
+    let res = service.shouldShowButtonGeneric(node, "someMethod", "someModelId");
+    expect(res).toBe(expected);
   });
+
   const enableRemoveAndEditItemsDataProvider = [
     ['Create action CREATE mode', DrawingBoardModes.CREATE ,ServiceInstanceActions.Create, true],
     ['Create action VIEW mode',DrawingBoardModes.VIEW , ServiceInstanceActions.Create,false],
@@ -260,224 +419,140 @@ describe('Shared Tree Service', () => {
       let res = service.shouldShowRemoveAndEdit(node);
       expect(res).toBe(enabled);
     });
-});
-function generateService() {
-  return {
-    "vnfs": {
-      "2017-488_PASQUALE-vPE 0": {
-        "inMaint": false,
-        "rollbackOnFailure": "true",
-        "originalName": "2017-488_PASQUALE-vPE 0",
-        "isMissingData": false,
-        "trackById": "stigekyxrqi",
-        "vfModules": {
-          "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": {
-            "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0gytfi": {
-              "isMissingData": false,
-              "sdncPreReload": null,
-              "modelInfo": {
-                "modelType": "VFmodule",
-                "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091",
-                "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db",
-                "modelName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
-                "modelVersion": "5",
-                "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3",
-                "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0"
-              },
-              "instanceParams": [{}],
-              "trackById": "3oj23o7nupo"
+
+
+  const isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDifferProvider = [
+    ['node is part of model, but vfmodule diff by customization',
+      true, 'mDNS 01222020 0', '9fdc68e9-9f53-431c-b8a2-7e337b9a0d0a', '82160e6e-d9c4-45ef-bd19-01573ab11b61'],
+
+    ['vnf model-name not found',
+      false, 'mDNS 01222020 1', '9fdc68e9-9f53-431c-b8a2-7e337b9a0d0a', '82160e6e-d9c4-45ef-bd19-01573ab11b61'],
+
+    ['vfmodule invariant-id not found',
+      false, 'mDNS 01222020 0', 'wrong invariant-id', '82160e6e-d9c4-45ef-bd19-01573ab11b61'],
+
+    ['vfmodule customization-id match',
+      false, 'mDNS 01222020 0', '9fdc68e9-9f53-431c-b8a2-7e337b9a0d0a', 'c9b32003-febc-44e0-a97f-7630fa7fa4a0'],
+  ];
+
+  each(isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDifferProvider).test('isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer: when  %s should return %s', (description, expected, vnfModelName, invariantUuid, customizationUuid) => {
+    const serviceModelId : string = 'a243da28-c11e-45a8-9f26-0284a9a789bc';
+    spyOn(store, 'getState').and.returnValue({
+      service : {
+        serviceHierarchy : {
+          [serviceModelId] : {
+            vnfs : {
+              [vnfModelName] : {
+                vfModules : {
+                  vfModuleModelName : {
+                    invariantUuid : invariantUuid,
+                    customizationUuid : customizationUuid
+                  }
+                }
+              }
             }
           }
-        },
-        "vnfStoreKey": "2017-488_PASQUALE-vPE 0",
-        "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
-        "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c",
-        "lcpCloudRegionId": "AAIAIC25",
-        "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
-        "lineOfBusiness": "ONAP",
-        "platformName": "xxx1",
-        "modelInfo": {
-          "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
-          "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
-          "modelName": "2017-488_PASQUALE-vPE",
-          "modelVersion": "5.0",
-          "modelCustomizationName": "2017-488_PASQUALE-vPE 0",
-          "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45",
-          "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09"
-        },
-        "legacyRegion": "11111111",
-        "instanceParams": [{}]
-      },
-      "2017-388_PASQUALE-vPE 0": {
-        "inMaint": false,
-        "rollbackOnFailure": "true",
-        "originalName": "2017-388_PASQUALE-vPE 0",
-        "isMissingData": false,
-        "trackById": "nib719t5vca",
-        "vfModules": {},
-        "vnfStoreKey": "2017-388_PASQUALE-vPE 0",
-        "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c",
-        "lcpCloudRegionId": "AAIAIC25",
-        "legacyRegion": "11111",
-        "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
-        "platformName": "platform",
-        "lineOfBusiness": "zzz1",
-        "instanceParams": [{}],
-        "modelInfo": {
-          "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
-          "modelVersionId": "afacccf6-397d-45d6-b5ae-94c39734b168",
-          "modelName": "2017-388_PASQUALE-vPE",
-          "modelVersion": "4.0",
-          "modelCustomizationId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c",
-          "modelCustomizationName": "2017-388_PASQUALE-vPE 0",
-          "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168"
-        },
-        "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168"
-      },
-      "2017-388_PASQUALE-vPE 1": {
-        "inMaint": false,
-        "rollbackOnFailure": "true",
-        "originalName": "2017-388_PASQUALE-vPE 1",
-        "isMissingData": false,
-        "trackById": "cv7l1ak8vpe",
-        "vfModules": {},
-        "vnfStoreKey": "2017-388_PASQUALE-vPE 1",
-        "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c",
-        "lcpCloudRegionId": "AAIAIC25",
-        "legacyRegion": "123",
-        "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
-        "platformName": "platform",
-        "lineOfBusiness": "ONAP",
-        "instanceParams": [{}],
-        "modelInfo": {
-          "modelInvariantId": "00beb8f9-6d39-452f-816d-c709b9cbb87d",
-          "modelVersionId": "0903e1c0-8e03-4936-b5c2-260653b96413",
-          "modelName": "2017-388_PASQUALE-vPE",
-          "modelVersion": "1.0",
-          "modelCustomizationId": "280dec31-f16d-488b-9668-4aae55d6648a",
-          "modelCustomizationName": "2017-388_PASQUALE-vPE 1",
-          "uuid": "0903e1c0-8e03-4936-b5c2-260653b96413"
-        },
-        "uuid": "0903e1c0-8e03-4936-b5c2-260653b96413"
+        }
       }
-    },
-    "instanceParams": [{}],
-    "validationCounter": 0,
-    "existingNames": {"yoav": ""},
-    "existingVNFCounterMap": {
-      "69e09f68-8b63-4cc9-b9ff-860960b5db09": 1,
-      "afacccf6-397d-45d6-b5ae-94c39734b168": 1,
-      "0903e1c0-8e03-4936-b5c2-260653b96413": 1
-    },
-    "existingVnfGroupCounterMap": {
-      "daeb6568-cef8-417f-9075-ed259ce59f48": 0,
-      "c2b300e6-45de-4e5e-abda-3032bee2de56": -1
-    },
-    "existingNetworksCounterMap": {"ddc3f20c-08b5-40fd-af72-c6d14636b986": 1},
-    "networks": {
-      "ExtVL 0": {
-        "inMaint": false,
-        "rollbackOnFailure": "true",
-        "originalName": "ExtVL 0",
-        "isMissingData": false,
-        "trackById": "s6okajvv2n8",
-        "networkStoreKey": "ExtVL 0",
-        "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c",
-        "lcpCloudRegionId": "AAIAIC25",
-        "legacyRegion": "12355555",
-        "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
-        "platformName": "platform",
-        "lineOfBusiness": null,
-        "instanceParams": [{}],
-        "modelInfo": {
-          "modelInvariantId": "379f816b-a7aa-422f-be30-17114ff50b7c",
-          "modelVersionId": "ddc3f20c-08b5-40fd-af72-c6d14636b986",
-          "modelName": "ExtVL",
-          "modelVersion": "37.0",
-          "modelCustomizationId": "94fdd893-4a36-4d70-b16a-ec29c54c184f",
-          "modelCustomizationName": "ExtVL 0",
-          "uuid": "ddc3f20c-08b5-40fd-af72-c6d14636b986"
-        },
-        "uuid": "ddc3f20c-08b5-40fd-af72-c6d14636b986"
+    });
+
+    const node = <any>{
+      data:{
+        modelInvariantId : '9fdc68e9-9f53-431c-b8a2-7e337b9a0d0a',
+        modelCustomizationId : 'c9b32003-febc-44e0-a97f-7630fa7fa4a0',
+        modelName : 'vfModuleModelName'
+      },
+      parent : {
+        data : {
+          modelName : "mDNS 01222020 0"
+        }
       }
-    },
-    "vnfGroups": {
-      "groupingservicefortest..ResourceInstanceGroup..0": {
-        "inMaint": false,
-        "rollbackOnFailure": "true",
-        "originalName": "groupingservicefortest..ResourceInstanceGroup..0",
-        "isMissingData": false,
-        "trackById": "se0obn93qq",
-        "vnfGroupStoreKey": "groupingservicefortest..ResourceInstanceGroup..0",
-        "instanceName": "groupingservicefortestResourceInstanceGroup0",
-        "instanceParams": [{}],
-        "modelInfo": {
-          "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45",
-          "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48",
-          "modelName": "groupingservicefortest..ResourceInstanceGroup..0",
-          "modelVersion": "1",
-          "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0",
-          "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48"
-        },
-        "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48"
+    };
+
+    const isDiffCustomizationUuidResponse : boolean = service.isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer(node, serviceModelId);
+    expect(isDiffCustomizationUuidResponse).toEqual(expected);
+  });
+
+  each([
+    [false, true, true, false],
+    [true, true, true, true],
+    [true, true, false, true],
+    [true, false, true, true],
+    [true, false, false, false],
+  ]).
+  test('when flag is %s the UpdatedLatestVersion is %s and Vfmodule not exists on hierarchy is %s isShouldShowButtonGenericMustToBeCalled should return %s', (
+     flag: boolean,
+     isThereAnUpdatedLatestVersion: boolean,
+     isVfModuleCustomizationIdNotExistsOnModel: boolean,
+     isShouldShowButtonGenericMustToBeCalled: boolean
+     ) => {
+      let node = <any>  {};
+      let serviceModelId : string = '08c5fa17-769a-4231-bd92-aed4b0ed086d';
+      jest.spyOn(store, 'getState').mockReturnValue(<any>{
+        global: {
+          "flags": {
+            "FLAG_FLASH_REPLACE_VF_MODULE": flag,
+          },
+        }
+      });
+      spyOn(service, 'isThereAnUpdatedLatestVersion').and.returnValue(isThereAnUpdatedLatestVersion);
+      spyOn(service, 'isVfModuleCustomizationIdNotExistsOnModel').and.returnValue(isVfModuleCustomizationIdNotExistsOnModel);
+
+      expect(service.isVfMoudleCouldBeUpgraded(node, serviceModelId)).toEqual(isShouldShowButtonGenericMustToBeCalled);
+    });
+
+  each([
+    ['Vfm customization uuid not exists in model', 'not-existing-customization-uuid', 'service-model-id', true],
+    ['Vfm customization uuid exists in model', 'existing-customization-uuid', 'service-model-id', false]
+  ]).
+  test('%s when vfModuleNode is  %s and serviceModelId is %s ', (
+    description,
+    modelCustomizationId,
+    serviceModelId: string,
+    isExistsOnHierarchy: boolean,
+    ) => {
+
+    const vfModuleNode = { data: {
+        modelCustomizationId : modelCustomizationId
+      }};
+
+    jest.spyOn(store, 'getState').mockReturnValue(<any>{
+      service : {
+        "serviceHierarchy": {
+          [serviceModelId]: {
+            "vfModules": {
+              "module-1": {
+                "customizationUuid": "3d7f41c8-333b-4fee-b50d-5687e9c2170f",
+              },
+              "module-2": {
+                "customizationUuid": "existing-customization-uuid",
+              }
+            }
+          }
+        }
       }
-    },
-    "instanceName": "yoav",
-    "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89",
-    "subscriptionServiceType": "TYLER SILVIA",
-    "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
-    "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c",
-    "lcpCloudRegionId": "AAIAIC25",
-    "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
-    "aicZoneId": "ATL53",
-    "pause": null,
-    "projectName": "WATKINS",
-    "rollbackOnFailure": "true",
-    "bulkSize": 1,
-    "aicZoneName": "AAIATLTE-ATL53",
-    "owningEntityName": "WayneHolland",
-    "testApi": "VNF_API",
-    "isEcompGeneratedNaming": false,
-    "tenantName": "USP-SIP-IC-24335-T-01",
-    "modelInfo": {
-      "modelInvariantId": "cdb90b57-ed78-4d44-a5b4-7f43a02ec632",
-      "modelVersionId": "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd",
-      "modelName": "action-data",
-      "modelVersion": "1.0",
-      "uuid": "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"
-    },
-    "isALaCarte": false,
-    "name": "action-data",
-    "version": "1.0",
-    "description": "PASQUALE vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM",
-    "category": "Network L1-3",
-    "uuid": "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd",
-    "invariantUuid": "cdb90b57-ed78-4d44-a5b4-7f43a02ec632",
-    "serviceType": "pnf",
-    "serviceRole": "Testing",
-    "vidNotions": {"instantiationUI": "legacy", "modelCategory": "other", "viewEditUI": "legacy"},
-    "isMultiStepDesign": true
-  };
-}
+    });
+    expect(service.isVfModuleCustomizationIdNotExistsOnModel(vfModuleNode, serviceModelId)).toEqual(isExistsOnHierarchy);
+
+
+  });
+
+});
 
 function getStore() {
   return {
     "global": {
       "name": null,
       "flags": {
-        "CREATE_INSTANCE_TEST": false,
         "EMPTY_DRAWING_BOARD_TEST": false,
         "FLAG_NETWORK_TO_ASYNC_INSTANTIATION": false,
         "FLAG_ADD_MSO_TESTAPI_FIELD": true,
         "FLAG_SERVICE_MODEL_CACHE": true,
         "FLAG_SHOW_ASSIGNMENTS": true,
         "FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS": true,
-        "FLAG_DEFAULT_VNF": true,
-        "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": true,
         "FLAG_A_LA_CARTE_AUDIT_INFO": true,
         "FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST": true,
         "FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS": true,
-        "FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE": true,
         "FLAG_1902_NEW_VIEW_EDIT": true,
         "FLAG_1810_IDENTIFY_SERVICE_FOR_NEW_UI": false,
         "FLAG_1902_VNF_GROUPING": true,
@@ -1511,62 +1586,30 @@ function getStore() {
   }
 }
 
-function getNetworkModel(){
-  return {
-    "customizationUuid":"94fdd893-4a36-4d70-b16a-ec29c54c184f",
-    "name":"ExtVL",
-    "version":"37.0",
-    "description":"ECOMP generic virtual link (network) base type for all other service-level and global networks",
-    "uuid":"ddc3f20c-08b5-40fd-af72-c6d14636b986",
-    "invariantUuid":"379f816b-a7aa-422f-be30-17114ff50b7c",
-    "max":1,
-    "min":0,
-    "isEcompGeneratedNaming":false,
-    "type":"VL",
-    "modelCustomizationName":"ExtVL 0",
-    "roles":["network role 1"," network role 2"],
-    "properties":{
-      "network_role":"network role 1, network role 2",
-      "network_assignments":
-        "{is_external_network=false, ipv4_subnet_default_assignment={min_subnets_count=1}, ecomp_generated_network_assignment=false, ipv6_subnet_default_assignment={min_subnets_count=1}}",
-      "exVL_naming":"{ecomp_generated_naming=true}","network_flows":"{is_network_policy=false, is_bound_to_vpn=false}",
-      "network_homing":"{ecomp_selected_instance_node_target=false}"
-    }
-  };
 
+function getNetworkModelInfoFromHierarchy(){
+  return {
+    "version": "2.0",
+    "customizationUuid":"customization-id-from-hierarchy",
+    "uuid": "UUID-from-hierarchy",
+    "invariantUuid": "invariantId-from-hierarchy"
+  }
 }
 
+function getSelectedModelInfo() {
+  return {
+    "instanceModelInfo": {
+      "modelVersion": "5.0",
+      "modelCustomizationId": "model-customization-id-from-instance",
+      "modelVersionId": "UUID-from-instance",
+      "modelInvariantId": "invariantId-from-instance"
+    }
+  }
+}
 function getNetworkInstance() {
   return {
-    "modelCustomizationId": "94fdd893-4a36-4d70-b16a-ec29c54c184f",
-    "modelId": "ddc3f20c-08b5-40fd-af72-c6d14636b986",
-    "modelUniqueId": "94fdd893-4a36-4d70-b16a-ec29c54c184f",
-    "missingData": true,
-    "id": "NETWORK4_INSTANCE_ID",
-    "action": "None",
-    "orchStatus": "Created",
-    "provStatus": "preprov",
     "inMaint": false,
     "instanceId": "NETWORK4_INSTANCE_ID",
     "instanceType": "CONTRAIL30_HIMELGUARD",
-    "instanceName": "NETWORK4_INSTANCE_NAME",
-    "name": "NETWORK4_INSTANCE_NAME",
-    "modelName": "ExtVL 0",
-    "type": "VL",
-    "isEcompGeneratedNaming": false,
-    "networkStoreKey": "NETWORK4_INSTANCE_ID",
-    "typeName": "N",
-    "menuActions": {"edit": {}, "showAuditInfo": {}, "duplicate": {}, "remove": {}, "delete": {}, "undoDelete": {}},
-    "isFailed": false,
-    "statusMessage": "",
-    "statusProperties": [{"key": "Prov Status:", "value": "preprov", "testId": "provStatus"}, {
-      "key": "Orch Status:",
-      "value": "Created",
-      "testId": "orchStatus"
-    }],
-    "trackById": "1wvr73xl999",
-    "parentType": "",
-    "componentInfoType": "Network",
-    "errors": {}
   };
 }