diff options
3 files changed, 60 insertions, 74 deletions
diff --git a/vid-webpack-master/src/app/shared/models/vfModuleInstance.ts b/vid-webpack-master/src/app/shared/models/vfModuleInstance.ts index 566c913ae..ed5a07212 100644 --- a/vid-webpack-master/src/app/shared/models/vfModuleInstance.ts +++ b/vid-webpack-master/src/app/shared/models/vfModuleInstance.ts @@ -5,6 +5,8 @@ export class VfModuleInstance extends ChildNodeInstance{ instanceParams: { [key: string] : string; }; position: any; statusMessage?: string; + tenantId? :string; + lcpCloudRegionId?: string; constructor() { super(); 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 91b749e0d..9ef440fc5 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 @@ -106,28 +106,7 @@ describe('vfModuleReducer', () => { 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 oldState = getReduxState(); let newState = vfModuleReducer(<any>oldState, <UpdateVFModuleField>{ @@ -222,40 +201,24 @@ test('#UPDATE_VFMODULE_POSITION: should update position', () => { }); 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']; + let vfModule = vfModuleReducer(<any>getReduxState(), getDeleteActionVfModule()) + .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; expect(vfModule).toBeDefined(); expect(vfModule.isMissingData).toBeTruthy(); expect(vfModule.action).toEqual(ServiceInstanceActions.None_Delete); }); +test('#DELETE_ACTION_VF_MODULE_INSTANCE set tenantId and lcpCloudRegion to VFM', () => { + let vfModule = vfModuleReducer(<any>getReduxState(), getDeleteActionVfModule()) + .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + + expect(vfModule).toBeDefined(); + expect(vfModule.tenantId).toEqual('tenantId'); + expect(vfModule.lcpCloudRegionId).toEqual('lcpCloudRegionId'); + +}); + test('#UNDO_DELETE_ACTION_VF_MODULE_INSTANCE', () => { let vfModule = vfModuleReducer(<any>{ serviceHierarchy: { @@ -291,28 +254,7 @@ test('#UNDO_DELETE_ACTION_VF_MODULE_INSTANCE', () => { }); test('#UPGRADE_VFMODULE', () => { - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy: { - 'serviceModelId': {} - }, - serviceInstance: { - 'serviceModelId': { - vnfs: { - 'vnfStoreKey': { - vfModules: { - 'modelName': { - 'dynamicModelName1': { - isMissingData: true, - action: 'None' - }, - 'dynamicModelName2': {}, - } - } - } - } - } - } - }, + let vfModule = vfModuleReducer(<any>getReduxState(), <UpgradeVfModuleInstanceAction>{ type: VfModuleActions.UPGRADE_VFMODULE, dynamicModelName: 'dynamicModelName1', @@ -358,5 +300,39 @@ test('#UNDO_UPGRADE_VFMODULE', () => { expect(vfModule.action).toEqual(ServiceInstanceActions.None); }); -}) -; +function getReduxState() { + return { + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + tenantId: 'tenantId', + lcpCloudRegionId: 'lcpCloudRegionId', + vfModules: { + 'modelName': { + 'dynamicModelName1': { + isMissingData: true, + action: 'None', + }, + 'dynamicModelName2': {}, + } + } + } + } + } + } + } +} + +function getDeleteActionVfModule() { + return <DeleteActionVfModuleInstanceAction>{ + type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId' + } +} +}); 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 2e91f8771..1ab275e05 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 @@ -79,6 +79,7 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS let oldAction = newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules[key][firstKey].action; if(oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState; newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules[key][firstKey].action = (oldAction + '_Delete') as ServiceInstanceActions; + setLcpCloudRegionIdAndTenantIdFromVnf(newState, (<DeleteActionVfModuleInstanceAction>action).serviceId, (<DeleteActionVfModuleInstanceAction>action).vnfStoreKey, key, firstKey); updateIsMissingDataOnDeleteVFModule(newState, (<UndoDeleteActionVfModuleInstanceAction>action).serviceId, (<UndoDeleteActionVfModuleInstanceAction>action).vnfStoreKey, key); return newState; } @@ -177,6 +178,13 @@ const updateIsMissingDataOnDeleteVFModule = (state: any, serviceModelId: string, }); }; +const setLcpCloudRegionIdAndTenantIdFromVnf = (state: any, serviceModelId: string, vnfStoreKey: string, key: string, firstKey: string) :void => { + let tenantId = state.serviceInstance[serviceModelId].vnfs[vnfStoreKey].tenantId; + let lcpCloudRegion = state.serviceInstance[serviceModelId].vnfs[vnfStoreKey].lcpCloudRegionId; + + state.serviceInstance[serviceModelId].vnfs[vnfStoreKey].vfModules[key][firstKey].tenantId = tenantId; + state.serviceInstance[serviceModelId].vnfs[vnfStoreKey].vfModules[key][firstKey].lcpCloudRegionId = lcpCloudRegion; +} const updateUniqueNames = (oldName : string, newName : string, serviceInstance : ServiceInstance) : void => { let existingNames = serviceInstance.existingNames; |