Merge "modify local workflow parameters to much native ones"
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / controller / aaiSubscriberController.test.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 require('./aaiSubscriberController');
22 require('../services/dataService');
23
24 const jestMock = require('jest-mock');
25
26 describe('TreeCtrl testing', () => {
27     var window;
28
29     let $scope;
30     beforeEach(
31         angular.mock.module('app')
32     );
33
34     beforeEach(inject(function (_$controller_) {
35         $scope = {};
36         _$controller_('TreeCtrl', {
37             $scope: $scope
38         });
39     }));
40
41     test('Verify expandAll calls broadcast with expand-all parameter', () => {
42         // given
43         const broadcast = jestMock.fn();
44         $scope.$broadcast = broadcast;
45         FIELD = {
46             ID: {
47                 ANGULAR_UI_TREE_EXPANDALL: "angular-ui-tree:expand-all"
48             }
49         };
50         // when
51         $scope.expandAll();
52         // then
53         expect(broadcast).toHaveBeenCalledWith("angular-ui-tree:expand-all");
54     });
55
56     test('Verify collapseAll calls broadcast with collapse-all parameter', () => {
57         // given
58         const broadcast = jestMock.fn();
59         $scope.$broadcast = broadcast;
60         FIELD = {
61             ID: {
62                 ANGULAR_UI_TREE_COLLAPSEALL: "angular-ui-tree:collapse-all"
63             }
64         };
65         // when
66         $scope.collapseAll();
67         // then
68         expect(broadcast).toHaveBeenCalledWith("angular-ui-tree:collapse-all");
69     });
70
71     test('Verify toggle calls toggle in given scope', () => {
72         // given
73         const testScope = {};
74         testScope.toggle = jestMock.fn();
75         // when
76         $scope.toggle(testScope);
77         // then
78         expect(testScope.toggle).toHaveBeenCalled();
79     });
80
81     test('Verify remove calls remove in given scope', () => {
82         // given
83         const testScope = {};
84         testScope.remove = jestMock.fn();
85         // when
86         $scope.remove(testScope);
87         // then
88         expect(testScope.remove).toHaveBeenCalled();
89     });
90
91     test('Verify moveLastToTheBeginning pops last element from data and puts it on the beginning', () => {
92         // given
93         $scope.data = [ 'a', 'b', 'c' ];
94         const expectedResult = [ 'c', 'a', 'b' ];
95
96         // when
97         $scope.moveLastToTheBeginning();
98         // then
99         expect($scope.data).toMatchObject(expectedResult);
100     });
101
102     test('Verify newSubItem pushes new item into given scope', () => {
103         // given
104         const testScope = {};
105         const testModel = {};
106
107         testModel.id = 2;
108         testModel.nodes = [];
109         testModel.title = 'testObject';
110
111         const expectedResult = {
112             id: 20,
113             title: 'testObject.1',
114             nodes: []
115         };
116
117         testScope.$modelValue = testModel;
118
119         // when
120         $scope.newSubItem(testScope);
121         // then
122         expect(testModel.nodes.length).toBe(1);
123         expect(testModel.nodes[0]).toMatchObject(expectedResult);
124     });
125 });
126
127 describe('aaiSubscriberController testing', () => {
128
129     beforeEach(
130         angular.mock.module('app')
131     );
132
133     let $scope;
134     let $any;
135
136     let mockFIELD = {
137         PROMPT: {
138             SELECT_SERVICE: 'testService'
139         },
140         NAME: {
141             SERVICE_INSTANCE_ID: 'testID',
142             SERVICE_INSTANCE_NAME: 'testName'
143         },
144         ID: {
145             INVENTORY_RESPONSE_ITEMS: 0,
146             INVENTORY_RESPONSE_ITEM: 0
147         },
148         STYLE: {
149             MSO_CTRL_BTN: 'testButtonStyle',
150         },
151         STATUS: {
152             DONE: 'done',
153         },
154         ERROR: {
155             AAI: 'testAAIError',
156             FETCHING_SERVICE_TYPES: 'testServiceType',
157             SELECT: 'testAlertError',
158         },
159
160     };
161
162     let mockCOMPONENT = {
163         SHOW_COMPONENT_DETAILS: 'testComponentDetails',
164         VNF: 'testComponentVNF',
165         WELCOME_PATH: 'http://test/welcome/',
166         CREATE_INSTANCE_PATH: 'testInstancePath',
167         FEATURE_FLAGS:{},
168     };
169
170     let mockAaiService = {
171         getSubscriptionServiceTypeList(customerId,successFunction,failFunction){},
172         getServiceModelsByServiceType(queryId,customerId,serviceType,successFunction,failFunction){},
173         searchServiceInstances(query){},
174     };
175
176     let mockAsdcService = {
177         isMacro(item){},
178         shouldTakeTheAsyncInstantiationFlow(serviceModel){},
179     };
180
181     let mockPropertyService = {
182         retrieveMsoMaxPollingIntervalMsec(){return 1000},
183         setMsoMaxPollingIntervalMsec(msecs){},
184         retrieveMsoMaxPolls(){return 1000},
185         setMsoMaxPolls(polls){},
186     };
187
188     let mockUtilityService = {
189     };
190
191     let mockVidService = {
192         setModel(model){},
193     };
194
195     let dataService;
196
197     let mockLocation = {
198         path(path){},
199     };
200
201     let mockHttp = {
202         get(){},
203     };
204
205     let mockOwningEntityService = {
206         getOwningEntityProperties(callBack){}
207     };
208
209     let mockQ = {
210
211     };
212
213     $ = (selector) => {return mockSelector};
214     let mockSelector = {
215         addClass(){return this},
216         removeClass(){return this},
217         attr(){},
218     };
219
220     let mock_ = {
221         reduce(service,iterateeFunction,accumulatorFunction){},
222         forEach(services,iteratedFunction){},
223         includes(array, status){
224             return array.includes(status);
225         },
226     };
227
228     let mockedLog = {};
229
230     let mockFeatureFlags = {};
231
232     let mockVIDCONFIGURATION = {};
233
234     let mockRoute = {};
235
236     let mockUibModal = {};
237
238     let timeout;
239
240     beforeEach(inject(function (_$controller_,DataService,$timeout) {
241         $scope = {
242             $on(request,toDoFunction){}
243         };
244         $any = {};
245         dataService = DataService;
246         timeout = $timeout;
247         _$controller_('aaiSubscriberController', {
248             $scope: $scope,
249             COMPONENT: mockCOMPONENT,
250             FIELD: mockFIELD,
251             PARAMETER: $any,
252             DataService: DataService,
253             PropertyService: mockPropertyService,
254             $http: mockHttp,
255             $timeout: timeout,
256             $location: mockLocation,
257             $log: mockedLog,
258             $route: mockRoute,
259             $uibModal: mockUibModal,
260             VIDCONFIGURATION: mockVIDCONFIGURATION,
261             UtilityService: mockUtilityService,
262             vidService: mockVidService,
263             AaiService: mockAaiService,
264             MsoService: $any,
265             OwningEntityService: mockOwningEntityService,
266             AsdcService: mockAsdcService,
267             featureFlags: mockFeatureFlags,
268             $q: mockQ,
269             _: mock_
270         });
271     }));
272
273     test('Verify showVnfDetails calls proper broadcast methots with proper parameters', () => {
274         // given
275         const broadcast = jestMock.fn();
276         $scope.$broadcast = broadcast;
277
278         aaiResult = [[['test']]];
279
280         // when
281         $scope.showVnfDetails('testVNF');
282
283         // then
284         expect(broadcast).toHaveBeenCalledWith(mockCOMPONENT.SHOW_COMPONENT_DETAILS, { componentId: mockCOMPONENT.VNF,callbackFunction: expect.any(Function) } );
285     });
286
287     test('Verify getSubs will call fetchSubs and fetchServices and gets gets customer list from AaiService on success', () => {
288         // given
289         mockAaiService.getSubList = (successFunction,failFunction) => {
290             successFunction(['testCustomer1', 'testCustomer2']);
291         };
292         mockAaiService.getServices2 = (successFunction,failFunction) => {
293             successFunction('testListId');
294         };
295
296         // when
297         $scope.getSubs();
298
299         // then
300         expect( $scope.customerList ).toContain('testCustomer1','testCustomer2');
301         expect( dataService.getServiceIdList() ).toEqual('testListId');
302     });
303
304     test('Verify getSubs will call fetchSubs and fetchServices and return error message from AaiService on fail', () => {
305         // given
306         mockAaiService.getSubList = (successFunction,failFunction) => {
307             failFunction({status: 404, data: 'getSubListTestErrorMessage'} );
308         };
309         mockAaiService.getServices2 = (successFunction,failFunction) => {
310             failFunction({status: 404, data: 'getServices02TestErrorMessage'} );
311         };
312
313         // when
314         $scope.getSubs();
315
316         // then
317         expect( $scope.errorDetails ).toEqual('getServices02TestErrorMessage');
318     });
319
320     test('Verify refreshServiceTypes will call getServiceTypesList and gets service type list from AaiService, with proper customerID ', () => {
321         // given
322         dataService.setGlobalCustomerId('testCustomerID');
323         dataService.setServiceIdList(['testServiceId1','testServiceId2']);
324
325         mockAaiService.getSubscriptionServiceTypeList = (customerId, successFunction,failFunction) => {
326             if (customerId === 'testCustomerID'){
327                 successFunction(['testServiceType1', 'testServiceType2']);
328             }
329         };
330
331         // when
332         $scope.refreshServiceTypes('testCustomerID');
333
334         // then
335         expect( $scope.serviceTypeList ).toContain('testServiceType1','testServiceType2');
336     });
337
338     test('Verify refreshServiceTypes will call getServiceTypesList and return error message with wrong customerID ', () => {
339         // given
340         mockAaiService.getSubscriptionServiceTypeList = (customerId, successFunction,failFunction) => {
341             if (customerId === 'testWrongCustomerID'){
342                 failFunction( {status: 404, data: 'testErrorMessage'} );
343             }
344         };
345
346         // when
347         $scope.refreshServiceTypes('testWrongCustomerID');
348
349         // then
350         expect( $scope.errorDetails ).toEqual('testErrorMessage');
351     });
352
353     test('Verify refreshServiceTypes will call getServiceTypesList and calls alert with no customerID ', () => {
354         // given
355         alert = jestMock.fn();
356
357         // when
358         $scope.refreshServiceTypes('');
359
360         // then
361         expect( alert ).toHaveBeenCalledWith(mockFIELD.ERROR.SELECT);
362     });
363
364     test('Verify getAaiServiceModels will set correct location ', () => {
365         // given
366         mockLocation.path = jestMock.fn();
367
368         // when
369         $scope.getAaiServiceModels('testServiceType','testSubName');
370
371         // then
372         expect(mockLocation.path).toHaveBeenCalledWith(mockCOMPONENT.CREATE_INSTANCE_PATH);
373     });
374
375     test('Verify getAaiServiceModels wont set correct location if service type is empty', () => {
376         // given
377         mockLocation.path = jestMock.fn();
378
379         // when
380         $scope.getAaiServiceModels('','testSubName');
381
382         // then
383         expect(mockLocation.path).not.toHaveBeenCalled();
384     });
385
386     test('Verify getAaiServiceModelsList will call AaiService getServiceModelsByServiceType and will set wholeData ', () => {
387         // given
388
389         mockAaiService.getServiceModelsByServiceType = (queryId,customerId,serviceType,successFunction,failFunction) => {
390             let response = {};
391             response.data = {};
392             response.data['inventory-response-item'] = [[],[]];
393             response.data['inventory-response-item'][0]['inventory-response-items'] = [];
394             response.data['inventory-response-item'][0]['service-subscription'] = [];
395
396             let testItem = [];
397             testItem['extra-properties'] = [];
398             testItem['extra-properties']['extra-property'] = [[],[],[],[],[],[],[]];
399             testItem['extra-properties']['extra-property'][6]["property-value"] = 1.546;
400
401             testItem['extra-properties']['extra-property'][4]['property-value'] = 0;
402
403             response.data['inventory-response-item'][0]['service-subscription']['service-type'] = 'testServiceType';
404             response.data['inventory-response-item'][0]['inventory-response-items']['inventory-response-item'] = testItem;
405
406
407             successFunction(response);
408         };
409
410         mock_.reduce = (service,iterateeFunction,accumulatorFunction) => {
411             return iterateeFunction([],service);
412         };
413         mock_.forEach = (service,iterateeFunction) => {
414             iterateeFunction(service);
415         };
416         mock_.maxBy = (item,maxFunction) => {
417             return maxFunction( item[0][0] )
418         };
419
420         dataService.setServiceIdList(['testService1','testService2','testService3','testService4']);
421         dataService.setSubscribers([{subscriberName:'testSubscriber1'},{subscriberName:'testSubscriber2'},{subscriberName:'testSubscriber3'},{subscriberName:'testSubscriber4'}]);
422         dataService.setGlobalCustomerId(2);
423         dataService.setSubscriberName('testSubscriber1');
424
425         // when
426         $scope.getAaiServiceModelsList();
427
428         // then
429         expect($scope.services[0]).toEqual(1.546);
430         expect($scope.serviceType).toEqual('testServiceType');
431     });
432
433     test('Verify getAaiServiceModelsList will call AaiService getServiceModelsByServiceType and will return error data on fail ', () => {
434         // given
435         dataService.setServiceIdList([['testServiceId1','testServiceId2']]);
436         dataService.setSubscribers(['testSubscriber1,testSubscriber2']);
437
438         mockAaiService.getServiceModelsByServiceType = (queryId,customerId,serviceType,successFunction,failFunction) => {
439             failFunction( {status: 404, data: 'testErrorMessage'})
440         };
441
442         // when
443         $scope.getAaiServiceModelsList();
444
445         // then
446         expect($scope.errorDetails).toEqual('testErrorMessage');
447     });
448
449     test('Verify getAaiServiceModelsList will call AaiService getServiceModelsByServiceType and will return error data if respose data is empty ', () => {
450         // given
451         dataService.setServiceIdList([['testServiceId1','testServiceId2']]);
452         dataService.setSubscribers(['testSubscriber1,testSubscriber2']);
453
454         mockAaiService.getServiceModelsByServiceType = (queryId,customerId,serviceType,successFunction,failFunction) => {
455             let response = {};
456             response.data = {};
457             response.data['inventory-response-item'] = [];
458             successFunction(response);
459         };
460
461         // when
462         $scope.getAaiServiceModelsList();
463
464         // then
465         expect($scope.status).toEqual('Failed to get service models from SDC.');
466     });
467
468     test('Verify deployService will call http get method to rest model service', () => {
469         // given
470         mockedLog.error = jestMock.fn();
471         mockAsdcService.isMacro = (item) => { return true };
472         mockAsdcService.shouldTakeTheAsyncInstantiationFlow = (serviceModel) => {return 'testModel'};
473         mockUtilityService.convertModel = (serviceModel)=>{return serviceModel};
474         $scope.$broadcast = (broadcastType, broadcastObject) => {broadcastObject.callbackFunction(
475             {
476                 isSuccessful:true,
477                 control:
478                     [
479                         {id:"subscriberName",value:"testSubscriber"},
480                         {id:"serviceType",value:"testService"}
481                         ],
482                 instanceId:"testInstance"
483             })};
484
485         let service = {
486             "service-instance":{
487                 "model-version-id": 101
488             }
489         };
490
491         $scope.refreshSubs = jestMock.fn();
492
493         let mockedGetPromise = Promise.resolve({data: {service: {name: 'testServiceName' }}});
494         mockHttp.get = () => mockedGetPromise;
495
496         // when
497         $scope.deployService(service,true);
498     });
499
500     test('Verify deployService will log error if get fails ', () => {
501         // given
502
503         let mockedGetPromise = Promise.reject({code: 404});
504         mockHttp.get = () => mockedGetPromise;
505
506         let service = {
507             "service-instance":{
508                 "model-version-id": 101
509             }
510         };
511
512         // when
513         $scope.deployService(service,false);
514     });
515
516     test('Verify refreshSubs fetches Subs and Services', () => {
517         // given
518         $scope.fetchSubs = jestMock.fn();
519         $scope.fetchServices = jestMock.fn();
520         $scope.init = jestMock.fn();
521
522         mockFIELD.PROMPT.REFRESH_SUB_LIST = 'testRefreshMock';
523
524         // when
525         $scope.refreshSubs();
526
527         // then
528         expect($scope.init).toHaveBeenCalled();
529         expect($scope.fetchSubs).toHaveBeenCalledWith(mockFIELD.PROMPT.REFRESH_SUB_LIST);
530         expect($scope.fetchServices).toHaveBeenCalled();
531
532     });
533
534     test('Verify loadOwningEntity gets owning entity properties', () => {
535         // given
536         mockOwningEntityService.getOwningEntityProperties = (callBack) => {
537           callBack({owningEntity:'testOwner',project:'testProject'});
538         };
539
540         // when
541         $scope.loadOwningEntity();
542
543         // then
544         expect($scope.owningEntities).toEqual('testOwner');
545         expect($scope.projects).toEqual('testProject');
546     });
547
548     test('Verify getPermitted returns items permission', () => {
549         // given
550         mockFIELD.ID.IS_PERMITTED = 'testPermission';
551
552         // when
553         expect(
554             $scope.getPermitted({})
555         ).toEqual(undefined);
556
557         expect(
558             $scope.getPermitted({isPermitted:true})
559         ).toEqual(true);
560
561         expect(
562             $scope.getPermitted({isPermitted:false})
563         ).toEqual(undefined);
564
565         expect(
566             $scope.getPermitted({isPermitted:false,testPermission:true})
567         ).toEqual(true);
568
569         expect(
570             $scope.getPermitted({testPermission:false,testPermission:false})
571         ).toEqual(false);
572
573         expect(
574             $scope.getPermitted({isPermitted:true,testPermission:false})
575         ).toEqual(true);
576     });
577
578     test('Verify getSubDetails calls to aaiService for service instance', () => {
579         // given
580         let aaiPromise = Promise.resolve(
581             {
582                 displayData:[
583                     {globalCustomerId:"testCustomerId01",subscriberName:"testCustomer1"},
584                     {globalCustomerId:"testCustomerId02",subscriberName:"testCustomer2"},
585                 ]
586             });
587
588         mockLocation.url = () => {return ""};
589
590         mockAaiService.searchServiceInstances = (query)=>aaiPromise;
591
592         // when
593         $scope.getSubDetails();
594     });
595
596     test('Verify getSubDetails catches bad response', () => {
597         // given
598         let aaiPromise = Promise.reject(
599             {data:'testError',status:404});
600
601         mockLocation.url = () => {return ""};
602
603         mockAaiService.searchServiceInstances = (query)=>aaiPromise;
604
605         // when
606         $scope.getSubDetails();
607     });
608
609     test('Verify getComponentList returns list of components if query is correct', () => {
610         // given
611         mockLocation.search = () => {
612             return {
613                 subscriberId: 'testSubscriberID',
614                 serviceType: 'testService',
615                 serviceInstanceId: "testServiceInstanceID",
616                 subscriberName: "testSubscriber",
617                 aaiModelVersionId: "testModelVersion"
618             }
619         };
620
621         mockVidService.getModel = () => {
622             return {
623                 service:{
624                     uuid: "testModelVersion",
625                 },
626             }
627         };
628
629         mockUtilityService.hasContents = (content) => {
630             if (content==="testModelVersion") {
631                 return true;
632             }
633             return false;
634         };
635
636         mockQ.resolve = (item) => {return Promise.resolve("testModelVersion")};
637
638         $scope.prepareScopeWithModel = () => {return Promise.resolve()};
639
640         mockAaiService.getVlansByNetworksMapping = (globalCustomerId, serviceType, serviceInstanceId, modelServiceUuid) => {
641             return Promise.resolve({serviceNetworks:true});
642         };
643
644         $scope.service ={
645             model:{
646                 service:{
647                     uuid: 'testModelServiceUuid'
648                 }
649             }
650         };
651
652         mockedLog.debug = () => {};
653         mockUtilityService.isObjectEmpty = () => {
654             return false;
655         };
656
657         mockFIELD.ID.INVENTORY_RESPONSE_ITEM = "testResponseItems";
658         mockFIELD.ID.SERVICE_SUBSCRIPTION = 0;
659         mockFIELD.ID.SERVICE_INSTANCES = 0;
660         mockFIELD.ID.SERVICE_INSTANCE = 0;
661         mockFIELD.ID.SERVICE_INSTANCE_ID = 'testServiceInstanceID';
662         mockFIELD.STATUS.ASSIGNED = 'teststatus';
663
664         mockAaiService.runNamedQuery = (namedQueryId,globalCustomerId,serviceType,serviceInstanceId,successFunction,failureFunction) => {
665             successFunction({
666                 data:{
667                     testResponseItems:[
668                         "testItem1",
669                         "testItem2",
670                         "testItem3",
671                     ]
672                 },
673             });
674             return Promise.resolve("testComponentList");
675         };
676
677         mockAaiService.getPortMirroringData = (portMirroringConfigurationIds) => {
678             return Promise.resolve({data:[8080,9090]});
679         };
680
681         mockAaiService.getPortMirroringSourcePorts = (portMirroringConfigurationIds) => {
682           return Promise.resolve({data:[8888,9999]})
683         };
684
685         mockAaiService.getSubscriberName = (customerId, successFunction) => {
686             successFunction({subscriberName:"testSubscriber1",serviceSubscriptions:[[
687                     [[[{'testServiceInstanceID':'testServiceInstanceID','orchestration-status':'testStatus'},{'testServiceInstanceID':'','orchestration-status':''}]]],
688                     [[[{'testServiceInstanceID':'','orchestration-status':''}]]]
689                 ]],
690             });
691         };
692
693         mock_.map = (serviceNetworkVlans, networkId) => {
694             return ["aaiNetworkId1","aaiNetworkId2"];
695         };
696
697         // when
698         return $scope.getComponentList('','').
699         then(components =>{
700             expect(components).toEqual("testComponentList")
701         });
702
703     });
704
705     test('Verify handleServerError sets proper  $scope.error and $scope.status', () => {
706         // given
707         mockUtilityService.getHttpErrorMessage = (response) => {return response.statusText};
708         mockFIELD.ERROR.SYSTEM_ERROR = "testSystemError";
709         mockFIELD.STATUS.ERROR = "testStatusError";
710
711         // when
712         $scope.handleServerError({statusText:'testStatusError'},'');
713
714         // then
715         expect($scope.error).toEqual("testSystemError (testStatusError)");
716         expect($scope.status).toEqual("testStatusError");
717     });
718
719     test('Verify showContentError sets proper $scope.error and $scope.status if UtilityService has that content', () => {
720         // given
721         mockFIELD.STATUS.ERROR = "testStatusError";
722
723         mockUtilityService.hasContents = (content) => {
724           return content === 'testContentError';
725
726         };
727
728         // when
729         $scope.showContentError('testContentError');
730
731         // then
732         expect($scope.error).toEqual("System failure (testContentError)");
733         expect($scope.status).toEqual("testStatusError");
734     });
735
736     test('Verify showContentError sets proper $scope.error and $scope.status if UtilityService has not that content', () => {
737         // given
738         mockFIELD.ERROR.SYSTEM_ERROR = "testSystemError";
739         mockFIELD.STATUS.ERROR = "testStatusError";
740
741         mockUtilityService.hasContents = (content) => {
742             return false;
743         };
744
745         // when
746         $scope.showContentError('testContentError');
747
748         // then
749         expect($scope.error).toEqual("testSystemError");
750         expect($scope.status).toEqual("testStatusError");
751     });
752
753     test('Verify handleInitialResponse shows error for response codes other then 200,201,202', ()  => {
754         // given
755         let response = {
756             data:{
757                 status:404,
758             }
759         };
760
761         mockFIELD.ERROR.MSO = "testSystemError";
762         mockFIELD.ERROR.AAI_FETCHING_CUST_DATA = "testStatusError:";
763
764         $scope.showError = jestMock.fn();
765
766         // when
767         $scope.handleInitialResponse(response);
768
769         // then
770         expect($scope.showError).toHaveBeenCalledWith("testSystemError");
771         expect($scope.status).toEqual("testStatusError:404");
772     });
773
774     test('Verify handleInitialResponse updates customer list with response code 202', ()  => {
775         // given
776         let customer ={
777             'globalCustomerId':'testCustomerID',
778             "subscriberName":'testSubscriber',
779             "isPermitted":false
780         };
781         let response = {
782             data:{
783                 status:202,
784                 customer:[customer],
785             }
786         };
787
788         mockFIELD.ID.GLOBAL_CUSTOMER_ID = 'globalCustomerId';
789         mockFIELD.ID.SUBNAME = 'subscriberName';
790         mockFIELD.ID.IS_PERMITTED = 'isPermitted';
791
792         // when
793         $scope.handleInitialResponse(response);
794
795         // then
796         expect($scope.customerList).toContainEqual(customer);
797     });
798
799     test('Verify handleInitialResponse calls showContentError with wrong response ', ()  => {
800         // given
801         $scope.showContentError = jestMock.fn();
802
803         // when
804         $scope.handleInitialResponse(null);
805
806         // then
807         expect($scope.showContentError).toHaveBeenCalledWith(expect.objectContaining({message:"Cannot read property 'data' of null"}));
808     });
809
810     test('Verify isConfigurationDataAvailiable will return proper response', ()  => {
811         // given
812         mockedLog.debug = jestMock.fn();
813         // when
814         expect( $scope.isConfigurationDataAvailiable({configData:{}}) ).toEqual(true);
815         expect( $scope.isConfigurationDataAvailiable({configData:{errorDescription:"testerror"}}) ).toEqual(false);
816         expect( $scope.isConfigurationDataAvailiable({}) ).toEqual(undefined);
817
818     });
819
820     test('Verify isActivateDeactivateEnabled will return proper response', ()  => {
821         // given
822         mockedLog.debug = jestMock.fn();
823
824         $scope.serviceOrchestrationStatus = "active";
825         mockCOMPONENT.ACTIVATE_SERVICE_STATUSES = ["active","up"];
826
827         // when
828         expect( $scope.isActivateDeactivateEnabled("deactivate")).toEqual(true);
829         expect( $scope.isActivateDeactivateEnabled("activate")).toEqual(true);
830
831         $scope.serviceOrchestrationStatus = "down";
832         mockCOMPONENT.ACTIVATE_SERVICE_STATUSES = ["active","up"];
833
834         expect( $scope.isActivateDeactivateEnabled("deactivate")).toEqual(false);
835         expect( $scope.isActivateDeactivateEnabled("activate")).toEqual(false);
836
837         $scope.serviceOrchestrationStatus = null;
838
839         expect( $scope.isActivateDeactivateEnabled(null)).toEqual(false);
840
841     });
842
843     test('Verify isShowVerifyService will return proper response base on feature flag', ()  => {
844         // given
845         mockCOMPONENT.FEATURE_FLAGS.FLAG_SHOW_VERIFY_SERVICE = 'showVerifyService';
846         mockFeatureFlags.isOn = (flag) => {
847             if (flag === 'showVerifyService'){return true};
848         };
849
850         // when
851         expect( $scope.isShowVerifyService()).toEqual(true);
852     });
853
854     test('Verify isEnableVerifyService will return false if is not ALaCarte', ()  => {
855         // given
856         dataService.setALaCarte(false);
857
858         // when
859         expect( $scope.isEnableVerifyService()).toEqual(false);
860     });
861
862     test('Verify isEnableVerifyService will return verifyButtonEnabled if is ALaCarte', ()  => {
863         // given
864         dataService.setALaCarte(true);
865
866         // when
867         $scope.verifyButtonEnabled = true;
868         expect( $scope.isEnableVerifyService()).toEqual(true);
869
870         $scope.verifyButtonEnabled = false;
871         expect( $scope.isEnableVerifyService()).toEqual(false);
872     });
873
874     test('Verify activateVerifyService will post POMBA verification', ()  => {
875         // given
876         mockCOMPONENT.VERIFY_SERVICE_URL = "/testURL";
877
878         mockAaiService.postPOMBAverificationRequest = jestMock.fn();
879
880         $scope.serviceInstanceId = "testInstanceID";
881         $scope.service = {model:{service:{}},instance:{}};
882         $scope.service.model.service.uuid = "testUuid";
883         $scope.service.model.service.invariantUuid = "testInvariantUuid";
884         $scope.globalCustomerId = "testCustomerId";
885         $scope.service.instance.serviceType = "testServiceType";
886
887         // when
888         $scope.activateVerifyService();
889
890         // then
891         expect(mockAaiService.postPOMBAverificationRequest).toHaveBeenCalledWith(
892             "/testURL",
893             expect.objectContaining({'serviceInstanceList':[expect.any(Object)]}),
894             expect.objectContaining({'headers':expect.any(Object)}));
895     });
896
897     test('Verify isShowAssignmentsEnabled will return proper response determine by feature flag', ()  => {
898         // given
899         mockCOMPONENT.FEATURE_FLAGS.FLAG_SHOW_ASSIGNMENTS = "showAssignment";
900
901         mockFeatureFlags.isOn = (flag) => {
902             if (flag === 'showAssignment'){return true};
903         };
904
905         // when
906         $scope.serviceOrchestrationStatus = "assigned";
907         expect( $scope.isShowAssignmentsEnabled() ).toEqual(true);
908
909         $scope.serviceOrchestrationStatus = "notAssigned";
910         expect( $scope.isShowAssignmentsEnabled() ).toEqual(false);
911
912         $scope.serviceOrchestrationStatus = null;
913         expect( $scope.isShowAssignmentsEnabled() ).toEqual(false);
914     });
915
916     test('Verify isActivateFabricConfiguration will return proper response determine by feature flag', ()  => {
917         // given
918         mockCOMPONENT.FEATURE_FLAGS.FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS = "fabricConfigurationAssignment";
919         $scope.hasFabricConfigurations = true;
920
921         mockFeatureFlags.isOn = (flag) => {
922             if (flag === 'fabricConfigurationAssignment'){return true};
923         };
924
925         // when
926         $scope.serviceOrchestrationStatus = "assigned";
927         expect( $scope.isActivateFabricConfiguration() ).toEqual(true);
928
929         $scope.serviceOrchestrationStatus = "notAssigned";
930         expect( $scope.isActivateFabricConfiguration() ).toEqual(false);
931
932         $scope.serviceOrchestrationStatus = null;
933         expect( $scope.isActivateFabricConfiguration() ).toEqual(false);
934     });
935
936     test('Verify isResumeShown will return proper response determine by feature flag with disabled ActivateDeactivate', ()  => {
937         // given
938         $scope.serviceOrchestrationStatus = "assigned";
939         $scope.isActivateDeactivateEnabled = () => {return false};
940
941         // when
942         expect( $scope.isResumeShown("assigned") ).toEqual(true);
943         expect( $scope.isResumeShown("unAssigned") ).toEqual(false);
944
945     });
946
947     test('Verify isResumeShown will return proper response determine by feature flag with enable ActivateDeactivate', ()  => {
948         // given
949         $scope.serviceOrchestrationStatus = "assigned";
950         $scope.isActivateDeactivateEnabled = () => {return true};
951
952         // when
953         expect( $scope.isResumeShown("assigned") ).toEqual(false);
954         expect( $scope.isResumeShown("unAssigned") ).toEqual(false);
955
956     });
957
958     test('Verify close will call time out cancel and hides pop up window if timer is defined', ()  => {
959         // given
960         $scope.timer = 1000;
961         $scope.isPopupVisible = true;
962
963         timeout.cancel = jestMock.fn();
964
965         // when
966         $scope.close();
967
968         // then
969         expect(timeout.cancel).toHaveBeenCalledWith(1000);
970         expect($scope.isPopupVisible).toEqual(false);
971     });
972
973     test('Verify close will hide pop up window if timer is undefined', ()  => {
974         // given
975         $scope.timer = undefined;
976         $scope.isPopupVisible = true;
977
978         // when
979         $scope.close();
980
981         // then
982         expect($scope.isPopupVisible).toEqual(false);
983     });
984
985     test('Verify reloadRoute will call reload on rout', ()  => {
986         // given
987         mockRoute.reload = jestMock.fn();
988
989         // when
990         $scope.reloadRoute();
991
992         // then
993         expect(mockRoute.reload).toHaveBeenCalled();
994     });
995
996     test('Verify prevPage will decrease currentPage', ()  => {
997         // given
998         $scope.currentPage = 5;
999
1000         // when
1001         $scope.prevPage();
1002
1003         // then
1004         expect($scope.currentPage).toEqual(4);
1005     });
1006
1007     test('Verify showAssignmentsSDNC will return proper response base on VIDCONFIGURATION', ()  => {
1008         // given
1009         $scope.service = {};
1010         $scope.service.instance = {};
1011         $scope.service.instance.id = "testServiceInstanceId";
1012
1013         mockVIDCONFIGURATION.SDNC_SHOW_ASSIGNMENTS_URL = "test/ulr/to/<SERVICE_INSTANCE_ID>";
1014
1015         // when
1016         expect( $scope.showAssignmentsSDNC() ).toEqual("test/ulr/to/testServiceInstanceId");
1017     });
1018
1019     test('Verify showAssignmentsSDNC will return null if service instance dos not exist or is null', ()  => {
1020         // given
1021         $scope.service = {};
1022
1023         // when
1024         expect( $scope.showAssignmentsSDNC() ).toEqual(null);
1025
1026         $scope.service.instance = null;
1027         expect( $scope.showAssignmentsSDNC() ).toEqual(null);
1028     });
1029
1030     test('Verify activateFabricConfigurationMSO with logged in user, will call uibModal open that will return response ', ()  => {
1031         // given
1032         let resopnse = {};
1033
1034         mockCOMPONENT.MSO_ACTIVATE_FABRIC_CONFIGURATION_REQ = "testMsoActivateType";
1035
1036         $scope.service = {};
1037         $scope.service.model = {};
1038         $scope.service = {};
1039         $scope.serviceInstanceId= "testServiceInstanceId";
1040
1041         dataService.setLoggedInUserId("testUserId");
1042
1043         mockUibModal.open = (testResponse) => {
1044             resopnse = testResponse.resolve;
1045         };
1046
1047         // when
1048         $scope.activateFabricConfigurationMSO();
1049
1050         // then
1051         expect( resopnse.msoType() ).toEqual("testMsoActivateType");
1052         expect( resopnse.requestParams().serviceInstanceId ).toEqual("testServiceInstanceId");
1053         expect( resopnse.requestParams().userId ).toEqual("testUserId");
1054         expect( resopnse.configuration() ).toEqual(undefined);
1055     });
1056
1057     test('Verify activateFabricConfigurationMSO without logged in user will first get user id from AaiService , will call uibModal open that will return response ', ()  => {
1058         // given
1059         let resopnse = {};
1060
1061         mockCOMPONENT.MSO_ACTIVATE_FABRIC_CONFIGURATION_REQ = "testMsoActivateType";
1062
1063         $scope.service = {};
1064         $scope.service.model = {};
1065         $scope.service = {};
1066         $scope.serviceInstanceId= "testServiceInstanceId";
1067
1068
1069         mockAaiService.getLoggedInUserID = (onSuccess) => {
1070             onSuccess({data:"testAaiUserId"});
1071         };
1072
1073         mockUibModal.open = (testResponse) => {
1074             resopnse = testResponse.resolve;
1075         };
1076
1077         // when
1078         $scope.activateFabricConfigurationMSO();
1079
1080         // then
1081         expect( resopnse.msoType() ).toEqual("testMsoActivateType");
1082         expect( resopnse.requestParams().serviceInstanceId ).toEqual("testServiceInstanceId");
1083         expect( resopnse.requestParams().userId ).toEqual("testAaiUserId");
1084         expect( resopnse.configuration() ).toEqual(undefined);
1085     });
1086
1087     test('Verify activateMSOInstance with logged in user, will get aicZone from AaiService and call uibModal open that will return response ', ()  => {
1088         // given
1089         let resopnse = {};
1090
1091         mockCOMPONENT.MSO_ACTIVATE_SERVICE_REQ = "testMsoActivateType";
1092
1093         $scope.service = {};
1094         $scope.service.model = {};
1095         $scope.service.instance = {};
1096
1097         dataService.setLoggedInUserId("testUserId");
1098
1099         mockAaiService.getAicZoneForPNF = (globalCustomerId,serviceType,serviceInstanceId,getZoneFunction) => {
1100             getZoneFunction("testAicZone");
1101         };
1102
1103         mockUibModal.open = (testResponse) => {
1104             resopnse = testResponse.resolve;
1105         };
1106
1107         // when
1108         $scope.activateMSOInstance();
1109
1110         // then
1111         expect( resopnse.msoType() ).toEqual("testMsoActivateType");
1112         expect( resopnse.requestParams().aicZone ).toEqual("testAicZone");
1113         expect( resopnse.requestParams().userId ).toEqual("testUserId");
1114         expect( resopnse.configuration() ).toEqual(undefined);
1115     });
1116
1117     test('Verify activateMSOInstance without logged in user will first get user id from AaiService , will call uibModal open that will return response ', ()  => {
1118         // given
1119         let resopnse = {};
1120
1121         mockCOMPONENT.MSO_ACTIVATE_SERVICE_REQ = "testMsoActivateType";
1122
1123         $scope.service = {};
1124         $scope.service.model = {};
1125         $scope.service.instance = {};
1126
1127
1128         mockAaiService.getAicZoneForPNF = (globalCustomerId,serviceType,serviceInstanceId,getZoneFunction) => {
1129             getZoneFunction("testAicZone");
1130         };
1131
1132         mockAaiService.getLoggedInUserID = (onSuccess) => {
1133             onSuccess({data:"testAaiUserId"});
1134         };
1135
1136         mockUibModal.open = (testResponse) => {
1137             resopnse = testResponse.resolve;
1138         };
1139
1140         // when
1141         $scope.activateMSOInstance();
1142
1143         // then
1144         expect( resopnse.msoType() ).toEqual("testMsoActivateType");
1145         expect( resopnse.requestParams().aicZone ).toEqual("testAicZone");
1146         expect( resopnse.requestParams().userId ).toEqual("testAaiUserId");
1147         expect( resopnse.configuration() ).toEqual(undefined);
1148     });
1149
1150     test('Verify deactivateMSOInstance will get call uibModal open that will return response ', ()  => {
1151         // given
1152         let resopnse = {};
1153
1154         mockCOMPONENT.MSO_DEACTIVATE_SERVICE_REQ = "testMsoDeactivateType";
1155
1156         $scope.service = {};
1157         $scope.service.model = {};
1158         $scope.service.instance = {};
1159
1160
1161         mockAaiService.getAicZoneForPNF = (globalCustomerId,serviceType,serviceInstanceId,getZoneFunction) => {
1162             getZoneFunction("testAicZone");
1163         };
1164
1165         mockAaiService.getLoggedInUserID = (onSuccess) => {
1166             onSuccess({data:"testAaiUserId"});
1167         };
1168
1169         mockUibModal.open = (testResponse) => {
1170             resopnse = testResponse.resolve;
1171         };
1172
1173         // when
1174         $scope.deactivateMSOInstance();
1175
1176         // then
1177         expect( resopnse.msoType() ).toEqual("testMsoDeactivateType");
1178         expect( resopnse.requestParams().aicZone ).toEqual("testAicZone");
1179         expect( resopnse.requestParams().userId ).toEqual("testAaiUserId");
1180         expect( resopnse.configuration() ).toEqual(undefined);
1181     });
1182
1183     test('Verify deleteConfiguration will get call uibModal open that will return response ', ()  => {
1184         // given
1185         let resopnse = {};
1186
1187         serviceObject = {
1188             model:{
1189                 service:{
1190                     invariantUuid:"testInvariantUuid",
1191                     uuid:"testUuid",
1192                     name:"testService",
1193                     version:"testVersion",
1194                 }},
1195             instance:{
1196                 serviceInstanceId:"testServiceInstanceId",
1197             }
1198         };
1199
1200         configuration = {
1201             modelInvariantId:"testModelInvariantId",
1202             modelVersionId:"testModelVersionId",
1203             modelCustomizationId:"testModelCustomizationId",
1204             nodeId:"testNodeId",
1205             DELETE:"testDELETE",
1206         };
1207
1208         mockCOMPONENT.MSO_DELETE_CONFIGURATION_REQ = "testMsoDeleteType";
1209
1210         mockAaiService.getLoggedInUserID = (successFunction) => {
1211             successFunction( {data:"testLoggedInUserId"} );
1212         };
1213
1214         mockUibModal.open = (testResponse) => {
1215             resopnse = testResponse.resolve;
1216         };
1217
1218         // when
1219         $scope.deleteConfiguration(serviceObject, configuration);
1220
1221         // then
1222         expect( resopnse.msoType() ).toEqual("testMsoDeleteType");
1223         expect( resopnse.requestParams().serviceModel.modelInvariantId ).toEqual("testInvariantUuid");
1224         expect( resopnse.requestParams().serviceModel.modelVersionId ).toEqual("testUuid");
1225         expect( resopnse.requestParams().serviceModel.modelName ).toEqual("testService");
1226         expect( resopnse.requestParams().serviceModel.modelVersion ).toEqual("testVersion");
1227         expect( resopnse.requestParams().serviceInstanceId ).toEqual("testServiceInstanceId");
1228         expect( resopnse.requestParams().configurationModel.modelInvariantId ).toEqual("testModelInvariantId");
1229         expect( resopnse.requestParams().configurationModel.modelVersionId ).toEqual("testModelVersionId");
1230         expect( resopnse.requestParams().configurationModel.modelCustomizationId ).toEqual("testModelCustomizationId");
1231         expect( resopnse.requestParams().configurationId ).toEqual("testNodeId");
1232         expect( resopnse.requestParams().configStatus ).toEqual("testDELETE");
1233         expect( resopnse.requestParams().userId ).toEqual("testLoggedInUserId");
1234     });
1235
1236     test('Verify toggleConfigurationStatus will get call uibModal open that will return response ', ()  => {
1237         // given
1238         let resopnse = {};
1239
1240         serviceObject = {
1241             model:{
1242                 service:{
1243                     invariantUuid:"testInvariantUuid",
1244                     uuid:"testUuid",
1245                     name:"testService",
1246                     version:"testVersion",
1247                 }},
1248             instance:{
1249                 serviceInstanceId:"testServiceInstanceId",
1250             }
1251         };
1252
1253         configuration = {
1254             modelInvariantId:"testModelInvariantId",
1255             modelVersionId:"testModelVersionId",
1256             modelCustomizationId:"testModelCustomizationId",
1257             nodeId:"testNodeId",
1258             nodeStatus:"testNodeStatus",
1259         };
1260
1261         mockAaiService.getLoggedInUserID = (successFunction) => {
1262             successFunction( {data:"testLoggedInUserId"} );
1263         };
1264
1265         mockUibModal.open = (testResponse) => {
1266             resopnse = testResponse.resolve;
1267         };
1268
1269         mockCOMPONENT.MSO_CHANGE_CONFIG_STATUS_REQ = "testMsoChangeConfig";
1270
1271         // when
1272         $scope.toggleConfigurationStatus(serviceObject, configuration);
1273
1274         // then
1275         expect( resopnse.msoType() ).toEqual("testMsoChangeConfig");
1276         expect( resopnse.requestParams().serviceModel.modelInvariantId ).toEqual("testInvariantUuid");
1277         expect( resopnse.requestParams().serviceModel.modelVersionId ).toEqual("testUuid");
1278         expect( resopnse.requestParams().serviceModel.modelName ).toEqual("testService");
1279         expect( resopnse.requestParams().serviceModel.modelVersion ).toEqual("testVersion");
1280         expect( resopnse.requestParams().serviceInstanceId ).toEqual("testServiceInstanceId");
1281         expect( resopnse.requestParams().configurationModel.modelInvariantId ).toEqual("testModelInvariantId");
1282         expect( resopnse.requestParams().configurationModel.modelVersionId ).toEqual("testModelVersionId");
1283         expect( resopnse.requestParams().configurationModel.modelCustomizationId ).toEqual("testModelCustomizationId");
1284         expect( resopnse.requestParams().configurationId ).toEqual("testNodeId");
1285         expect( resopnse.requestParams().configStatus ).toEqual("testNodeStatus");
1286         expect( resopnse.requestParams().userId ).toEqual("testLoggedInUserId");
1287     });
1288
1289     test('Verify togglePortStatus will get call uibModal open that will return response ', ()  => {
1290         // given
1291         let resopnse = {};
1292
1293         let serviceObject = {
1294             model:{
1295                 service:{
1296                     invariantUuid:"testInvariantUuid",
1297                     uuid:"testUuid",
1298                     name:"testService",
1299                     version:"testVersion",
1300                 }},
1301             instance:{
1302                 serviceInstanceId:"testServiceInstanceId",
1303             }
1304         };
1305
1306         let configuration = {
1307             modelInvariantId:"testModelInvariantId",
1308             modelVersionId:"testModelVersionId",
1309             modelCustomizationId:"testModelCustomizationId",
1310             nodeId:"testNodeId",
1311         };
1312
1313         let port = {
1314             portId:"testPort",
1315             portStatus:"open",
1316         };
1317
1318         mockAaiService.getLoggedInUserID = (successFunction) => {
1319             successFunction( {data:"testLoggedInUserId"} );
1320         };
1321
1322         mockUibModal.open = (testResponse) => {
1323             resopnse = testResponse.resolve;
1324         };
1325
1326         mockCOMPONENT.MSO_CHANGE_PORT_STATUS_REQ = "testMsoPortStatus";
1327
1328         // when
1329         $scope.togglePortStatus(serviceObject, configuration,port);
1330
1331         // then
1332         expect( resopnse.msoType() ).toEqual("testMsoPortStatus");
1333         expect( resopnse.requestParams().serviceModel.modelInvariantId ).toEqual("testInvariantUuid");
1334         expect( resopnse.requestParams().serviceModel.modelVersionId ).toEqual("testUuid");
1335         expect( resopnse.requestParams().serviceModel.modelName ).toEqual("testService");
1336         expect( resopnse.requestParams().serviceModel.modelVersion ).toEqual("testVersion");
1337         expect( resopnse.requestParams().serviceInstanceId ).toEqual("testServiceInstanceId");
1338         expect( resopnse.requestParams().configurationModel.modelInvariantId ).toEqual("testModelInvariantId");
1339         expect( resopnse.requestParams().configurationModel.modelVersionId ).toEqual("testModelVersionId");
1340         expect( resopnse.requestParams().configurationModel.modelCustomizationId ).toEqual("testModelCustomizationId");
1341         expect( resopnse.requestParams().configurationId ).toEqual("testNodeId");
1342         expect( resopnse.requestParams().userId ).toEqual("testLoggedInUserId");
1343         expect( resopnse.requestParams().portId ).toEqual("testPort");
1344         expect( resopnse.requestParams().portStatus ).toEqual("open");
1345     });
1346
1347
1348     test('Verify getServiceInstancesSearchResults will get global customer Id from AaiService with proper service instance', ()  => {
1349         // given
1350         let selectedCustomer = 'testCustomer';
1351         let selectedInstanceIdentifierType = 'testInstanceIdentifierType';
1352         let selectedServiceInstance = 'testServiceInstance ';
1353         let selectedProject = "testProject";
1354         let selectedOwningEntity = "testOwningEntity";
1355
1356         let globalCustomerId = 'testCustomerIdResponse';
1357
1358         mockAaiService.getGlobalCustomerIdByInstanceIdentifier = jestMock.fn((serviceInstance, instanceIdentifierType) => {
1359             if(serviceInstance===selectedServiceInstance && instanceIdentifierType == selectedInstanceIdentifierType){
1360                 return Promise.resolve(globalCustomerId);
1361             }
1362             return Promise.reject();
1363         });
1364
1365         mockAaiService.getMultipleValueParamQueryString = ( element, subPath) => {
1366             return subPath + '/ ' + element;
1367         };
1368
1369         mockAaiService.getJoinedQueryString = jestMock.fn();
1370
1371         mock_.map = (element,id) => {
1372             return element;
1373         };
1374
1375         mockCOMPONENT.PROJECT_SUB_PATH = "test/project/sub";
1376         mockCOMPONENT.OWNING_ENTITY_SUB_PATH = "test/entity/sub";
1377         mockCOMPONENT.SELECTED_SUBSCRIBER_SUB_PATH = "test/subscriber/sub";
1378         mockCOMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH = "test/service/instance/sub";
1379         mockCOMPONENT.SELECTED_SERVICE_SUB_PATH = "text/service/sub";
1380
1381         mockUtilityService.hasContents = (element) => {
1382           if (  element ===  selectedCustomer ||
1383                 element === selectedServiceInstance ||
1384                 element === globalCustomerId )
1385               return true;
1386         };
1387
1388         window.location = {};
1389
1390         // when
1391         $scope.getServiceInstancesSearchResults(selectedCustomer, selectedInstanceIdentifierType, selectedServiceInstance, selectedProject, selectedOwningEntity);
1392
1393         // then
1394         expect(mockAaiService.getGlobalCustomerIdByInstanceIdentifier).toHaveBeenCalledWith(selectedServiceInstance,selectedInstanceIdentifierType);
1395     });
1396
1397     test('Verify getServiceInstancesSearchResults will alert error if non of parameters is located in UtilityService', ()  => {
1398         // given
1399         let selectedCustomer = 'testCustomer';
1400         let selectedInstanceIdentifierType = 'testInstanceIdentifierType';
1401         let selectedServiceInstance = 'testServiceInstance ';
1402         let selectedProject = "testProject";
1403         let selectedOwningEntity = "testOwningEntity";
1404
1405         let globalCustomerId = 'testCustomerIdResponse';
1406
1407         mockAaiService.getGlobalCustomerIdByInstanceIdentifier = (serviceInstance, instanceIdentifierType) => {
1408             if(serviceInstance===selectedServiceInstance && instanceIdentifierType == selectedInstanceIdentifierType){
1409                 return Promise.resolve(globalCustomerId);
1410             }
1411             return Promise.reject();
1412         };
1413
1414         mockAaiService.getMultipleValueParamQueryString = ( element, subPath) => {
1415             return subPath + '/ ' + element;
1416         };
1417
1418         mockAaiService.getJoinedQueryString = (queryArray) => {
1419             let joinedQuery = "";
1420             queryArray.forEach((element)=>{
1421                 joinedQuery += element + "//"
1422             });
1423
1424             return joinedQuery;
1425         };
1426
1427         mock_.map = (element,id) => {
1428             return element;
1429         };
1430
1431         mockCOMPONENT.PROJECT_SUB_PATH = "test/project/sub";
1432         mockCOMPONENT.OWNING_ENTITY_SUB_PATH = "test/entity/sub";
1433         mockCOMPONENT.SELECTED_SUBSCRIBER_SUB_PATH = "test/subscriber/sub";
1434         mockCOMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH = "test/service/instance/sub";
1435         mockCOMPONENT.SELECTED_SERVICE_SUB_PATH = "text/service/sub";
1436
1437         mockUtilityService.hasContents = (element) => {
1438                 return false;
1439         };
1440
1441         alert = jestMock.fn();
1442         mockFIELD.ERROR.SELECT = "testError";
1443
1444         window.location = {};
1445
1446         // when
1447         $scope.getServiceInstancesSearchResults(selectedCustomer, selectedInstanceIdentifierType, selectedServiceInstance, selectedProject, selectedOwningEntity);
1448
1449         // then
1450         expect(alert).toHaveBeenCalledWith("testError");
1451     });
1452
1453     test('Verify getServiceInstancesSearchResults will navigate to proper page if selected service instance is not present in UtilityService', ()  => {
1454         // given
1455         let selectedCustomer = 'testCustomer';
1456         let selectedInstanceIdentifierType = 'testInstanceIdentifierType';
1457         let selectedServiceInstance = 'testServiceInstance ';
1458         let selectedProject = "testProject";
1459         let selectedOwningEntity = "testOwningEntity";
1460
1461         let globalCustomerId = 'testCustomerIdResponse';
1462
1463         mockAaiService.getGlobalCustomerIdByInstanceIdentifier = (serviceInstance, instanceIdentifierType) => {
1464             if(serviceInstance===selectedServiceInstance && instanceIdentifierType == selectedInstanceIdentifierType){
1465                 return Promise.resolve(globalCustomerId);
1466             }
1467             return Promise.reject();
1468         };
1469
1470         mockAaiService.getMultipleValueParamQueryString = ( element, subPath) => {
1471             return subPath + element;
1472         };
1473
1474         mockAaiService.getJoinedQueryString = jestMock.fn();
1475
1476         mock_.map = (element,id) => {
1477             return element;
1478         };
1479
1480         mockCOMPONENT.PROJECT_SUB_PATH = "test/project/sub/";
1481         mockCOMPONENT.OWNING_ENTITY_SUB_PATH = "test/entity/sub/";
1482         mockCOMPONENT.SELECTED_SUBSCRIBER_SUB_PATH = "test/subscriber/sub/";
1483         mockCOMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH = "test/service/instance/sub/";
1484         mockCOMPONENT.SELECTED_SERVICE_SUB_PATH = "text/service/sub/";
1485
1486
1487         mockUtilityService.hasContents = (element) => {
1488             return element === selectedCustomer;
1489         };
1490
1491         window.location = {};
1492
1493         // when
1494         $scope.getServiceInstancesSearchResults(selectedCustomer, selectedInstanceIdentifierType, selectedServiceInstance, selectedProject, selectedOwningEntity);
1495
1496         // then
1497         expect(mockAaiService.getJoinedQueryString).toHaveBeenCalledWith(expect.arrayContaining([
1498             mockCOMPONENT.PROJECT_SUB_PATH+selectedProject,
1499             mockCOMPONENT.OWNING_ENTITY_SUB_PATH+selectedOwningEntity,
1500             mockCOMPONENT.SELECTED_SUBSCRIBER_SUB_PATH+selectedCustomer
1501         ]));
1502     });
1503
1504
1505 });