1 import {getTestBed, TestBed} from '@angular/core/testing';
2 import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
3 import {InstantiationTemplatesModalService} from "./instantiation.templates.modal.service";
4 import {AaiService} from "../../../services/aaiService/aai.service";
5 import {ActivatedRoute} from "@angular/router";
6 import {IframeService} from "../../../utils/iframe.service";
7 import {NgRedux} from "@angular-redux/store";
8 import {FeatureFlagsService} from "../../../services/featureFlag/feature-flags.service";
9 import {InstantiationTemplatesRowModel} from "./instantiation.templates.row.model";
12 class ActivatedRouteMock<T> {
15 serviceModelId: '6e59c5de-f052-46fa-aa7e-2fca9d674c44'
24 describe('instantiation templates modal service', () => {
26 let service: InstantiationTemplatesModalService;
27 let httpMock: HttpTestingController;
28 let _aaiService: AaiService;
29 let _activatedRoute: ActivatedRoute;
31 beforeAll(done => (async () => {
32 TestBed.configureTestingModule({
33 imports: [HttpClientTestingModule],
34 providers: [InstantiationTemplatesModalService,
38 {provide: ActivatedRoute, useClass: ActivatedRouteMock},
39 {provide: NgRedux, useClass: MockAppStore}
42 await TestBed.compileComponents();
44 injector = getTestBed();
45 service = injector.get(InstantiationTemplatesModalService);
46 httpMock = injector.get(HttpTestingController);
47 _aaiService = injector.get(AaiService);
48 _activatedRoute = injector.get(ActivatedRoute);
50 })().then(done).catch(done.fail));
53 test('service should be defined', () => {
54 expect(service).toBeDefined();
58 test('convertResponseToUI - should return table data', () => {
61 "created": 1524995555000,
62 "modified": 1524995556000,
63 "action": "INSTANTIATE",
69 "jobId": "9f88fdb5-bb47-4bf3-8c5f-98f1ad0ec87c",
70 "templateId": "ce4ec177-cfc8-483e-8a2c-b7aea53fd740",
72 "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d91",
74 "jobStatus": "FAILED",
75 "statusModifiedDate": 1524995555000,
78 "owningEntityId": "aaa1",
79 "owningEntityName": "aaa1",
82 "aicZoneName": "VSDKYUTP-BAN1",
83 "tenantId": "1178612d2b394be4834ad77f567c0af2",
84 "tenantName": "AIN Web Tool-15-D-SSPtestcustome",
87 "serviceType": "TYLER SILVIA",
88 "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89",
89 "serviceInstanceId": null,
90 "serviceInstanceName": 'serviceInstanceName',
91 "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
92 "serviceModelName": "ComplexService",
93 "serviceModelVersion": "1.0",
94 "createdBulkDate": 1524995555000,
95 "isRetryEnabled": false
97 const tableRows: InstantiationTemplatesRowModel[] = service.convertResponseToUI(jobs);
98 expect(tableRows).toHaveLength(1);
99 expect(tableRows[0].userId).toEqual('16807000');
100 expect((new Date(tableRows[0].createDate)).toISOString()).toEqual('2018-04-29T09:52:35.000Z');
101 expect(tableRows[0].instanceName).toEqual('serviceInstanceName');
102 expect(tableRows[0].instantiationStatus).toEqual('FAILED');
103 expect(tableRows[0].region).toEqual('hvf6 (AAA1)');
104 expect(tableRows[0].tenant).toEqual('AIN Web Tool-15-D-SSPtestcustome');
105 expect(tableRows[0].aicZone).toEqual('VSDKYUTP-BAN1');
106 expect(tableRows[0].jobId).toEqual('9f88fdb5-bb47-4bf3-8c5f-98f1ad0ec87c');
110 test('getCloudOwner should remove "-att" from owningEntityName : "att-owner', () => {
111 let result: InstantiationTemplatesRowModel = new InstantiationTemplatesRowModel({
112 owningEntityName: 'att-owner',
115 expect(result.region).toEqual('regionId (OWNER)');
118 test('getCloudOwner should not return owningEntityName if not exist', () => {
119 let result: InstantiationTemplatesRowModel = new InstantiationTemplatesRowModel({owningEntityName: null, regionId: 'regionId'});
120 expect(result.region).toEqual('regionId');
123 test('getInstanceName should return instance name id exist if not exist', () => {
124 let result: InstantiationTemplatesRowModel = new InstantiationTemplatesRowModel({serviceInstanceName: 'instanceName'});
125 expect(result.instanceName).toEqual('instanceName');
128 test('getInstanceName should return <Automatically generated> if instance name not exist', () => {
129 let result: InstantiationTemplatesRowModel = new InstantiationTemplatesRowModel({});
130 expect(result.instanceName).toEqual('<Automatically generated>');