diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-07-07 19:23:03 +0300 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-07-08 16:13:43 +0300 |
commit | f792671ae247a931f34d902e9276202b5016ef9a (patch) | |
tree | 6104971e8074c9a3d720836276ff18619719ec02 /vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn | |
parent | fc62274e8d15964d63c62bf0e2f4abc040252ee9 (diff) |
Merge from ecomp 718fd196 - Modern UI
Issue-ID: VID-378
Change-Id: I2736b98426e324ec3aa233b034229ba84d99839f
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn')
2 files changed, 162 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.spec.ts new file mode 100644 index 000000000..9ccfaf753 --- /dev/null +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.spec.ts @@ -0,0 +1,66 @@ +import {ComponentInfoService} from "../../../component-info/component-info.service"; +import {NgRedux} from "@angular-redux/store"; +import {AppState} from "../../../../../shared/store/reducers"; +import {getTestBed, TestBed} from "@angular/core/testing"; +import {HttpClientTestingModule} from "@angular/common/http/testing"; +import {MockNgRedux, NgReduxTestingModule} from "@angular-redux/store/testing"; +import {SharedTreeService} from "../../shared.tree.service"; +import {ComponentInfoType} from "../../../component-info/component-info-model"; +import {VpnModelInfo} from "./vpn.model.info"; +import {VrfModel} from "../../../../../shared/models/vrfModel"; +import {ModelInformationItem} from "../../../../../shared/components/model-information/model-information.component"; +import {Level1Instance} from "../../../../../shared/models/level1Instance"; +import * as _ from "lodash"; +import {VpnTreeNode} from "../../../../../shared/models/vpnTreeNode"; +import {Level1Model} from "../../../../../shared/models/nodeModel"; + +describe('VPN Model Info', () => { + + let injector; + let _store : NgRedux<AppState>; + let _sharedTreeService: SharedTreeService; + let vpnModel: VpnModelInfo; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule, NgReduxTestingModule], + providers: [ + SharedTreeService, + MockNgRedux + ] + }).compileComponents(); + injector = getTestBed(); + _sharedTreeService = injector.get(SharedTreeService); + _store = injector.get(NgRedux); + vpnModel = new VpnModelInfo(_store,_sharedTreeService); + }); + + + test('vpnModel should be defined', () => { + expect(vpnModel).toBeDefined(); + }); + + test('vpnModel should defined extra details', () => { + expect(vpnModel.name).toEqual('vpns'); + expect(vpnModel.type).toEqual('VPN'); + expect(vpnModel.childNames).toBeUndefined; + expect(vpnModel.componentInfoType).toEqual(ComponentInfoType.VPN); + }); + + test('Info for vpn should be correct', () => { + const model = null; + const instance = new VpnTreeNode(new Level1Instance(), new Level1Model(), ""); + instance.region = "USA,EMEA"; + instance.routeTargetId = "globalRouteTarget_1"; + instance.routeTargetRole = "routeTargetRole_1"; + instance.customerVPNId = "VPN1260"; + let actualVpnInfo = vpnModel.getInfo(model,instance); + const instanceInfo = [ + ModelInformationItem.createInstance("Region", "USA,EMEA"), + ModelInformationItem.createInstance("Route target id", "globalRouteTarget_1"), + ModelInformationItem.createInstance("Route target role", "routeTargetRole_1"), + ModelInformationItem.createInstance("Customet VPN ID", "VPN1260")]; + expect(actualVpnInfo).toEqual(instanceInfo); + }); + +}) diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.ts new file mode 100644 index 000000000..b951162f8 --- /dev/null +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.ts @@ -0,0 +1,96 @@ +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 * as _ from "lodash"; +import {NgRedux} from "@angular-redux/store"; +import {AppState} from "../../../../../shared/store/reducers"; +import {SharedTreeService} from "../../shared.tree.service"; +import {NetworkInstance} from "../../../../../shared/models/networkInstance"; +import {Level1Model} from "../../../../../shared/models/nodeModel"; +import {VpnTreeNode} from "../../../../../shared/models/vpnTreeNode"; + +export class VpnModelInfo implements ILevelNodeInfo { + constructor(private _store: NgRedux<AppState>, + private _sharedTreeService: SharedTreeService) { + } + + name: string = 'vpns'; + type: string = 'VPN'; + typeName: string = 'VPN'; + + childNames: string[] = []; + componentInfoType = ComponentInfoType.VPN; + + isEcompGeneratedNaming(currentModel): boolean { + return false; + } + + updateDynamicInputsDataFromModel = (currentModel): any => []; + + getModel = (modelId: string, instance: any, serviceHierarchy): any => { + return new Level1Model(); + }; + + + createInstanceTreeNode = (instance: NetworkInstance, model: any, parentModel, storeKey: string): VpnTreeNode => { + let node = new VpnTreeNode(instance, model, storeKey); + node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); + node = this._sharedTreeService.addingStatusProperty(node); + node.typeName = this.typeName; + node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; + node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; + node = this._sharedTreeService.addingStatusProperty(node); + return node; + }; + + + getNextLevelObject = (): any => { + return null; + }; + + getTooltip = (): string => 'VPN'; + + getType = (): string => 'VPN'; + + 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 {}; + } + + updatePosition(that, node, instanceId): void { + } + + getNodePosition(instance): number { + return 0; + } + + getInfo(model, instance): ModelInformationItem[] { + const modelInformation = []; + const instanceInfo = !_.isEmpty(instance) ? [ + ModelInformationItem.createInstance("Region", instance.region), + ModelInformationItem.createInstance("Route target id", !_.isNull(instance.routeTargetId) ? instance.routeTargetId : null), + ModelInformationItem.createInstance("Route target role", !_.isNull(instance.routeTargetRole) ? instance.routeTargetRole : null), + ModelInformationItem.createInstance("Customet VPN ID", !_.isNull(instance.customerVPNId) ? instance.customerVPNId : null)] : []; + const result = [modelInformation, instanceInfo]; + return _.uniq(_.flatten(result)); + } +} + |