aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src')
-rw-r--r--vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts2
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts6
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts51
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts21
4 files changed, 45 insertions, 35 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 f442e1504..b1a67a5bc 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
@@ -351,7 +351,7 @@ export class VFModuleModelInfo implements ILevelNodeInfo {
},
delete: {
method: (node, serviceModelId) => {
- this._store.dispatch(deleteActionVfModuleInstance(node.data.dynamicModelName, node.parent.data.vnfStoreKey, serviceModelId))
+ this._store.dispatch(deleteActionVfModuleInstance(node.data.dynamicModelName, node.parent.data.vnfStoreKey, serviceModelId, node.data.modelName))
},
visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId),
enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId)
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 1b80452cb..ac26ba936 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
@@ -49,6 +49,7 @@ export interface DeleteActionVfModuleInstanceAction extends Action {
dynamicModelName: string;
vnfStoreKey : string;
serviceId?: string;
+ vfModuleModelName: string;
}
export interface UpgradeVfModuleInstanceAction extends Action {
@@ -115,11 +116,12 @@ export const updateVFModuleInstance: ActionCreator<UpdateVFModuleInstanceAction>
vnfStoreKey : vnfStoreKey
});
-export const deleteActionVfModuleInstance: ActionCreator<DeleteActionVfModuleInstanceAction> = (dynamicModelName, vnfStoreKey, serviceId) => ({
+export const deleteActionVfModuleInstance: ActionCreator<DeleteActionVfModuleInstanceAction> = (dynamicModelName, vnfStoreKey, serviceId, vfModuleModelName) => ({
type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE,
dynamicModelName: dynamicModelName,
vnfStoreKey : vnfStoreKey,
- serviceId: serviceId
+ serviceId: serviceId,
+ vfModuleModelName
});
export const undoDeleteVfModuleInstance: ActionCreator<UndoDeleteActionVfModuleInstanceAction> = (dynamicModelName, vnfStoreKey, serviceId) => ({
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 9ef440fc5..9bbcf46f7 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,15 +1,18 @@
import {
CreateVFModuleInstanceAction,
- DeleteActionVfModuleInstanceAction, DeleteVFModuleField,
+ DeleteActionVfModuleInstanceAction,
+ DeleteVFModuleField,
DeleteVfModuleInstanceAction,
UndoDeleteActionVfModuleInstanceAction,
- UpdateVFModluePosition, UpdateVFModuleField,
+ UpdateVFModluePosition,
+ UpdateVFModuleField,
UpgradeVfModuleInstanceAction,
VfModuleActions
} from "./vfModule.actions";
import {vfModuleReducer} from "./vfModule.reducers";
import {VfModuleInstance} from "../../../models/vfModuleInstance";
import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+import each from "jest-each";
describe('vfModuleReducer', () => {
@@ -114,12 +117,12 @@ describe('vfModuleReducer', () => {
dynamicModelName: 'dynamicModelName1',
vnfStoreKey: 'vnfStoreKey',
serviceId: 'serviceModelId',
- modelName: 'modelName',
+ modelName: 'vfModuleModelName',
fieldName: newFieldName,
fieldValue: newFieldValue
});
- let vfModule = newState.serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1'];
+ let vfModule = newState.serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['vfModuleModelName']['dynamicModelName1'];
expect(vfModule[newFieldName]).toEqual(newFieldValue);
});
@@ -200,18 +203,22 @@ test('#UPDATE_VFMODULE_POSITION: should update position', () => {
expect(vfModule.position).toEqual(1);
});
-test('#DELETE_ACTION_VF_MODULE_INSTANCE', () => {
- let vfModule = vfModuleReducer(<any>getReduxState(), getDeleteActionVfModule())
- .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1'];
+ each([
+ ['for the first vfModule', 'dynamicModelName1', true],
+ ['for the second vfModule', 'dynamicModelName2', true],
+ ]).
+test('#DELETE_ACTION_VF_MODULE_INSTANCE %s', (description, dynamicModelName: string, isMissingData: boolean) => {
+ let vfModule = vfModuleReducer(<any>getReduxState(), getDeleteActionVfModule(dynamicModelName))
+ .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['vfModuleModelName'][dynamicModelName];
- expect(vfModule).toBeDefined();
- expect(vfModule.isMissingData).toBeTruthy();
- expect(vfModule.action).toEqual(ServiceInstanceActions.None_Delete);
-});
+ 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'];
+ let vfModule = vfModuleReducer(<any>getReduxState(), getDeleteActionVfModule('dynamicModelName1'))
+ .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['vfModuleModelName']['dynamicModelName1'];
expect(vfModule).toBeDefined();
expect(vfModule.tenantId).toEqual('tenantId');
@@ -260,8 +267,8 @@ test('#UPGRADE_VFMODULE', () => {
dynamicModelName: 'dynamicModelName1',
vnfStoreKey: 'vnfStoreKey',
serviceId: 'serviceModelId',
- modelName: 'modelName'
- }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1'];
+ modelName: 'vfModuleModelName'
+ }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['vfModuleModelName']['dynamicModelName1'];
expect(vfModule.action).toEqual(ServiceInstanceActions.None_Upgrade);
});
@@ -312,12 +319,15 @@ function getReduxState() {
tenantId: 'tenantId',
lcpCloudRegionId: 'lcpCloudRegionId',
vfModules: {
- 'modelName': {
+ 'vfModuleModelName': {
'dynamicModelName1': {
isMissingData: true,
action: 'None',
},
- 'dynamicModelName2': {},
+ 'dynamicModelName2': {
+ action: 'None',
+ isMissingData: true,
+ },
}
}
}
@@ -327,12 +337,13 @@ function getReduxState() {
}
}
-function getDeleteActionVfModule() {
+function getDeleteActionVfModule(dynamicModelName?: string) {
return <DeleteActionVfModuleInstanceAction>{
type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE,
- dynamicModelName: 'dynamicModelName1',
+ dynamicModelName: dynamicModelName,
vnfStoreKey: 'vnfStoreKey',
- serviceId: 'serviceModelId'
+ serviceId: 'serviceModelId',
+ vfModuleModelName: 'vfModuleModelName',
}
}
});
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 1ab275e05..9c624b055 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
@@ -70,20 +70,17 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS
return Object.assign({}, state);
}
case VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE : {
+ let deleteAction = (<DeleteActionVfModuleInstanceAction>action);
let newState = _.cloneDeep(state);
- let vfModules = newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules;
+ let vfModule = newState.serviceInstance[deleteAction.serviceId].vnfs[deleteAction.vnfStoreKey]
+ .vfModules[deleteAction.vfModuleModelName][deleteAction.dynamicModelName];
+ let oldAction = vfModule.action;
+ if (oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState;
+ newState.serviceInstance[deleteAction.serviceId].vnfs[deleteAction.vnfStoreKey]
+ .vfModules[deleteAction.vfModuleModelName][deleteAction.dynamicModelName].action = (oldAction + '_Delete') as ServiceInstanceActions;
+ setLcpCloudRegionIdAndTenantIdFromVnf(newState, deleteAction.serviceId, deleteAction.vnfStoreKey, deleteAction.vfModuleModelName, deleteAction.dynamicModelName);
+ updateIsMissingDataOnDeleteVFModule(newState, (<UndoDeleteActionVfModuleInstanceAction>action).serviceId, (<UndoDeleteActionVfModuleInstanceAction>action).vnfStoreKey, deleteAction.vfModuleModelName);
- for(let key in vfModules){
- let firstKey = Object.keys(vfModules[key])[0];
- if(firstKey === (<DeleteActionVfModuleInstanceAction>action).dynamicModelName){
- 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;
- }
- }
return newState;
}
case VfModuleActions.UNDO_DELETE_ACTION_VF_MODULE_INSTANCE : {