aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/pnf/pnf.model.info.spec.ts
blob: ca041e04552da0d0d3949f6ea72629a4a884ab93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import {ComponentInfoService} from "../../../component-info/component-info.service";
import {AppState} from "../../../../../shared/store/reducers";
import {NgRedux} from "@angular-redux/store";
import {PnfModelInfo} from "./pnf.model.info";
import {getTestBed, TestBed} from "@angular/core/testing";
import {DynamicInputsService} from "../../dynamicInputs.service";
import {SharedTreeService} from "../../shared.tree.service";
import {DuplicateService} from "../../../duplicate/duplicate.service";
import {AaiService} from "../../../../../shared/services/aaiService/aai.service";
import {FeatureFlagsService} from "../../../../../shared/services/featureFlag/feature-flags.service";
import {IframeService} from "../../../../../shared/utils/iframe.service";
import {HttpClientTestingModule} from "@angular/common/http/testing";
import {MockNgRedux, NgReduxTestingModule} from "@angular-redux/store/testing";
import {HttpClient, HttpHandler} from "@angular/common/http";
import {CollectionResourceModel} from "../../../../../shared/models/collectionResourceModel";
import {ComponentInfoType} from "../../../component-info/component-info-model";


describe('PNF model info', () => {
  let injector;
  let _componentInfoService: ComponentInfoService;
  let _store: NgRedux<AppState>;
  let pnfModel: PnfModelInfo =  new PnfModelInfo();
  beforeEach(() => {
    TestBed.configureTestingModule({
      imports: [HttpClientTestingModule, NgReduxTestingModule],
      providers: [
        MockNgRedux,
        DynamicInputsService,
        SharedTreeService,
        DuplicateService,
        AaiService,
        HttpClient,
        HttpHandler,
        FeatureFlagsService,
        ComponentInfoService,
        IframeService]
    }).compileComponents();

    injector = getTestBed();
    _store = injector.get(NgRedux);
    _componentInfoService = injector.get(ComponentInfoService);
  });

  test('pnf model should be defined', () => {
    expect(pnfModel).toBeDefined();
  });

  test('pnf model should defined extra details', () => {
    expect(pnfModel.name).toEqual('pnfs');
    expect(pnfModel.type).toEqual('PNF');
    expect(pnfModel.typeName).toEqual('PNF');
    expect(pnfModel.componentInfoType).toEqual(ComponentInfoType.PNF);
  });

  test('getTooltip should return "PNF"', () => {
    let tooltip: string = pnfModel.getTooltip();
    expect(tooltip).toEqual('PNF');
  });

  test('getType should return "pnf"', () => {
    let tooltip: string = pnfModel.getType();
    expect(tooltip).toEqual('pnf');
  });

  test('getNextLevelObject should be null', () => {
    let nextLevel: any = pnfModel.getNextLevelObject();
    expect(nextLevel).toBeNull();
  });

  test('isEcompGeneratedNaming should return false', () => {
    let isEcompGeneratedNaming: boolean = pnfModel.isEcompGeneratedNaming(<any>{});
    expect(isEcompGeneratedNaming).toBeFalsy();
  });

  test('getModel should return pnf model', () => {
    let model: CollectionResourceModel = pnfModel.getModel('PNF1', <any>{
      originalName : 'PNF1'
    }, getServiceHierarchy());
    expect(model.type).toEqual('PNF');
  });

  function getServiceHierarchy(){
    return {
      "service": {
        "uuid": "12550cd7-7708-4f53-a09e-41d3d6327ebc",
        "invariantUuid": "561faa57-7bbb-40ec-a81c-c0d4133e98d4",
        "name": "AIM Transport SVC_ym161f",
        "version": "1.0",
        "toscaModelURL": null,
        "category": "Network L1-3",
        "serviceType": "TRANSPORT",
        "serviceRole": "AIM",
        "description": "AIM Transport service",
        "serviceEcompNaming": "true",
        "instantiationType": "Macro",
        "inputs": {},
        "vidNotions": {
          "instantiationUI": "legacy",
          "modelCategory": "other",
          "viewEditUI": "legacy"
        }
      },
      "vnfs": {},
      "networks": {},
      "collectionResources": {},
      "configurations": {},
      "fabricConfigurations": {},
      "serviceProxies": {},
      "vfModules": {},
      "volumeGroups": {},
      "pnfs": {
        "PNF1": {
          "uuid": "1c831fa9-28a6-4778-8c1d-80b9e769f2ed",
          "invariantUuid": "74e13a12-dac9-4fba-b102-cd242d9e7f02",
          "description": "AIM Transport service",
          "name": "AIM PNF Model",
          "version": "1.0",
          "customizationUuid": "dce78da7-c842-47a1-aba2-2de1cd03ab7a",
          "inputs": {},
          "commands": {},
          "properties": {
            "nf_function": "SDNGW",
            "nf_role": "pD2IPE",
            "ecomp_generated_naming": "false",
            "nf_type": "ROUTER"
          },
          "type": "PNF"
        }
      },
      "vnfGroups": {}
    }
  }
})