2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 require('./aaiSubscriberController');
22 require('../services/dataService');
24 const jestMock = require('jest-mock');
26 describe('TreeCtrl testing', () => {
31 angular.mock.module('app')
34 beforeEach(inject(function (_$controller_) {
36 _$controller_('TreeCtrl', {
41 test('Verify expandAll calls broadcast with expand-all parameter', () => {
43 const broadcast = jestMock.fn();
44 $scope.$broadcast = broadcast;
47 ANGULAR_UI_TREE_EXPANDALL: "angular-ui-tree:expand-all"
53 expect(broadcast).toHaveBeenCalledWith("angular-ui-tree:expand-all");
56 test('Verify collapseAll calls broadcast with collapse-all parameter', () => {
58 const broadcast = jestMock.fn();
59 $scope.$broadcast = broadcast;
62 ANGULAR_UI_TREE_COLLAPSEALL: "angular-ui-tree:collapse-all"
68 expect(broadcast).toHaveBeenCalledWith("angular-ui-tree:collapse-all");
71 test('Verify toggle calls toggle in given scope', () => {
74 testScope.toggle = jestMock.fn();
76 $scope.toggle(testScope);
78 expect(testScope.toggle).toHaveBeenCalled();
81 test('Verify remove calls remove in given scope', () => {
84 testScope.remove = jestMock.fn();
86 $scope.remove(testScope);
88 expect(testScope.remove).toHaveBeenCalled();
91 test('Verify moveLastToTheBeginning pops last element from data and puts it on the beginning', () => {
93 $scope.data = [ 'a', 'b', 'c' ];
94 const expectedResult = [ 'c', 'a', 'b' ];
97 $scope.moveLastToTheBeginning();
99 expect($scope.data).toMatchObject(expectedResult);
102 test('Verify newSubItem pushes new item into given scope', () => {
104 const testScope = {};
105 const testModel = {};
108 testModel.nodes = [];
109 testModel.title = 'testObject';
111 const expectedResult = {
113 title: 'testObject.1',
117 testScope.$modelValue = testModel;
120 $scope.newSubItem(testScope);
122 expect(testModel.nodes.length).toBe(1);
123 expect(testModel.nodes[0]).toMatchObject(expectedResult);
127 describe('aaiSubscriberController testing', () => {
130 angular.mock.module('app')
138 SELECT_SERVICE: 'testService'
141 SERVICE_INSTANCE_ID: 'testID',
142 SERVICE_INSTANCE_NAME: 'testName'
145 INVENTORY_RESPONSE_ITEMS: 0,
146 INVENTORY_RESPONSE_ITEM: 0
149 MSO_CTRL_BTN: 'testButtonStyle',
156 FETCHING_SERVICE_TYPES: 'testServiceType',
157 SELECT: 'testAlertError',
162 let mockCOMPONENT = {
163 SHOW_COMPONENT_DETAILS: 'testComponentDetails',
164 VNF: 'testComponentVNF',
165 WELCOME_PATH: 'http://test/welcome/',
166 CREATE_INSTANCE_PATH: 'testInstancePath',
170 let mockAaiService = {
171 getSubscriptionServiceTypeList(customerId,successFunction,failFunction){},
172 getServiceModelsByServiceType(queryId,customerId,serviceType,successFunction,failFunction){},
173 searchServiceInstances(query){},
176 let mockAsdcService = {
178 shouldTakeTheAsyncInstantiationFlow(serviceModel){},
181 let mockPropertyService = {
182 retrieveMsoMaxPollingIntervalMsec(){return 1000},
183 setMsoMaxPollingIntervalMsec(msecs){},
184 retrieveMsoMaxPolls(){return 1000},
185 setMsoMaxPolls(polls){},
188 let mockUtilityService = {
191 let mockVidService = {
205 let mockOwningEntityService = {
206 getOwningEntityProperties(callBack){}
213 $ = (selector) => {return mockSelector};
215 addClass(){return this},
216 removeClass(){return this},
221 reduce(service,iterateeFunction,accumulatorFunction){},
222 forEach(services,iteratedFunction){},
223 includes(array, status){
224 return array.includes(status);
230 let mockFeatureFlags = {};
232 let mockVIDCONFIGURATION = {};
236 let mockUibModal = {};
240 beforeEach(inject(function (_$controller_,DataService,$timeout) {
242 $on(request,toDoFunction){}
245 dataService = DataService;
247 _$controller_('aaiSubscriberController', {
249 COMPONENT: mockCOMPONENT,
252 DataService: DataService,
253 PropertyService: mockPropertyService,
256 $location: mockLocation,
259 $uibModal: mockUibModal,
260 VIDCONFIGURATION: mockVIDCONFIGURATION,
261 UtilityService: mockUtilityService,
262 vidService: mockVidService,
263 AaiService: mockAaiService,
265 OwningEntityService: mockOwningEntityService,
266 AsdcService: mockAsdcService,
267 featureFlags: mockFeatureFlags,
273 test('Verify showVnfDetails calls proper broadcast methots with proper parameters', () => {
275 const broadcast = jestMock.fn();
276 $scope.$broadcast = broadcast;
278 aaiResult = [[['test']]];
281 $scope.showVnfDetails('testVNF');
284 expect(broadcast).toHaveBeenCalledWith(mockCOMPONENT.SHOW_COMPONENT_DETAILS, { componentId: mockCOMPONENT.VNF,callbackFunction: expect.any(Function) } );
287 test('Verify getSubs will call fetchSubs and fetchServices and gets gets customer list from AaiService on success', () => {
289 mockAaiService.getSubList = (successFunction,failFunction) => {
290 successFunction(['testCustomer1', 'testCustomer2']);
292 mockAaiService.getServices2 = (successFunction,failFunction) => {
293 successFunction('testListId');
300 expect( $scope.customerList ).toContain('testCustomer1','testCustomer2');
301 expect( dataService.getServiceIdList() ).toEqual('testListId');
304 test('Verify getSubs will call fetchSubs and fetchServices and return error message from AaiService on fail', () => {
306 mockAaiService.getSubList = (successFunction,failFunction) => {
307 failFunction({status: 404, data: 'getSubListTestErrorMessage'} );
309 mockAaiService.getServices2 = (successFunction,failFunction) => {
310 failFunction({status: 404, data: 'getServices02TestErrorMessage'} );
317 expect( $scope.errorDetails ).toEqual('getServices02TestErrorMessage');
320 test('Verify refreshServiceTypes will call getServiceTypesList and gets service type list from AaiService, with proper customerID ', () => {
322 dataService.setGlobalCustomerId('testCustomerID');
323 dataService.setServiceIdList(['testServiceId1','testServiceId2']);
325 mockAaiService.getSubscriptionServiceTypeList = (customerId, successFunction,failFunction) => {
326 if (customerId === 'testCustomerID'){
327 successFunction(['testServiceType1', 'testServiceType2']);
332 $scope.refreshServiceTypes('testCustomerID');
335 expect( $scope.serviceTypeList ).toContain('testServiceType1','testServiceType2');
338 test('Verify refreshServiceTypes will call getServiceTypesList and return error message with wrong customerID ', () => {
340 mockAaiService.getSubscriptionServiceTypeList = (customerId, successFunction,failFunction) => {
341 if (customerId === 'testWrongCustomerID'){
342 failFunction( {status: 404, data: 'testErrorMessage'} );
347 $scope.refreshServiceTypes('testWrongCustomerID');
350 expect( $scope.errorDetails ).toEqual('testErrorMessage');
353 test('Verify refreshServiceTypes will call getServiceTypesList and calls alert with no customerID ', () => {
355 alert = jestMock.fn();
358 $scope.refreshServiceTypes('');
361 expect( alert ).toHaveBeenCalledWith(mockFIELD.ERROR.SELECT);
364 test('Verify getAaiServiceModels will set correct location ', () => {
366 mockLocation.path = jestMock.fn();
369 $scope.getAaiServiceModels('testServiceType','testSubName');
372 expect(mockLocation.path).toHaveBeenCalledWith(mockCOMPONENT.CREATE_INSTANCE_PATH);
375 test('Verify getAaiServiceModels wont set correct location if service type is empty', () => {
377 mockLocation.path = jestMock.fn();
380 $scope.getAaiServiceModels('','testSubName');
383 expect(mockLocation.path).not.toHaveBeenCalled();
386 test('Verify getAaiServiceModelsList will call AaiService getServiceModelsByServiceType and will set wholeData ', () => {
389 mockAaiService.getServiceModelsByServiceType = (queryId,customerId,serviceType,successFunction,failFunction) => {
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'] = [];
397 testItem['extra-properties'] = [];
398 testItem['extra-properties']['extra-property'] = [[],[],[],[],[],[],[]];
399 testItem['extra-properties']['extra-property'][6]["property-value"] = 1.546;
401 testItem['extra-properties']['extra-property'][4]['property-value'] = 0;
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;
407 successFunction(response);
410 mock_.reduce = (service,iterateeFunction,accumulatorFunction) => {
411 return iterateeFunction([],service);
413 mock_.forEach = (service,iterateeFunction) => {
414 iterateeFunction(service);
416 mock_.maxBy = (item,maxFunction) => {
417 return maxFunction( item[0][0] )
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');
426 $scope.getAaiServiceModelsList();
429 expect($scope.services[0]).toEqual(1.546);
430 expect($scope.serviceType).toEqual('testServiceType');
433 test('Verify getAaiServiceModelsList will call AaiService getServiceModelsByServiceType and will return error data on fail ', () => {
435 dataService.setServiceIdList([['testServiceId1','testServiceId2']]);
436 dataService.setSubscribers(['testSubscriber1,testSubscriber2']);
438 mockAaiService.getServiceModelsByServiceType = (queryId,customerId,serviceType,successFunction,failFunction) => {
439 failFunction( {status: 404, data: 'testErrorMessage'})
443 $scope.getAaiServiceModelsList();
446 expect($scope.errorDetails).toEqual('testErrorMessage');
449 test('Verify getAaiServiceModelsList will call AaiService getServiceModelsByServiceType and will return error data if respose data is empty ', () => {
451 dataService.setServiceIdList([['testServiceId1','testServiceId2']]);
452 dataService.setSubscribers(['testSubscriber1,testSubscriber2']);
454 mockAaiService.getServiceModelsByServiceType = (queryId,customerId,serviceType,successFunction,failFunction) => {
457 response.data['inventory-response-item'] = [];
458 successFunction(response);
462 $scope.getAaiServiceModelsList();
465 expect($scope.status).toEqual('Failed to get service models from SDC.');
468 test('Verify deployService will call http get method to rest model service', () => {
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(
479 {id:"subscriberName",value:"testSubscriber"},
480 {id:"serviceType",value:"testService"}
482 instanceId:"testInstance"
487 "model-version-id": 101
491 $scope.refreshSubs = jestMock.fn();
493 let mockedGetPromise = Promise.resolve({data: {service: {name: 'testServiceName' }}});
494 mockHttp.get = () => mockedGetPromise;
497 $scope.deployService(service,true);
500 test('Verify deployService will log error if get fails ', () => {
503 let mockedGetPromise = Promise.reject({code: 404});
504 mockHttp.get = () => mockedGetPromise;
508 "model-version-id": 101
513 $scope.deployService(service,false);
516 test('Verify refreshSubs fetches Subs and Services', () => {
518 $scope.fetchSubs = jestMock.fn();
519 $scope.fetchServices = jestMock.fn();
520 $scope.init = jestMock.fn();
522 mockFIELD.PROMPT.REFRESH_SUB_LIST = 'testRefreshMock';
525 $scope.refreshSubs();
528 expect($scope.init).toHaveBeenCalled();
529 expect($scope.fetchSubs).toHaveBeenCalledWith(mockFIELD.PROMPT.REFRESH_SUB_LIST);
530 expect($scope.fetchServices).toHaveBeenCalled();
534 test('Verify loadOwningEntity gets owning entity properties', () => {
536 mockOwningEntityService.getOwningEntityProperties = (callBack) => {
537 callBack({owningEntity:'testOwner',project:'testProject'});
541 $scope.loadOwningEntity();
544 expect($scope.owningEntities).toEqual('testOwner');
545 expect($scope.projects).toEqual('testProject');
548 test('Verify getPermitted returns items permission', () => {
550 mockFIELD.ID.IS_PERMITTED = 'testPermission';
554 $scope.getPermitted({})
555 ).toEqual(undefined);
558 $scope.getPermitted({isPermitted:true})
562 $scope.getPermitted({isPermitted:false})
563 ).toEqual(undefined);
566 $scope.getPermitted({isPermitted:false,testPermission:true})
570 $scope.getPermitted({testPermission:false,testPermission:false})
574 $scope.getPermitted({isPermitted:true,testPermission:false})
578 test('Verify getSubDetails calls to aaiService for service instance', () => {
580 let aaiPromise = Promise.resolve(
583 {globalCustomerId:"testCustomerId01",subscriberName:"testCustomer1"},
584 {globalCustomerId:"testCustomerId02",subscriberName:"testCustomer2"},
588 mockLocation.url = () => {return ""};
590 mockAaiService.searchServiceInstances = (query)=>aaiPromise;
593 $scope.getSubDetails();
596 test('Verify getSubDetails catches bad response', () => {
598 let aaiPromise = Promise.reject(
599 {data:'testError',status:404});
601 mockLocation.url = () => {return ""};
603 mockAaiService.searchServiceInstances = (query)=>aaiPromise;
606 $scope.getSubDetails();
609 test('Verify getComponentList returns list of components if query is correct', () => {
611 mockLocation.search = () => {
613 subscriberId: 'testSubscriberID',
614 serviceType: 'testService',
615 serviceInstanceId: "testServiceInstanceID",
616 subscriberName: "testSubscriber",
617 aaiModelVersionId: "testModelVersion"
621 mockVidService.getModel = () => {
624 uuid: "testModelVersion",
629 mockUtilityService.hasContents = (content) => {
630 if (content==="testModelVersion") {
636 mockQ.resolve = (item) => {return Promise.resolve("testModelVersion")};
638 $scope.prepareScopeWithModel = () => {return Promise.resolve()};
640 mockAaiService.getVlansByNetworksMapping = (globalCustomerId, serviceType, serviceInstanceId, modelServiceUuid) => {
641 return Promise.resolve({serviceNetworks:true});
647 uuid: 'testModelServiceUuid'
652 mockedLog.debug = () => {};
653 mockUtilityService.isObjectEmpty = () => {
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';
664 mockAaiService.runNamedQuery = (namedQueryId,globalCustomerId,serviceType,serviceInstanceId,successFunction,failureFunction) => {
674 return Promise.resolve("testComponentList");
677 mockAaiService.getPortMirroringData = (portMirroringConfigurationIds) => {
678 return Promise.resolve({data:[8080,9090]});
681 mockAaiService.getPortMirroringSourcePorts = (portMirroringConfigurationIds) => {
682 return Promise.resolve({data:[8888,9999]})
685 mockAaiService.getSubscriberName = (customerId, successFunction) => {
686 successFunction({subscriberName:"testSubscriber1",serviceSubscriptions:[[
687 [[[{'testServiceInstanceID':'testServiceInstanceID','orchestration-status':'testStatus'},{'testServiceInstanceID':'','orchestration-status':''}]]],
688 [[[{'testServiceInstanceID':'','orchestration-status':''}]]]
693 mock_.map = (serviceNetworkVlans, networkId) => {
694 return ["aaiNetworkId1","aaiNetworkId2"];
698 return $scope.getComponentList('','').
700 expect(components).toEqual("testComponentList")
705 test('Verify handleServerError sets proper $scope.error and $scope.status', () => {
707 mockUtilityService.getHttpErrorMessage = (response) => {return response.statusText};
708 mockFIELD.ERROR.SYSTEM_ERROR = "testSystemError";
709 mockFIELD.STATUS.ERROR = "testStatusError";
712 $scope.handleServerError({statusText:'testStatusError'},'');
715 expect($scope.error).toEqual("testSystemError (testStatusError)");
716 expect($scope.status).toEqual("testStatusError");
719 test('Verify showContentError sets proper $scope.error and $scope.status if UtilityService has that content', () => {
721 mockFIELD.STATUS.ERROR = "testStatusError";
723 mockUtilityService.hasContents = (content) => {
724 return content === 'testContentError';
729 $scope.showContentError('testContentError');
732 expect($scope.error).toEqual("System failure (testContentError)");
733 expect($scope.status).toEqual("testStatusError");
736 test('Verify showContentError sets proper $scope.error and $scope.status if UtilityService has not that content', () => {
738 mockFIELD.ERROR.SYSTEM_ERROR = "testSystemError";
739 mockFIELD.STATUS.ERROR = "testStatusError";
741 mockUtilityService.hasContents = (content) => {
746 $scope.showContentError('testContentError');
749 expect($scope.error).toEqual("testSystemError");
750 expect($scope.status).toEqual("testStatusError");
753 test('Verify handleInitialResponse shows error for response codes other then 200,201,202', () => {
761 mockFIELD.ERROR.MSO = "testSystemError";
762 mockFIELD.ERROR.AAI_FETCHING_CUST_DATA = "testStatusError:";
764 $scope.showError = jestMock.fn();
767 $scope.handleInitialResponse(response);
770 expect($scope.showError).toHaveBeenCalledWith("testSystemError");
771 expect($scope.status).toEqual("testStatusError:404");
774 test('Verify handleInitialResponse updates customer list with response code 202', () => {
777 'globalCustomerId':'testCustomerID',
778 "subscriberName":'testSubscriber',
788 mockFIELD.ID.GLOBAL_CUSTOMER_ID = 'globalCustomerId';
789 mockFIELD.ID.SUBNAME = 'subscriberName';
790 mockFIELD.ID.IS_PERMITTED = 'isPermitted';
793 $scope.handleInitialResponse(response);
796 expect($scope.customerList).toContainEqual(customer);
799 test('Verify handleInitialResponse calls showContentError with wrong response ', () => {
801 $scope.showContentError = jestMock.fn();
804 $scope.handleInitialResponse(null);
807 expect($scope.showContentError).toHaveBeenCalledWith(expect.objectContaining({message:"Cannot read property 'data' of null"}));
810 test('Verify isConfigurationDataAvailiable will return proper response', () => {
812 mockedLog.debug = jestMock.fn();
814 expect( $scope.isConfigurationDataAvailiable({configData:{}}) ).toEqual(true);
815 expect( $scope.isConfigurationDataAvailiable({configData:{errorDescription:"testerror"}}) ).toEqual(false);
816 expect( $scope.isConfigurationDataAvailiable({}) ).toEqual(undefined);
820 test('Verify isActivateDeactivateEnabled will return proper response', () => {
822 mockedLog.debug = jestMock.fn();
824 $scope.serviceOrchestrationStatus = "active";
825 mockCOMPONENT.ACTIVATE_SERVICE_STATUSES = ["active","up"];
828 expect( $scope.isActivateDeactivateEnabled("deactivate")).toEqual(true);
829 expect( $scope.isActivateDeactivateEnabled("activate")).toEqual(true);
831 $scope.serviceOrchestrationStatus = "down";
832 mockCOMPONENT.ACTIVATE_SERVICE_STATUSES = ["active","up"];
834 expect( $scope.isActivateDeactivateEnabled("deactivate")).toEqual(false);
835 expect( $scope.isActivateDeactivateEnabled("activate")).toEqual(false);
837 $scope.serviceOrchestrationStatus = null;
839 expect( $scope.isActivateDeactivateEnabled(null)).toEqual(false);
843 test('Verify isShowVerifyService will return proper response base on feature flag', () => {
845 mockCOMPONENT.FEATURE_FLAGS.FLAG_SHOW_VERIFY_SERVICE = 'showVerifyService';
846 mockFeatureFlags.isOn = (flag) => {
847 if (flag === 'showVerifyService'){return true};
851 expect( $scope.isShowVerifyService()).toEqual(true);
854 test('Verify isEnableVerifyService will return false if is not ALaCarte', () => {
856 dataService.setALaCarte(false);
859 expect( $scope.isEnableVerifyService()).toEqual(false);
862 test('Verify isEnableVerifyService will return verifyButtonEnabled if is ALaCarte', () => {
864 dataService.setALaCarte(true);
867 $scope.verifyButtonEnabled = true;
868 expect( $scope.isEnableVerifyService()).toEqual(true);
870 $scope.verifyButtonEnabled = false;
871 expect( $scope.isEnableVerifyService()).toEqual(false);
874 test('Verify activateVerifyService will post POMBA verification', () => {
876 mockCOMPONENT.VERIFY_SERVICE_URL = "/testURL";
878 mockAaiService.postPOMBAverificationRequest = jestMock.fn();
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";
888 $scope.activateVerifyService();
891 expect(mockAaiService.postPOMBAverificationRequest).toHaveBeenCalledWith(
893 expect.objectContaining({'serviceInstanceList':[expect.any(Object)]}),
894 expect.objectContaining({'headers':expect.any(Object)}));
897 test('Verify isShowAssignmentsEnabled will return proper response determine by feature flag', () => {
899 mockCOMPONENT.FEATURE_FLAGS.FLAG_SHOW_ASSIGNMENTS = "showAssignment";
901 mockFeatureFlags.isOn = (flag) => {
902 if (flag === 'showAssignment'){return true};
906 $scope.serviceOrchestrationStatus = "assigned";
907 expect( $scope.isShowAssignmentsEnabled() ).toEqual(true);
909 $scope.serviceOrchestrationStatus = "notAssigned";
910 expect( $scope.isShowAssignmentsEnabled() ).toEqual(false);
912 $scope.serviceOrchestrationStatus = null;
913 expect( $scope.isShowAssignmentsEnabled() ).toEqual(false);
916 test('Verify isActivateFabricConfiguration will return proper response determine by feature flag', () => {
918 mockCOMPONENT.FEATURE_FLAGS.FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS = "fabricConfigurationAssignment";
919 $scope.hasFabricConfigurations = true;
921 mockFeatureFlags.isOn = (flag) => {
922 if (flag === 'fabricConfigurationAssignment'){return true};
926 $scope.serviceOrchestrationStatus = "assigned";
927 expect( $scope.isActivateFabricConfiguration() ).toEqual(true);
929 $scope.serviceOrchestrationStatus = "notAssigned";
930 expect( $scope.isActivateFabricConfiguration() ).toEqual(false);
932 $scope.serviceOrchestrationStatus = null;
933 expect( $scope.isActivateFabricConfiguration() ).toEqual(false);
936 test('Verify isResumeShown will return proper response determine by feature flag with disabled ActivateDeactivate', () => {
938 $scope.serviceOrchestrationStatus = "assigned";
939 $scope.isActivateDeactivateEnabled = () => {return false};
942 expect( $scope.isResumeShown("assigned") ).toEqual(true);
943 expect( $scope.isResumeShown("unAssigned") ).toEqual(false);
947 test('Verify isResumeShown will return proper response determine by feature flag with enable ActivateDeactivate', () => {
949 $scope.serviceOrchestrationStatus = "assigned";
950 $scope.isActivateDeactivateEnabled = () => {return true};
953 expect( $scope.isResumeShown("assigned") ).toEqual(false);
954 expect( $scope.isResumeShown("unAssigned") ).toEqual(false);
958 test('Verify close will call time out cancel and hides pop up window if timer is defined', () => {
961 $scope.isPopupVisible = true;
963 timeout.cancel = jestMock.fn();
969 expect(timeout.cancel).toHaveBeenCalledWith(1000);
970 expect($scope.isPopupVisible).toEqual(false);
973 test('Verify close will hide pop up window if timer is undefined', () => {
975 $scope.timer = undefined;
976 $scope.isPopupVisible = true;
982 expect($scope.isPopupVisible).toEqual(false);
985 test('Verify reloadRoute will call reload on rout', () => {
987 mockRoute.reload = jestMock.fn();
990 $scope.reloadRoute();
993 expect(mockRoute.reload).toHaveBeenCalled();
996 test('Verify prevPage will decrease currentPage', () => {
998 $scope.currentPage = 5;
1004 expect($scope.currentPage).toEqual(4);
1007 test('Verify showAssignmentsSDNC will return proper response base on VIDCONFIGURATION', () => {
1009 $scope.service = {};
1010 $scope.service.instance = {};
1011 $scope.service.instance.id = "testServiceInstanceId";
1013 mockVIDCONFIGURATION.SDNC_SHOW_ASSIGNMENTS_URL = "test/ulr/to/<SERVICE_INSTANCE_ID>";
1016 expect( $scope.showAssignmentsSDNC() ).toEqual("test/ulr/to/testServiceInstanceId");
1019 test('Verify showAssignmentsSDNC will return null if service instance dos not exist or is null', () => {
1021 $scope.service = {};
1024 expect( $scope.showAssignmentsSDNC() ).toEqual(null);
1026 $scope.service.instance = null;
1027 expect( $scope.showAssignmentsSDNC() ).toEqual(null);
1030 test('Verify activateFabricConfigurationMSO with logged in user, will call uibModal open that will return response ', () => {
1034 mockCOMPONENT.MSO_ACTIVATE_FABRIC_CONFIGURATION_REQ = "testMsoActivateType";
1036 $scope.service = {};
1037 $scope.service.model = {};
1038 $scope.service = {};
1039 $scope.serviceInstanceId= "testServiceInstanceId";
1041 dataService.setLoggedInUserId("testUserId");
1043 mockUibModal.open = (testResponse) => {
1044 resopnse = testResponse.resolve;
1048 $scope.activateFabricConfigurationMSO();
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);
1057 test('Verify activateFabricConfigurationMSO without logged in user will first get user id from AaiService , will call uibModal open that will return response ', () => {
1061 mockCOMPONENT.MSO_ACTIVATE_FABRIC_CONFIGURATION_REQ = "testMsoActivateType";
1063 $scope.service = {};
1064 $scope.service.model = {};
1065 $scope.service = {};
1066 $scope.serviceInstanceId= "testServiceInstanceId";
1069 mockAaiService.getLoggedInUserID = (onSuccess) => {
1070 onSuccess({data:"testAaiUserId"});
1073 mockUibModal.open = (testResponse) => {
1074 resopnse = testResponse.resolve;
1078 $scope.activateFabricConfigurationMSO();
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);
1087 test('Verify activateMSOInstance with logged in user, will get aicZone from AaiService and call uibModal open that will return response ', () => {
1091 mockCOMPONENT.MSO_ACTIVATE_SERVICE_REQ = "testMsoActivateType";
1093 $scope.service = {};
1094 $scope.service.model = {};
1095 $scope.service.instance = {};
1097 dataService.setLoggedInUserId("testUserId");
1099 mockAaiService.getAicZoneForPNF = (globalCustomerId,serviceType,serviceInstanceId,getZoneFunction) => {
1100 getZoneFunction("testAicZone");
1103 mockUibModal.open = (testResponse) => {
1104 resopnse = testResponse.resolve;
1108 $scope.activateMSOInstance();
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);
1117 test('Verify activateMSOInstance without logged in user will first get user id from AaiService , will call uibModal open that will return response ', () => {
1121 mockCOMPONENT.MSO_ACTIVATE_SERVICE_REQ = "testMsoActivateType";
1123 $scope.service = {};
1124 $scope.service.model = {};
1125 $scope.service.instance = {};
1128 mockAaiService.getAicZoneForPNF = (globalCustomerId,serviceType,serviceInstanceId,getZoneFunction) => {
1129 getZoneFunction("testAicZone");
1132 mockAaiService.getLoggedInUserID = (onSuccess) => {
1133 onSuccess({data:"testAaiUserId"});
1136 mockUibModal.open = (testResponse) => {
1137 resopnse = testResponse.resolve;
1141 $scope.activateMSOInstance();
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);
1150 test('Verify deactivateMSOInstance will get call uibModal open that will return response ', () => {
1154 mockCOMPONENT.MSO_DEACTIVATE_SERVICE_REQ = "testMsoDeactivateType";
1156 $scope.service = {};
1157 $scope.service.model = {};
1158 $scope.service.instance = {};
1161 mockAaiService.getAicZoneForPNF = (globalCustomerId,serviceType,serviceInstanceId,getZoneFunction) => {
1162 getZoneFunction("testAicZone");
1165 mockAaiService.getLoggedInUserID = (onSuccess) => {
1166 onSuccess({data:"testAaiUserId"});
1169 mockUibModal.open = (testResponse) => {
1170 resopnse = testResponse.resolve;
1174 $scope.deactivateMSOInstance();
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);
1183 test('Verify deleteConfiguration will get call uibModal open that will return response ', () => {
1190 invariantUuid:"testInvariantUuid",
1193 version:"testVersion",
1196 serviceInstanceId:"testServiceInstanceId",
1201 modelInvariantId:"testModelInvariantId",
1202 modelVersionId:"testModelVersionId",
1203 modelCustomizationId:"testModelCustomizationId",
1204 nodeId:"testNodeId",
1205 DELETE:"testDELETE",
1208 mockCOMPONENT.MSO_DELETE_CONFIGURATION_REQ = "testMsoDeleteType";
1210 mockAaiService.getLoggedInUserID = (successFunction) => {
1211 successFunction( {data:"testLoggedInUserId"} );
1214 mockUibModal.open = (testResponse) => {
1215 resopnse = testResponse.resolve;
1219 $scope.deleteConfiguration(serviceObject, configuration);
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");
1236 test('Verify toggleConfigurationStatus will get call uibModal open that will return response ', () => {
1243 invariantUuid:"testInvariantUuid",
1246 version:"testVersion",
1249 serviceInstanceId:"testServiceInstanceId",
1254 modelInvariantId:"testModelInvariantId",
1255 modelVersionId:"testModelVersionId",
1256 modelCustomizationId:"testModelCustomizationId",
1257 nodeId:"testNodeId",
1258 nodeStatus:"testNodeStatus",
1261 mockAaiService.getLoggedInUserID = (successFunction) => {
1262 successFunction( {data:"testLoggedInUserId"} );
1265 mockUibModal.open = (testResponse) => {
1266 resopnse = testResponse.resolve;
1269 mockCOMPONENT.MSO_CHANGE_CONFIG_STATUS_REQ = "testMsoChangeConfig";
1272 $scope.toggleConfigurationStatus(serviceObject, configuration);
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");
1289 test('Verify togglePortStatus will get call uibModal open that will return response ', () => {
1293 let serviceObject = {
1296 invariantUuid:"testInvariantUuid",
1299 version:"testVersion",
1302 serviceInstanceId:"testServiceInstanceId",
1306 let configuration = {
1307 modelInvariantId:"testModelInvariantId",
1308 modelVersionId:"testModelVersionId",
1309 modelCustomizationId:"testModelCustomizationId",
1310 nodeId:"testNodeId",
1318 mockAaiService.getLoggedInUserID = (successFunction) => {
1319 successFunction( {data:"testLoggedInUserId"} );
1322 mockUibModal.open = (testResponse) => {
1323 resopnse = testResponse.resolve;
1326 mockCOMPONENT.MSO_CHANGE_PORT_STATUS_REQ = "testMsoPortStatus";
1329 $scope.togglePortStatus(serviceObject, configuration,port);
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");
1348 test('Verify getServiceInstancesSearchResults will get global customer Id from AaiService with proper service instance', () => {
1350 let selectedCustomer = 'testCustomer';
1351 let selectedInstanceIdentifierType = 'testInstanceIdentifierType';
1352 let selectedServiceInstance = 'testServiceInstance ';
1353 let selectedProject = "testProject";
1354 let selectedOwningEntity = "testOwningEntity";
1356 let globalCustomerId = 'testCustomerIdResponse';
1358 mockAaiService.getGlobalCustomerIdByInstanceIdentifier = jestMock.fn((serviceInstance, instanceIdentifierType) => {
1359 if(serviceInstance===selectedServiceInstance && instanceIdentifierType == selectedInstanceIdentifierType){
1360 return Promise.resolve(globalCustomerId);
1362 return Promise.reject();
1365 mockAaiService.getMultipleValueParamQueryString = ( element, subPath) => {
1366 return subPath + '/ ' + element;
1369 mockAaiService.getJoinedQueryString = jestMock.fn();
1371 mock_.map = (element,id) => {
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";
1381 mockUtilityService.hasContents = (element) => {
1382 if ( element === selectedCustomer ||
1383 element === selectedServiceInstance ||
1384 element === globalCustomerId )
1388 window.location = {};
1391 $scope.getServiceInstancesSearchResults(selectedCustomer, selectedInstanceIdentifierType, selectedServiceInstance, selectedProject, selectedOwningEntity);
1394 expect(mockAaiService.getGlobalCustomerIdByInstanceIdentifier).toHaveBeenCalledWith(selectedServiceInstance,selectedInstanceIdentifierType);
1397 test('Verify getServiceInstancesSearchResults will alert error if non of parameters is located in UtilityService', () => {
1399 let selectedCustomer = 'testCustomer';
1400 let selectedInstanceIdentifierType = 'testInstanceIdentifierType';
1401 let selectedServiceInstance = 'testServiceInstance ';
1402 let selectedProject = "testProject";
1403 let selectedOwningEntity = "testOwningEntity";
1405 let globalCustomerId = 'testCustomerIdResponse';
1407 mockAaiService.getGlobalCustomerIdByInstanceIdentifier = (serviceInstance, instanceIdentifierType) => {
1408 if(serviceInstance===selectedServiceInstance && instanceIdentifierType == selectedInstanceIdentifierType){
1409 return Promise.resolve(globalCustomerId);
1411 return Promise.reject();
1414 mockAaiService.getMultipleValueParamQueryString = ( element, subPath) => {
1415 return subPath + '/ ' + element;
1418 mockAaiService.getJoinedQueryString = (queryArray) => {
1419 let joinedQuery = "";
1420 queryArray.forEach((element)=>{
1421 joinedQuery += element + "//"
1427 mock_.map = (element,id) => {
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";
1437 mockUtilityService.hasContents = (element) => {
1441 alert = jestMock.fn();
1442 mockFIELD.ERROR.SELECT = "testError";
1444 window.location = {};
1447 $scope.getServiceInstancesSearchResults(selectedCustomer, selectedInstanceIdentifierType, selectedServiceInstance, selectedProject, selectedOwningEntity);
1450 expect(alert).toHaveBeenCalledWith("testError");
1453 test('Verify getServiceInstancesSearchResults will navigate to proper page if selected service instance is not present in UtilityService', () => {
1455 let selectedCustomer = 'testCustomer';
1456 let selectedInstanceIdentifierType = 'testInstanceIdentifierType';
1457 let selectedServiceInstance = 'testServiceInstance ';
1458 let selectedProject = "testProject";
1459 let selectedOwningEntity = "testOwningEntity";
1461 let globalCustomerId = 'testCustomerIdResponse';
1463 mockAaiService.getGlobalCustomerIdByInstanceIdentifier = (serviceInstance, instanceIdentifierType) => {
1464 if(serviceInstance===selectedServiceInstance && instanceIdentifierType == selectedInstanceIdentifierType){
1465 return Promise.resolve(globalCustomerId);
1467 return Promise.reject();
1470 mockAaiService.getMultipleValueParamQueryString = ( element, subPath) => {
1471 return subPath + element;
1474 mockAaiService.getJoinedQueryString = jestMock.fn();
1476 mock_.map = (element,id) => {
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/";
1487 mockUtilityService.hasContents = (element) => {
1488 return element === selectedCustomer;
1491 window.location = {};
1494 $scope.getServiceInstancesSearchResults(selectedCustomer, selectedInstanceIdentifierType, selectedServiceInstance, selectedProject, selectedOwningEntity);
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