aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2018-08-29 17:01:32 +0300
committerIttay Stern <ittay.stern@att.com>2019-02-18 18:35:30 +0200
commit6f900cc45d7dd7f97430812b86b5c1d1693c8ae3 (patch)
tree936005c364dc5a7264d6304d4777c3d83494db22 /vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember
parent67d99f816cc583643c35193197594cf78d8ce60a (diff)
merge from ecomp a88f0072 - Modern UI
Issue-ID: VID-378 Change-Id: Ibcb23dd27f550cf32ce2fe0239f0f496ae014ff6 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember')
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.actions.ts68
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.spec.ts153
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.ts58
3 files changed, 279 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.actions.ts
new file mode 100644
index 000000000..faa7a52d3
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.actions.ts
@@ -0,0 +1,68 @@
+import {Action, ActionCreator} from "redux";
+
+export enum RelatedVnfActions {
+ CREATE_RELATED_VNF_MEMBER_INSTANCE = "CREATE_RELATED_VNF_MEMBER_INSTANCE",
+ REMOVE_RELATED_VNF_MEMBER_INSTANCE = "REMOVE_RELATED_VNF_MEMBER_INSTANCE",
+ DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE = "DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE",
+ UNDO_DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE = "UNDO_DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE"
+}
+
+export interface RemoveRelatedVnfMemebrInstance extends Action {
+ vnfGroupStoreKey: string;
+ relatedVnfMemeberStoreKey: string;
+ serviceId?: string;
+}
+
+export interface DeleteRelatedVnfMemebrInstanceAction extends Action {
+ vnfGroupStoreKey: string;
+ relatedVnfMemeberStoreKey: string;
+ serviceId?: string;
+}
+
+export interface DeleteActionRelatedVnfMemeberInstanceAction extends Action {
+ vnfGroupStoreKey: string;
+ relatedVnfMemeberStoreKey: string;
+ serviceId?: string;
+}
+
+export interface UndoDeleteActionRelatedVnfMemeberInstanceAction extends Action {
+ vnfGroupStoreKey: string;
+ relatedVnfMemeberStoreKey: string;
+ serviceId?: string;
+}
+
+export interface CreateRelatedVnfMemeberInstanceAction extends Action {
+ relatedVnfMember: any;
+ vnfGroupStoreKey: string;
+ serviceId?: string;
+}
+
+
+export const removeRelatedVnfMemberInstance: ActionCreator<RemoveRelatedVnfMemebrInstance> = (vnfGroupStoreKey, relatedVnfMemeberStoreKey, serviceId) => ({
+ type: RelatedVnfActions.REMOVE_RELATED_VNF_MEMBER_INSTANCE,
+ vnfGroupStoreKey: vnfGroupStoreKey,
+ relatedVnfMemeberStoreKey: relatedVnfMemeberStoreKey,
+ serviceId: serviceId
+});
+
+export const deleteActionRelatedVnfMemberInstance: ActionCreator<DeleteActionRelatedVnfMemeberInstanceAction> = (vnfGroupStoreKey, relatedVnfMemeberStoreKey, serviceId) => ({
+ type: RelatedVnfActions.DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE,
+ vnfGroupStoreKey: vnfGroupStoreKey,
+ relatedVnfMemeberStoreKey: relatedVnfMemeberStoreKey,
+ serviceId: serviceId
+});
+
+export const undoDeleteActionRelatedVnfMemberInstance: ActionCreator<UndoDeleteActionRelatedVnfMemeberInstanceAction> = (vnfGroupStoreKey, relatedVnfMemeberStoreKey, serviceId) => ({
+ type: RelatedVnfActions.UNDO_DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE,
+ vnfGroupStoreKey: vnfGroupStoreKey,
+ relatedVnfMemeberStoreKey: relatedVnfMemeberStoreKey,
+ serviceId: serviceId
+});
+
+
+export const createRelatedVnfMemberInstance: ActionCreator<CreateRelatedVnfMemeberInstanceAction> = (vnfGroupStoreKey, serviceId, relatedVnfMember) => ({
+ type: RelatedVnfActions.CREATE_RELATED_VNF_MEMBER_INSTANCE,
+ relatedVnfMember: relatedVnfMember,
+ vnfGroupStoreKey: vnfGroupStoreKey,
+ serviceId: serviceId
+});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.spec.ts
new file mode 100644
index 000000000..347957480
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.spec.ts
@@ -0,0 +1,153 @@
+import {relatedVnfMemeberReducer} from "./relatedVnfMember.reducers";
+import {
+ CreateRelatedVnfMemeberInstanceAction,
+ DeleteActionRelatedVnfMemeberInstanceAction,
+ RelatedVnfActions,
+ UndoDeleteActionRelatedVnfMemeberInstanceAction
+} from "./relatedVnfMember.actions";
+import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+
+
+describe('relatedVnfMemberReducer', () => {
+
+ test('#DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE should change action to delete',() => {
+ const serviceUuid: string = 'serviceUuid';
+ const actionName: ServiceInstanceActions = ServiceInstanceActions.None;
+
+ let service = relatedVnfMemeberReducer(<any>{
+ serviceInstance: {
+ 'serviceUuid': {
+ 'vnfGroups' : {
+ 'vnfGroupStoreKey' : {
+ 'vnfs' : {
+ 'vnfStoreKey1' : {
+ 'action' : actionName
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }, <DeleteActionRelatedVnfMemeberInstanceAction>{
+ type: RelatedVnfActions.DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE,
+ vnfGroupStoreKey: 'vnfGroupStoreKey',
+ relatedVnfMemeberStoreKey : 'vnfStoreKey1',
+ serviceId : 'serviceUuid'
+ });
+
+ expect(service.serviceInstance[serviceUuid].vnfGroups['vnfGroupStoreKey']['vnfs']['vnfStoreKey1'].action).toEqual('None_Delete');
+ });
+
+ test('#UNDO_DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE should undo change action to delete', () => {
+ const serviceUuid: string = 'serviceUuid';
+ const actionName: ServiceInstanceActions = ServiceInstanceActions.None_Delete;
+
+ let service = relatedVnfMemeberReducer(<any>{
+ serviceInstance: {
+ 'serviceUuid': {
+ 'vnfGroups' : {
+ 'vnfGroupStoreKey' : {
+ 'vnfs' : {
+ 'vnfStoreKey1' : {
+ 'action' : actionName
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }, <UndoDeleteActionRelatedVnfMemeberInstanceAction>{
+ type: RelatedVnfActions.UNDO_DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE,
+ vnfGroupStoreKey: 'vnfGroupStoreKey',
+ relatedVnfMemeberStoreKey : 'vnfStoreKey1',
+ serviceId : 'serviceUuid'
+ });
+
+ expect(service.serviceInstance[serviceUuid].vnfGroups['vnfGroupStoreKey']['vnfs']['vnfStoreKey1'].action).toEqual('None');
+ });
+
+ test('#REMOVE_RELATED_VNF_MEMBER_INSTANCE should remove instance', () => {
+ const serviceUuid: string = 'serviceUuid';
+ const actionName: ServiceInstanceActions = ServiceInstanceActions.None_Delete;
+
+ let service = relatedVnfMemeberReducer(<any>{
+ serviceInstance: {
+ 'serviceUuid': {
+ 'vnfGroups' : {
+ 'vnfGroupStoreKey' : {
+ 'vnfs' : {
+ 'vnfStoreKey1' : {
+ 'action' : actionName
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }, <UndoDeleteActionRelatedVnfMemeberInstanceAction>{
+ type: RelatedVnfActions.UNDO_DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE,
+ vnfGroupStoreKey: 'vnfGroupStoreKey',
+ relatedVnfMemeberStoreKey : 'vnfStoreKey1',
+ serviceId : 'serviceUuid'
+ });
+
+ expect(service.serviceInstance[serviceUuid].vnfGroups['vnfGroupStoreKey']['vnfs']['vnfStoreKey1'].action).toEqual('None');
+ });
+
+ test('#CREATE_RELATED_VNF_MEMBER_INSTANCE should add new relatedVNF instance', () => {
+ const serviceUuid: string = 'serviceUuid';
+ const actionName: ServiceInstanceActions = ServiceInstanceActions.None_Delete;
+ let relatedVnfMember = {
+ "instanceName":"VNF1_INSTANCE_NAME",
+ "instanceId":"VNF1_INSTANCE_ID",
+ "orchStatus":null,
+ "productFamilyId":null,
+ "lcpCloudRegionId":"mtn23b",
+ "tenantId":"3e9a20a3e89e45f884e09df0cc2d2d2a",
+ "tenantName":"APPC-24595-T-IST-02C",
+ "modelInfo":{
+ "modelInvariantId":"vnf-instance-model-invariant-id",
+ "modelVersionId":"7a6ee536-f052-46fa-aa7e-2fca9d674c44",
+ "modelVersion":"2.0",
+ "modelName":"vf_vEPDG",
+ "modelType":"vnf"
+ },
+ "instanceType":"VNF1_INSTANCE_TYPE",
+ "provStatus":null,
+ "inMaint":false,
+ "uuid":"7a6ee536-f052-46fa-aa7e-2fca9d674c44",
+ "originalName":null,
+ "legacyRegion":null,
+ "lineOfBusiness":null,
+ "platformName":null,
+ "trackById":"7a6ee536-f052-46fa-aa7e-2fca9d674c44:002",
+ "serviceInstanceId":"service-instance-id1",
+ "serviceInstanceName":"service-instance-name"
+ };
+
+ let service = relatedVnfMemeberReducer(<any>{
+ serviceInstance: {
+ 'serviceUuid': {
+ 'vnfGroups' : {
+ 'vnfGroupStoreKey' : { }
+ }
+ }
+ }
+ }, <CreateRelatedVnfMemeberInstanceAction>{
+ type: RelatedVnfActions.CREATE_RELATED_VNF_MEMBER_INSTANCE,
+ relatedVnfMember: relatedVnfMember,
+ vnfGroupStoreKey: 'vnfGroupStoreKey',
+ serviceId: serviceUuid
+ });
+
+ expect(service.serviceInstance[serviceUuid].vnfGroups['vnfGroupStoreKey']['vnfs']['VNF1_INSTANCE_ID'].action).toEqual('Create');
+ expect(service.serviceInstance[serviceUuid].vnfGroups['vnfGroupStoreKey']['vnfs']['VNF1_INSTANCE_ID'].instanceId).toEqual('VNF1_INSTANCE_ID');
+ });
+
+});
+
+
+
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.ts
new file mode 100644
index 000000000..250f934be
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.ts
@@ -0,0 +1,58 @@
+import {Action} from "redux";
+import * as _ from "lodash";
+import {ServiceState} from "../main.reducer";
+import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+import {
+ CreateRelatedVnfMemeberInstanceAction,
+ DeleteActionRelatedVnfMemeberInstanceAction, DeleteRelatedVnfMemebrInstanceAction,
+ RelatedVnfActions,
+ UndoDeleteActionRelatedVnfMemeberInstanceAction
+} from "./relatedVnfMember.actions";
+
+export function relatedVnfMemeberReducer(state: ServiceState, action: Action): ServiceState {
+ switch (action.type) {
+
+ case RelatedVnfActions.DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE : {
+ let newState = _.cloneDeep(state);
+ let relatedVnfMember = newState.serviceInstance[(<DeleteActionRelatedVnfMemeberInstanceAction>action).serviceId].vnfGroups[(<DeleteActionRelatedVnfMemeberInstanceAction>action).vnfGroupStoreKey]['vnfs'][(<DeleteActionRelatedVnfMemeberInstanceAction>action).relatedVnfMemeberStoreKey];
+ let oldAction = relatedVnfMember.action;
+ if(oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState;
+ newState.serviceInstance[(<DeleteActionRelatedVnfMemeberInstanceAction>action).serviceId].vnfGroups[(<DeleteActionRelatedVnfMemeberInstanceAction>action).vnfGroupStoreKey]['vnfs'][(<DeleteActionRelatedVnfMemeberInstanceAction>action).relatedVnfMemeberStoreKey].action = (oldAction + '_Delete') as ServiceInstanceActions;
+ return newState;
+ }
+
+ case RelatedVnfActions.UNDO_DELETE_ACTION_RELATED_VNF_MEMBER_INSTANCE : {
+ let newState = _.cloneDeep(state);
+ let relatedVnfMember = newState.serviceInstance[(<UndoDeleteActionRelatedVnfMemeberInstanceAction>action).serviceId].vnfGroups[(<UndoDeleteActionRelatedVnfMemeberInstanceAction>action).vnfGroupStoreKey]['vnfs'][(<UndoDeleteActionRelatedVnfMemeberInstanceAction>action).relatedVnfMemeberStoreKey];
+ let oldState = relatedVnfMember.action;
+ newState.serviceInstance[(<DeleteActionRelatedVnfMemeberInstanceAction>action).serviceId].vnfGroups[(<DeleteActionRelatedVnfMemeberInstanceAction>action).vnfGroupStoreKey]['vnfs'][(<DeleteActionRelatedVnfMemeberInstanceAction>action).relatedVnfMemeberStoreKey].action = (oldState.split('_')[0]) as ServiceInstanceActions;
+ return newState;
+ }
+
+ case RelatedVnfActions.REMOVE_RELATED_VNF_MEMBER_INSTANCE : {
+ let newState = _.cloneDeep(state);
+ delete newState.serviceInstance[(<DeleteRelatedVnfMemebrInstanceAction>action).serviceId].vnfGroups[(<DeleteRelatedVnfMemebrInstanceAction>action).vnfGroupStoreKey]['vnfs'][(<DeleteRelatedVnfMemebrInstanceAction>action).relatedVnfMemeberStoreKey];
+ return newState;
+ }
+
+ case RelatedVnfActions.CREATE_RELATED_VNF_MEMBER_INSTANCE : {
+ let newState = _.cloneDeep(state);
+ let relatedVnfMember = (<CreateRelatedVnfMemeberInstanceAction>action).relatedVnfMember;
+ relatedVnfMember['action'] = 'Create';
+ relatedVnfMember['vnfStoreKey'] = relatedVnfMember.instanceId;
+ relatedVnfMember['trackById'] = relatedVnfMember.instanceId;
+ relatedVnfMember['instanceName'] = relatedVnfMember.instanceName;
+ if(_.isNil(newState.serviceInstance[(<CreateRelatedVnfMemeberInstanceAction>action).serviceId].vnfGroups[(<CreateRelatedVnfMemeberInstanceAction>action).vnfGroupStoreKey]['vnfs'])){
+ newState.serviceInstance[(<CreateRelatedVnfMemeberInstanceAction>action).serviceId].vnfGroups[(<CreateRelatedVnfMemeberInstanceAction>action).vnfGroupStoreKey]['vnfs'] = {};
+ }
+ newState.serviceInstance[(<CreateRelatedVnfMemeberInstanceAction>action).serviceId].vnfGroups[(<CreateRelatedVnfMemeberInstanceAction>action).vnfGroupStoreKey]['vnfs'][(<CreateRelatedVnfMemeberInstanceAction>action).relatedVnfMember['instanceId']] = relatedVnfMember;
+ newState.serviceInstance[(<CreateRelatedVnfMemeberInstanceAction>action).serviceId].isDirty = true;
+ return newState;
+ }
+ }
+}
+
+
+
+
+