diff options
Diffstat (limited to 'vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf')
2 files changed, 233 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.spec.ts new file mode 100644 index 000000000..6c8382808 --- /dev/null +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.spec.ts @@ -0,0 +1,112 @@ +import {ComponentInfoType} from "../../../component-info/component-info-model"; +import {NcfModelInfo} from "./ncf.model.info"; +import {ModelInformationItem} from "../../../../../shared/components/model-information/model-information.component"; +import {NcfTreeNode} from "../../../../../shared/models/ncfTreeNode"; + +describe('NCF Model Info', () => { + + let ncfModel: NcfModelInfo; + + beforeEach(() => { + ncfModel = new NcfModelInfo(null); + }); + + test('ncfModel should be defined', () => { + expect(ncfModel).toBeDefined(); + }); + + test('ncfModel should defined extra details', () => { + expect(ncfModel.name).toEqual('ncfs'); + expect(ncfModel.type).toEqual('NCF'); + expect(ncfModel.childNames).toBeUndefined; + expect(ncfModel.componentInfoType).toEqual(ComponentInfoType.NCF); + }); + + test('createInstanceTreeNode shall create the right ncfTreeNode', () => { + const instance = { + action: "None", + instanceName: "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection", + instanceId: "6b3536cf-3a12-457f-abb5-fa2203e0d923", + instanceType: "L3-NETWORK", + inMaint: false, + uuid: "dd182d7d-6949-4b90-b3cc-5befe400742e", + originalName: "ncm_vlan_ym161f..NetworkCollection..0", + trackById: "6b3536cf-3a12-457f-abb5-fa2203e0d923", + instanceGroupRole: "SUB_INTERFACE", + instanceGroupFunction: "vTSBC Customer Landing Network Collection", + numberOfNetworks: 1 + }; + + const parentModel = { + networksCollection: { + "ncm_vlan_ym161f..NetworkCollection..0": { + uuid: "dd182d7d-6949-4b90-b3cc-5befe400742e", + invariantUuid: "868b109c-9481-4a18-891b-af974db7705a", + name: "ncm_vlan_ym161f..NetworkCollection..0", + version: "1", + networkCollectionProperties: { + networkCollectionFunction: "vTSBC Customer Landing Network Collection", + networkCollectionDescription: "vTSBC Customer Landing Network Collection Desc" + } + } + } + }; + + const expected = { + action: "None", + id: "6b3536cf-3a12-457f-abb5-fa2203e0d923", + inMaint: false, + instanceGroupFunction: "vTSBC Customer Landing Network Collection", + instanceGroupRole: "SUB_INTERFACE", + instanceId: "6b3536cf-3a12-457f-abb5-fa2203e0d923", + instanceName: "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection", + instanceType: "L3-NETWORK", + missingData: false, + modelVersion: "1", + name: "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection", + numberOfNetworks: 1, + storeKey: "6b3536cf-3a12-457f-abb5-fa2203e0d923", + typeName: "NCF" + }; + + const ncfTreeNode: NcfTreeNode = ncfModel.createInstanceTreeNode(instance, {}, parentModel, "6b3536cf-3a12-457f-abb5-fa2203e0d923"); + expect(ncfTreeNode).toMatchObject(expected); + }); + + test('get modelInformation shall return Model version, role, Collection function, Number of networks', () => { + const ncf = { + trackById: "6b3536cf-3a12-457f-abb5-fa2203e0d923", + instanceGroupRole: "SUB_INTERFACE", + instanceGroupFunction: "vTSBC Customer Landing Network Collection", + numberOfNetworks: 1, + modelVersion: "35" + }; + + const actualModelInformationItems = ncfModel.getInfo(null, ncf); + const expected = [ + ModelInformationItem.createInstance('Model version', '35'), + ModelInformationItem.createInstance('Role', 'SUB_INTERFACE'), + ModelInformationItem.createInstance('Collection function', 'vTSBC Customer Landing Network Collection'), + ModelInformationItem.createInstance('Number of networks', 1), + ]; + + expect(actualModelInformationItems).toEqual(expected); + }); + + test('get modelInformation shall return empty array when ncf instance is null', () => { + expect(ncfModel.getInfo(null, null)).toEqual([]); + }); + + test('ncf getMenuAction: delete', ()=>{ + let node = {}; + let serviceModelId = 'serviceModelId'; + let result = ncfModel.getMenuAction(<any>node, serviceModelId); + spyOn(result['delete'], 'method'); + expect(result['delete']).toBeDefined(); + expect(result['delete'].visible()).toBeFalsy(); + expect(result['delete'].enable()).toBeFalsy(); + result['delete']['method'](node, serviceModelId); + expect(result['delete']['method']).toHaveBeenCalledWith(node, serviceModelId); + }); + +}); diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.ts new file mode 100644 index 000000000..4db41c0d1 --- /dev/null +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.ts @@ -0,0 +1,121 @@ +import {ILevelNodeInfo} from "../basic.model.info"; +import {ComponentInfoType} from "../../../component-info/component-info-model"; +import {ITreeNode} from "angular-tree-component/dist/defs/api"; +import {AvailableNodeIcons} from "../../../available-models-tree/available-models-tree.service"; +import {ModelInformationItem} from "../../../../../shared/components/model-information/model-information.component"; +import {Level1Model} from "../../../../../shared/models/nodeModel"; +import {NcfTreeNode} from "../../../../../shared/models/ncfTreeNode"; +import {Level1Instance} from "../../../../../shared/models/level1Instance"; +import {NgRedux} from "@angular-redux/store"; +import {AppState} from "../../../../../shared/store/reducers"; +import { + deleteActionNcfInstance, + undoDeleteActionNcfInstance +} from "../../../../../shared/storeUtil/utils/ncf/ncf.actions"; +import * as _ from 'lodash'; +import {NcfModelInterface} from "../../../../../shared/models/ncfModel"; + +export class NcfModelInfo implements ILevelNodeInfo { + constructor(private _store: NgRedux<AppState>){ + } + + name: string = 'ncfs'; + type: string = 'NCF'; + typeName: string = 'NCF'; + + childNames: string[] = []; + componentInfoType = ComponentInfoType.NCF; + + isEcompGeneratedNaming(currentModel): boolean { + return false; + } + + updateDynamicInputsDataFromModel = (currentModel): any => []; + + getModel = (modelId: string, instance: any, serviceHierarchy): any => { + return new Level1Model(); + }; + + + createInstanceTreeNode = (instance: Level1Instance, model: Level1Model, parentModel, storeKey: string): NcfTreeNode => { + let modelVersion: string = null; + if (parentModel.networksCollection && instance.originalName) { + const ncfRealModel: NcfModelInterface = parentModel.networksCollection[instance.originalName]; + if (ncfRealModel) { + modelVersion = ncfRealModel.version; + } + } + + let node = new NcfTreeNode(instance, model, storeKey, modelVersion); + node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.typeName = this.typeName; + return node; + }; + + + getNextLevelObject = (): any => { + return null; + }; + + getTooltip = (): string => 'NCF'; + + getType = (): string => 'NCF'; + + hasMissingData(instance, dynamicInputs: any, isEcompGeneratedNaming: boolean): boolean { + return false; + } + + onClickAdd(node, serviceModelId: string): void { + + } + + getNodeCount(node: ITreeNode, serviceModelId: string): number { + return 0; + } + + showNodeIcons(node: ITreeNode, serviceModelId: string): AvailableNodeIcons { + return null; + } + + getMenuAction(node: ITreeNode, serviceModelId: string): { [methodName: string]: { method: Function, visible: Function, enable: Function } } { + return <any>{ + delete: { + method: (node, serviceModelId) => { + this._store.dispatch(deleteActionNcfInstance(node.data.parent.collectionResourceStoreKey, node.data.storeKey, serviceModelId)); + }, + visible: (node) => false, + enable: (node) => false + }, + undoDelete: { + method: (node, serviceModelId) => { + this._store.dispatch(undoDeleteActionNcfInstance(node.data.parent.collectionResourceStoreKey, node.data.storeKey, serviceModelId)); + }, + visible: (node) => false, + enable: (node) => false + } + + }; + } + + updatePosition(that, node, instanceId): void { + } + + getNodePosition(instance): number { + return 0; + } + + getInfo(model, instance: NcfTreeNode): ModelInformationItem[] { + + if (_.isNil(instance)) { + return []; + } + + return [ + ModelInformationItem.createInstance("Model version", instance.modelVersion), + ModelInformationItem.createInstance('Role', instance.instanceGroupRole), + ModelInformationItem.createInstance('Collection function', instance.instanceGroupFunction), + ModelInformationItem.createInstance('Number of networks', instance.numberOfNetworks), + ]; + } +} + |