diff options
author | Ittay Stern <ittay.stern@att.com> | 2020-02-16 15:47:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-02-16 15:47:12 +0000 |
commit | cdd9b9bbc017ea323483dd153773e4ee158fceed (patch) | |
tree | 85c9fb99f45dee087c51e38e6c42467860640562 | |
parent | cd5df8ad4a74522ac8cdea9108b6a8c8250662c7 (diff) | |
parent | 32d65b8087406fccc5db734a6843d8942727bd78 (diff) |
Merge "the upgrade button is allowed when VFM in instance not exists in model."
2 files changed, 51 insertions, 4 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts index 3499377ac..dc4c2d3de 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts @@ -400,10 +400,10 @@ describe('Shared Tree Service', () => { [true, false, true, true], [true, false, false, false], ]). - test('when flag is %s the UpdatedLatestVersion is %s and Vfmodule CustomizationUuid Differ is %s isShouldShowButtonGenericMustToBeCalled should return %s', ( + 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, - isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer: boolean, + isVfModuleCustomizationIdNotExistsOnModel: boolean, isShouldShowButtonGenericMustToBeCalled: boolean ) => { let node = <any> {}; @@ -416,11 +416,47 @@ describe('Shared Tree Service', () => { } }); spyOn(service, 'isThereAnUpdatedLatestVersion').and.returnValue(isThereAnUpdatedLatestVersion); - spyOn(service, 'isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer').and.returnValue(isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer); + 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", + } + } + } + } + } + }); + expect(service.isVfModuleCustomizationIdNotExistsOnModel(vfModuleNode, serviceModelId)).toEqual(isExistsOnHierarchy); + + + }); + }); function getStore() { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts index de859e4ea..864472505 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts @@ -222,7 +222,18 @@ export class SharedTreeService { isVfMoudleCouldBeUpgraded(node, serviceModelId): boolean{ return (FeatureFlagsService.getFlagState(Features.FLAG_FLASH_REPLACE_VF_MODULE, this._store) && - ((this.isThereAnUpdatedLatestVersion(serviceModelId)) || this.isVfmoduleAlmostPartOfModelOnlyCustomizationUuidDiffer(node, serviceModelId))) + (this.isThereAnUpdatedLatestVersion(serviceModelId) || this.isVfModuleCustomizationIdNotExistsOnModel(node, serviceModelId))) + } + + isVfModuleCustomizationIdNotExistsOnModel(vfModuleNode, serviceModelId) { + + // prevent undefined + if (_.isNil(vfModuleNode.data) || _.isNil(vfModuleNode.data.modelCustomizationId)) { + return false; + } + + let vfModulesHierarchyByGivenModelId = this._store.getState().service.serviceHierarchy[serviceModelId].vfModules; + return !_.some(vfModulesHierarchyByGivenModelId, vfmodel => vfmodel.customizationUuid === vfModuleNode.data.modelCustomizationId); } |