diff options
Diffstat (limited to 'vid-webpack-master/src')
20 files changed, 389 insertions, 247 deletions
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 2210d7c84..5e14586c5 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 @@ -20,10 +20,10 @@ import {MessageBoxService} from "../../../../../shared/components/messageBox/mes import {AvailableNodeIcons} from "../../../available-models-tree/available-models-tree.service"; import {IframeService} from "../../../../../shared/utils/iframe.service"; import { - deleteActionVfModuleInstance, + deleteActionVfModuleInstance, deleteVFModuleField, removeVfModuleInstance, undoDeleteVfModuleInstance, - undoUgradeVFModule, + undoUgradeVFModule, updateVFModuleField, updateVFModulePosition, upgradeVFModule } from "../../../../../shared/storeUtil/utils/vfModule/vfModule.actions"; @@ -354,7 +354,8 @@ export class VFModuleModelInfo implements ILevelNodeInfo { }, undoDelete: { method: (node, serviceModelId) => { - this._store.dispatch(undoDeleteVfModuleInstance(node.data.dynamicModelName, node.parent.data.vnfStoreKey, serviceModelId)) + this._store.dispatch(undoDeleteVfModuleInstance(node.data.dynamicModelName, node.parent.data.vnfStoreKey, serviceModelId)); + this._store.dispatch(deleteVFModuleField(node.data.modelName, node.parent.data.vnfStoreKey, node.data.servicedId ,node.data.dynamicModelName, 'retainAssignments')); }, visible: (node) => this._sharedTreeService.shouldShowUndoDelete(node), enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && this._sharedTreeService.shouldShowDelete(node.parent) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId) @@ -386,9 +387,6 @@ export class VFModuleModelInfo implements ILevelNodeInfo { } private upgradeVFM(serviceModelId, node) { - this._sharedTreeService.upgradeBottomUp(node, serviceModelId); - this._store.dispatch(upgradeVFModule(node.data.modelName, node.parent.data.vnfStoreKey, serviceModelId, node.data.dynamicModelName)); - if (FeatureFlagsService.getFlagState(Features.FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS, this._store)) { this._iframeService.addClassOpenModal('content'); this._dialogService.addDialog(GenericFormPopupComponent, { @@ -401,10 +399,14 @@ export class VFModuleModelInfo implements ILevelNodeInfo { modelId: node.data.modelId, type: node.data.type, popupService: this._vfModuleUpgradePopupService, + vfModule : _.cloneDeep(node) }, - node: node, + node, isUpdateMode: false }); + }else { + this._sharedTreeService.upgradeBottomUp(node, serviceModelId); + this._store.dispatch(upgradeVFModule(node.data.modelName, node.parent.data.vnfStoreKey, serviceModelId ,node.data.dynamicModelName)); } } diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrfModal/networkStep/network.step.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrfModal/networkStep/network.step.service.spec.ts index c7c8d07a0..5d502c2da 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrfModal/networkStep/network.step.service.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrfModal/networkStep/network.step.service.spec.ts @@ -84,7 +84,6 @@ describe('Network step service', () => { "genericModalCriteria": {"roles": ["-- select an option --", "network role 1", "network role 2", "network role 3", "network role 4", "network role 5"]}, "name": null, "flags": { - "CREATE_INSTANCE_TEST": false, "EMPTY_DRAWING_BOARD_TEST": false, "FLAG_NETWORK_TO_ASYNC_INSTANTIATION": false, "FLAG_ENABLE_WEBPACK_MODERN_UI": true, 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 1412faa24..53854ac7b 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 @@ -467,7 +467,6 @@ function getStore() { "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, diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts index 5b64aea9b..14d14668a 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts @@ -25,9 +25,7 @@ class MockAppStore<T> { "FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS": true, "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, - "CREATE_INSTANCE_TEST": false, "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false, - "EMPTY_DRAWING_BOARD_TEST": false, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, "type": "[FLAGS] Update" diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts index a6a29d1df..f644a7c7e 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/service.control.generator.spec.ts @@ -25,9 +25,7 @@ class MockAppStore<T> { "FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS": true, "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, - "CREATE_INSTANCE_TEST": false, "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false, - "EMPTY_DRAWING_BOARD_TEST": false, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, "type": "[FLAGS] Update" diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts index f8a2da711..62c5ce3f4 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts @@ -27,9 +27,7 @@ class MockAppStore<T> { "FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS": true, "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, - "CREATE_INSTANCE_TEST": false, "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false, - "EMPTY_DRAWING_BOARD_TEST": false, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, "type": "[FLAGS] Update" diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts index 66afac9ad..5c6e25c6b 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts @@ -28,9 +28,7 @@ class MockAppStore<T> { "FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS": true, "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, - "CREATE_INSTANCE_TEST": false, "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false, - "EMPTY_DRAWING_BOARD_TEST": false, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, "type": "[FLAGS] Update" diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts index 71d661191..49f1aa3ae 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.spec.ts @@ -25,8 +25,6 @@ class MockAppStore<T> { "type": "UPDATE_DRAWING_BOARD_STATUS", "drawingBoardStatus": "CREATE", "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": false, diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts index ab70ea335..a36ed9c4c 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts @@ -33,9 +33,7 @@ class MockAppStore<T>{ "FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS": true, "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, - "CREATE_INSTANCE_TEST": false, "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false, - "EMPTY_DRAWING_BOARD_TEST": false, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, "type": "[FLAGS] Update" diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts index 54af063d8..c2024afe2 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts @@ -33,10 +33,8 @@ class MockReduxStore<T> { "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, "FLAG_ADVANCED_PORTS_FILTER": true, - "CREATE_INSTANCE_TEST": false, "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false, "FLAG_REGION_ID_FROM_REMOTE": true, - "EMPTY_DRAWING_BOARD_TEST": false, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, "type": "[FLAGS] Update" diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts index eb094abfb..6c20beccc 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts @@ -30,10 +30,8 @@ class MockReduxStore<T> { "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, "FLAG_ADVANCED_PORTS_FILTER": true, - "CREATE_INSTANCE_TEST": false, "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false, "FLAG_REGION_ID_FROM_REMOTE": true, - "EMPTY_DRAWING_BOARD_TEST": false, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, "type": "[FLAGS] Update" diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts index 5b5acd33b..f1e3af006 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts @@ -31,10 +31,8 @@ class MockReduxStore<T> { "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, "FLAG_ADVANCED_PORTS_FILTER": true, - "CREATE_INSTANCE_TEST": false, "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false, "FLAG_REGION_ID_FROM_REMOTE": true, - "EMPTY_DRAWING_BOARD_TEST": false, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, "type": "[FLAGS] Update" diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.spec.ts index 5b27b6e29..296db3469 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModule/vfModule.popuop.service.spec.ts @@ -30,10 +30,8 @@ class MockReduxStore<T> { "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, "FLAG_ADVANCED_PORTS_FILTER": true, - "CREATE_INSTANCE_TEST": false, "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false, "FLAG_REGION_ID_FROM_REMOTE": true, - "EMPTY_DRAWING_BOARD_TEST": false, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, "type": "[FLAGS] Update" diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts index a7f6d5515..ff3f23ff4 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts @@ -3,9 +3,34 @@ import {ITreeNode} from "angular-tree-component/dist/defs/api"; import {FormGroup} from "@angular/forms"; import {VfModulePopuopService} from "../vfModule/vfModule.popuop.service"; import {FormPopupDetails} from "../../../../models/formControlModels/formPopupDetails.model"; +import {updateVFModuleField, upgradeVFModule} from "../../../../storeUtil/utils/vfModule/vfModule.actions"; +import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service"; +import {NgRedux} from "@angular-redux/store"; +import {AppState} from "../../../../store/reducers"; +import {BasicControlGenerator} from "../../../genericForm/formControlsServices/basic.control.generator"; +import {VfModuleControlGenerator} from "../../../genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator"; +import {IframeService} from "../../../../utils/iframe.service"; +import {DefaultDataGeneratorService} from "../../../../services/defaultDataServiceGenerator/default.data.generator.service"; +import {AaiService} from "../../../../services/aaiService/aai.service"; +import {BasicPopupService} from "../basic.popup.service"; +import { + FormControlModel +} from "../../../../models/formControlModels/formControl.model"; +import {CheckboxFormControl} from "../../../../models/formControlModels/checkboxFormControl.model"; +import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum"; @Injectable() export class VfModuleUpgradePopupService extends VfModulePopuopService { + constructor(protected _basicControlGenerator: BasicControlGenerator, + protected _vfModuleControlGenerator: VfModuleControlGenerator, + protected _iframeService: IframeService, + protected _defaultDataGeneratorService: DefaultDataGeneratorService, + protected _aaiService: AaiService, + protected _basicPopupService : BasicPopupService, + protected _store: NgRedux<AppState>, + private _sharedTreeService : SharedTreeService){ + super(_basicControlGenerator, _vfModuleControlGenerator, _iframeService, _defaultDataGeneratorService, _aaiService, _basicPopupService,_store); + } node: ITreeNode; getGenericFormPopupDetails(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, node: ITreeNode, uuidData: Object, isUpdateMode: boolean): FormPopupDetails { @@ -13,11 +38,31 @@ export class VfModuleUpgradePopupService extends VfModulePopuopService { } getDynamicInputs = () => []; - getControls = () => []; + + getControls = () : FormControlModel[] => { + return [ + new CheckboxFormControl({ + type: FormControlType.CHECKBOX, + controlName: 'retainAssignments', + displayName: 'Retain Assignments', + dataTestId: 'retainAssignments', + value: true, + validations: [] + }) + ]; + }; + + getTitle = (): string => 'Upgrade Module'; onSubmit(that, form: FormGroup) { - //that.storeVFModule(that, form.value); + const node = that.uuidData.vfModule; + const serviceInstanceId: string = that.uuidData.serviceId; + + this._store.dispatch(upgradeVFModule(node.data.modelName, node.parent.data.vnfStoreKey, serviceInstanceId ,node.data.dynamicModelName)); + this._sharedTreeService.upgradeBottomUp(node, serviceInstanceId); + this._store.dispatch(updateVFModuleField(node.data.modelName, node.parent.data.vnfStoreKey, serviceInstanceId ,node.data.dynamicModelName, 'retainAssignments', form.controls['retainAssignments'].value)); + this.postSubmitIframeMessage(that); this.onCancel(that, form); } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts index 17054c78b..5850d25f0 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts @@ -13,6 +13,7 @@ import {SdcUiServices} from "onap-ui-angular"; import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service"; import {getTestBed, TestBed} from "@angular/core/testing"; import {VfModuleUpgradePopupService} from "./vfModule.upgrade.popuop.service"; +import {SharedTreeService} from "../../../../../drawingBoard/service-planning/objectsToTree/shared.tree.service"; class MockModalService<T> { } @@ -52,6 +53,7 @@ describe('VFModule popup service', () => { AaiService, LogService, BasicPopupService, + SharedTreeService, {provide: FeatureFlagsService, useClass: MockFeatureFlagsService}, {provide: NgRedux, useClass: MockReduxStore}, {provide: HttpClient, useClass: MockAppStore}, @@ -73,4 +75,15 @@ describe('VFModule popup service', () => { expect(service.getTitle()).toBe("Upgrade Module") }); + test('get controls should return retainAssignments control with false i', ()=> { + + const controls = service.getControls(); + + const retainAssignmentsControl = controls.find((control)=>{ + return control.controlName === 'retainAssignments'; + }); + + expect(retainAssignmentsControl).toBeDefined(); + expect(retainAssignmentsControl.value).toBeTruthy(); + }); }); diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts index b1bbc92a8..5f0347350 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts @@ -30,10 +30,8 @@ class MockReduxStore<T> { "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, "FLAG_ADVANCED_PORTS_FILTER": true, - "CREATE_INSTANCE_TEST": false, "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false, "FLAG_REGION_ID_FROM_REMOTE": true, - "EMPTY_DRAWING_BOARD_TEST": false, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, "type": "[FLAGS] Update" diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts index 075c97227..f0d50fd18 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnfGroup/vnfGroup.popup.service.spec.ts @@ -30,10 +30,8 @@ class MockReduxStore<T> { "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, "FLAG_ADVANCED_PORTS_FILTER": true, - "CREATE_INSTANCE_TEST": false, "FLAG_SETTING_DEFAULTS_IN_DRAWING_BOARD": false, "FLAG_REGION_ID_FROM_REMOTE": true, - "EMPTY_DRAWING_BOARD_TEST": false, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, "type": "[FLAGS] Update" diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts index 59e5ee1fa..70c10c429 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts @@ -9,6 +9,8 @@ export enum VfModuleActions { UPDATE_VFMODULE_POSITION = "UPDATE_VFMODULE_POSITION", UPGRADE_VFMODULE = "UPGRADE_VFMODULE", UNDO_UPGRADE_VFMODULE_ACTION = "UNDO_UPGRADE_VFMODULE_ACTION", + UPDATE_VFMODULE_FEILD = "UPDATE_VFMODULE_FEILD", + DELETE_VFMODULE_FEILD = "DELETE_VFMODULE_FEILD", } @@ -62,6 +64,23 @@ export interface UndoUpgradeVfModuleInstanceAction extends Action { dynamicModelName: string; } +export interface UpdateVFModuleField extends Action { + modelName : string; + vnfStoreKey : string; + serviceId: string; + dynamicModelName: string; + fieldName: string; + fieldValue : any; +} + +export interface DeleteVFModuleField extends Action { + modelName : string; + vnfStoreKey : string; + serviceId: string; + dynamicModelName: string; + deleteFieldName: string; +} + export interface UndoDeleteActionVfModuleInstanceAction extends Action { dynamicModelName: string; vnfStoreKey : string; @@ -132,3 +151,22 @@ export const undoUgradeVFModule: ActionCreator<UndoUpgradeVfModuleInstanceAction vnfStoreKey, serviceId }); + +export const updateVFModuleField: ActionCreator<UpdateVFModuleField> = (modelName, vnfStoreKey, serviceId, dynamicModelName, fieldName, fieldValue) => ({ + type: VfModuleActions.UPDATE_VFMODULE_FEILD, + dynamicModelName, + modelName, + vnfStoreKey, + serviceId, + fieldName, + fieldValue +}); + +export const deleteVFModuleField: ActionCreator<DeleteVFModuleField> = (modelName, vnfStoreKey, serviceId, dynamicModelName, deleteFieldName) => ({ + type: VfModuleActions.DELETE_VFMODULE_FEILD, + dynamicModelName, + modelName, + vnfStoreKey, + serviceId, + deleteFieldName +}); diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts index ee0edb0a7..7b890b715 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts @@ -1,9 +1,9 @@ import { CreateVFModuleInstanceAction, - DeleteActionVfModuleInstanceAction, + DeleteActionVfModuleInstanceAction, DeleteVFModuleField, DeleteVfModuleInstanceAction, UndoDeleteActionVfModuleInstanceAction, - UpdateVFModluePosition, + UpdateVFModluePosition, UpdateVFModuleField, UpgradeVfModuleInstanceAction, VfModuleActions } from "./vfModule.actions"; @@ -14,12 +14,13 @@ import {ServiceInstanceActions} from "../../../models/serviceInstanceActions"; describe('vfModuleReducer', () => { test('#REMOVE_VNF_MODULE_INSTANCE : should delete existing vnf module by dynamicModelName', () => { - let state = vfModuleReducer(<any>{serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vfName' : { - vfModules : { - 'modelName' : { + let state = vfModuleReducer(<any>{ + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vfName': { + vfModules: { + 'modelName': { 'dynamicModelName1': {}, 'dynamicModelName2': {}, } @@ -27,13 +28,14 @@ describe('vfModuleReducer', () => { } } } - }}, + } + }, <DeleteVfModuleInstanceAction>{ type: VfModuleActions.REMOVE_VNF_MODULE_INSTANCE, - modelName : 'modelName', - vfName : 'vfName', - vnfStoreKey : 'vfName', - serviceModelId : 'serviceModelId', + modelName: 'modelName', + vfName: 'vfName', + vnfStoreKey: 'vfName', + serviceModelId: 'serviceModelId', dynamicModelName: 'dynamicModelName1' }); @@ -43,26 +45,27 @@ describe('vfModuleReducer', () => { }); test('#DELETE_LAST_VNF_MODULE_INSTANCE : should delete existing vnf module', () => { - let state = vfModuleReducer(<any>{serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vfName' : { - vfModules : { - 'modelName' : { - 'dynamicModelName': { - } + let state = vfModuleReducer(<any>{ + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vfName': { + vfModules: { + 'modelName': { + 'dynamicModelName': {} } } } } } - }}, + } + }, <DeleteVfModuleInstanceAction>{ type: VfModuleActions.REMOVE_VNF_MODULE_INSTANCE, - modelName : 'modelName', - vfName : 'vfName', - vnfStoreKey : 'vfName', - serviceModelId : 'serviceModelId', + modelName: 'modelName', + vfName: 'vfName', + vnfStoreKey: 'vfName', + serviceModelId: 'serviceModelId', dynamicModelName: 'dynamicModelName' }); @@ -70,28 +73,29 @@ describe('vfModuleReducer', () => { expect(state.serviceInstance['serviceModelId'].vnfs['vfName'].vfModules['modelName']).not.toBeDefined(); }); - test('#CREATE_VF_MODULE: should create new vfModule to existing VNF', ()=>{ - let vfModuleInstance : VfModuleInstance = new VfModuleInstance(); + test('#CREATE_VF_MODULE: should create new vfModule to existing VNF', () => { + let vfModuleInstance: VfModuleInstance = new VfModuleInstance(); vfModuleInstance.instanceName = 'instanceName'; vfModuleInstance.isMissingData = false; vfModuleInstance.volumeGroupName = 'volumeGroupName'; - let vfModule = vfModuleReducer(<any>{serviceInstance : { - 'serviceUuid' : { - vnfs : { - 'vnfStoreKey' : { - 'vfModules' : { - } + let vfModule = vfModuleReducer(<any>{ + serviceInstance: { + 'serviceUuid': { + vnfs: { + 'vnfStoreKey': { + 'vfModules': {} } } } - }}, + } + }, <CreateVFModuleInstanceAction>{ type: VfModuleActions.CREATE_VF_MODULE, - vfId : 'vfId', - vfInstance : new VfModuleInstance(), - vnfStoreKey : 'vnfStoreKey', - serviceUuid : 'serviceUuid', - index : 1 + vfId: 'vfId', + vfInstance: new VfModuleInstance(), + vnfStoreKey: 'vnfStoreKey', + serviceUuid: 'serviceUuid', + index: 1 }).serviceInstance['serviceUuid'].vnfs['vnfStoreKey'].vfModules; let firstVfModuleName = Object.keys(vfModule)[0]; @@ -99,23 +103,64 @@ describe('vfModuleReducer', () => { expect(vfModule[firstVfModuleName].isMissingData).toBeFalsy(); }); - test('#UPDATE_VF_MODULE: should update existing VFModule', ()=>{ - let vfModuleInstance : VfModuleInstance = new VfModuleInstance(); - vfModuleInstance.instanceName = 'instanceName'; - vfModuleInstance.isMissingData = false; - vfModuleInstance.volumeGroupName = 'volumeGroupName'; - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} + test('#UPDATE_VFMODULE_FEILD: should update field with some value', () => { + const newFieldName = 'newFieldName'; + const newFieldValue = 'newFieldValue'; + let oldState = { + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'modelName': { + 'dynamicModelName1': { + isMissingData: true, + action: 'None' + }, + 'dynamicModelName2': {}, + } + } + } + } + } + } + }; + + let newState = vfModuleReducer(<any>oldState, + <UpdateVFModuleField>{ + type: VfModuleActions.UPDATE_VFMODULE_FEILD, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId', + modelName: 'modelName', + fieldName: newFieldName, + fieldValue: newFieldValue + }); + + let vfModule = newState.serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + + expect(vfModule[newFieldName]).toEqual(newFieldValue); + }); + + test('#DELETE_VFMODULE_FEILD: should update field with some value', () => { + const deleteFieldName = 'deleteFieldName'; + let oldState = { + serviceHierarchy: { + 'serviceModelId': {} }, - serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vfName' : { - vfModules : { - 'modelName' : { + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'modelName': { 'dynamicModelName1': { - isMissingData : true + isMissingData: true, + [deleteFieldName]: true, + action: 'None' }, 'dynamicModelName2': {}, } @@ -123,192 +168,197 @@ describe('vfModuleReducer', () => { } } } - }}, - <CreateVFModuleInstanceAction>{ - type: VfModuleActions.UPDATE_VF_MODULE, - vfId : 'modelName', - vfInstance : new VfModuleInstance(), - vnfStoreKey : 'vfName', - dynamicModelName : 'dynamicModelName1', - serviceUuid : 'serviceModelId', - index : 1 - }).serviceInstance['serviceModelId'].vnfs['vfName'].vfModules; + } + }; + let newState = vfModuleReducer(<any>oldState, + <DeleteVFModuleField>{ + type: VfModuleActions.DELETE_VFMODULE_FEILD, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId', + modelName: 'modelName', + deleteFieldName: deleteFieldName, + }); - let firstVfModuleName = Object.keys(vfModule)[0]; - expect(vfModule[firstVfModuleName]).toBeDefined(); - expect(vfModule[firstVfModuleName].isMissingData).toBeFalsy(); - }); + let vfModule = newState.serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + expect(vfModule[deleteFieldName]).toBeUndefined(); +}); - test('#UPDATE_VFMODULE_POSITION: should update position', ()=>{ - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} - }, - serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vfName' : { - vfModules : { - 'modelName' : { - 'dynamicModelName': { - isMissingData : true - } +test('#UPDATE_VFMODULE_POSITION: should update position', () => { + let vfModule = vfModuleReducer(<any>{ + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vfName': { + vfModules: { + 'modelName': { + 'dynamicModelName': { + isMissingData: true } } } } } - }}, - <UpdateVFModluePosition>{ - type: VfModuleActions.UPDATE_VFMODULE_POSITION, - node: { - position : 1, - dynamicModelName : "dynamicModelName", - modelName : "modelName" - }, - instanceId : "serviceModelId", - vnfStoreKey : "vfName" + } + } + }, + <UpdateVFModluePosition>{ + type: VfModuleActions.UPDATE_VFMODULE_POSITION, + node: { + position: 1, + dynamicModelName: "dynamicModelName", + modelName: "modelName" + }, + instanceId: "serviceModelId", + vnfStoreKey: "vfName" - }).serviceInstance['serviceModelId'].vnfs['vfName'].vfModules["modelName"]["dynamicModelName"]; - - expect(vfModule.position).toEqual(1); - }); + }).serviceInstance['serviceModelId'].vnfs['vfName'].vfModules["modelName"]["dynamicModelName"]; + expect(vfModule.position).toEqual(1); +}); - test('#DELETE_ACTION_VF_MODULE_INSTANCE', ()=>{ - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} - }, - serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vnfStoreKey' : { - vfModules : { - 'modelName' : { - 'dynamicModelName1': { - isMissingData : true, - action : 'None' - }, - 'dynamicModelName2': {}, - } +test('#DELETE_ACTION_VF_MODULE_INSTANCE', () => { + let vfModule = vfModuleReducer(<any>{ + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'modelName': { + 'dynamicModelName1': { + isMissingData: true, + action: 'None' + }, + 'dynamicModelName2': {}, } } } } - }}, - <DeleteActionVfModuleInstanceAction>{ - type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE, - dynamicModelName: 'dynamicModelName1', - vnfStoreKey : 'vnfStoreKey', - serviceId: 'serviceModelId' - }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + } + } + }, + <DeleteActionVfModuleInstanceAction>{ + type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId' + }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; - console.log(vfModule.action); - expect(vfModule).toBeDefined(); - expect(vfModule.isMissingData).toBeTruthy(); - expect(vfModule.action).toEqual(ServiceInstanceActions.None_Delete); - }); + console.log(vfModule.action); + expect(vfModule).toBeDefined(); + expect(vfModule.isMissingData).toBeTruthy(); + expect(vfModule.action).toEqual(ServiceInstanceActions.None_Delete); +}); - test('#UNDO_DELETE_ACTION_VF_MODULE_INSTANCE', ()=>{ - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} - }, - serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vnfStoreKey' : { - vfModules : { - 'modelName' : { - 'dynamicModelName1': { - isMissingData : true, - action : 'None_Delete' - }, - 'dynamicModelName2': {}, - } +test('#UNDO_DELETE_ACTION_VF_MODULE_INSTANCE', () => { + let vfModule = vfModuleReducer(<any>{ + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'modelName': { + 'dynamicModelName1': { + isMissingData: true, + action: 'None_Delete' + }, + 'dynamicModelName2': {}, } } } } - }}, - <UndoDeleteActionVfModuleInstanceAction>{ - type: VfModuleActions.UNDO_DELETE_ACTION_VF_MODULE_INSTANCE, - dynamicModelName: 'dynamicModelName1', - vnfStoreKey : 'vnfStoreKey', - serviceId: 'serviceModelId' - }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + } + } + }, + <UndoDeleteActionVfModuleInstanceAction>{ + type: VfModuleActions.UNDO_DELETE_ACTION_VF_MODULE_INSTANCE, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId' + }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; - console.log(vfModule.action); - expect(vfModule).toBeDefined(); - expect(vfModule.action).toEqual(ServiceInstanceActions.None); - }); + console.log(vfModule.action); + expect(vfModule).toBeDefined(); + expect(vfModule.action).toEqual(ServiceInstanceActions.None); +}); - test('#UPGRADE_VFMODULE', ()=>{ - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} - }, - serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vnfStoreKey' : { - vfModules : { - 'modelName' : { - 'dynamicModelName1': { - isMissingData : true, - action : 'None' - }, - 'dynamicModelName2': {}, - } +test('#UPGRADE_VFMODULE', () => { + let vfModule = vfModuleReducer(<any>{ + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'modelName': { + 'dynamicModelName1': { + isMissingData: true, + action: 'None' + }, + 'dynamicModelName2': {}, } } } } - }}, - <UpgradeVfModuleInstanceAction>{ - type: VfModuleActions.UPGRADE_VFMODULE, - dynamicModelName: 'dynamicModelName1', - vnfStoreKey : 'vnfStoreKey', - serviceId: 'serviceModelId', - modelName: 'modelName' - }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + } + } + }, + <UpgradeVfModuleInstanceAction>{ + type: VfModuleActions.UPGRADE_VFMODULE, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId', + modelName: 'modelName' + }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; - expect(vfModule.action).toEqual(ServiceInstanceActions.None_Upgrade); - }); + expect(vfModule.action).toEqual(ServiceInstanceActions.None_Upgrade); +}); - test('#UNDO_UPGRADE_VFMODULE', ()=>{ - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} - }, - serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vnfStoreKey' : { - vfModules : { - 'modelName' : { - 'dynamicModelName1': { - isMissingData : true, - action : 'None_Upgrade' - }, - 'dynamicModelName2': {}, - } +test('#UNDO_UPGRADE_VFMODULE', () => { + let vfModule = vfModuleReducer(<any>{ + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'modelName': { + 'dynamicModelName1': { + isMissingData: true, + action: 'None_Upgrade' + }, + 'dynamicModelName2': {}, } } } } - }}, - <UpgradeVfModuleInstanceAction>{ - type: VfModuleActions.UNDO_UPGRADE_VFMODULE_ACTION, - dynamicModelName: 'dynamicModelName1', - vnfStoreKey : 'vnfStoreKey', - serviceId: 'serviceModelId', - modelName: 'modelName' - }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; - - expect(vfModule.action).toEqual(ServiceInstanceActions.None); - }); + } + } + }, + <UpgradeVfModuleInstanceAction>{ + type: VfModuleActions.UNDO_UPGRADE_VFMODULE_ACTION, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId', + modelName: 'modelName' + }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + expect(vfModule.action).toEqual(ServiceInstanceActions.None); }); + +}) +; diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts index a7aadba41..1bb2b15fd 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts @@ -1,10 +1,10 @@ import {Action} from "redux"; import * as _ from "lodash"; import { - CreateVFModuleInstanceAction, DeleteActionVfModuleInstanceAction, - DeleteVfModuleInstanceAction, UndoDeleteActionVfModuleInstanceAction, UpdateVFModluePosition, + CreateVFModuleInstanceAction, DeleteActionVfModuleInstanceAction, DeleteVFModuleField, + DeleteVfModuleInstanceAction, UndoDeleteActionVfModuleInstanceAction, UpdateVFModluePosition, UpdateVFModuleField, UpdateVFModuleInstanceAction, UpgradeVfModuleInstanceAction, - VfModuleActions + VfModuleActions, } from "./vfModule.actions"; import {ServiceInstance} from "../../../models/serviceInstance"; import {VfModuleMap} from "../../../models/vfModulesMap"; @@ -145,6 +145,26 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS } return clonedState; } + case VfModuleActions.UPDATE_VFMODULE_FEILD : { + let clonedState = _.cloneDeep(state); + let updateFieldAction = <UpdateVFModuleField> action; + + clonedState.serviceInstance[updateFieldAction.serviceId] + .vnfs[updateFieldAction.vnfStoreKey] + .vfModules[updateFieldAction.modelName][updateFieldAction.dynamicModelName][updateFieldAction.fieldName] = updateFieldAction.fieldValue; + + return clonedState; + } + case VfModuleActions.DELETE_VFMODULE_FEILD : { + let clonedState = _.cloneDeep(state); + let deleteAction = <DeleteVFModuleField> action; + + delete clonedState.serviceInstance[deleteAction.serviceId] + .vnfs[deleteAction.vnfStoreKey] + .vfModules[deleteAction.modelName][deleteAction.dynamicModelName][deleteAction.deleteFieldName]; + + return clonedState; + } } } |