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);
226 isEmpty(something) {return true;},
231 let mockFeatureFlags = {};
233 let mockVIDCONFIGURATION = {};
237 let mockUibModal = {};
241 beforeEach(inject(function (_$controller_,DataService,$timeout) {
243 $on(request,toDoFunction){}
246 dataService = DataService;
248 _$controller_('aaiSubscriberController', {
250 COMPONENT: mockCOMPONENT,
253 DataService: DataService,
254 PropertyService: mockPropertyService,
257 $location: mockLocation,
260 $uibModal: mockUibModal,
261 VIDCONFIGURATION: mockVIDCONFIGURATION,
262 UtilityService: mockUtilityService,
263 vidService: mockVidService,
264 AaiService: mockAaiService,
266 OwningEntityService: mockOwningEntityService,
267 AsdcService: mockAsdcService,
268 featureFlags: mockFeatureFlags,
274 test('Verify showVnfDetails calls proper broadcast methots with proper parameters', () => {
276 const broadcast = jestMock.fn();
277 $scope.$broadcast = broadcast;
279 aaiResult = [[['test']]];
282 $scope.showVnfDetails('testVNF');
285 expect(broadcast).toHaveBeenCalledWith(mockCOMPONENT.SHOW_COMPONENT_DETAILS, { componentId: mockCOMPONENT.VNF,callbackFunction: expect.any(Function) } );
288 test('Verify getSubs will call fetchSubs and fetchServices and gets gets customer list from AaiService on success', () => {
290 mockAaiService.getSubList = (successFunction,failFunction) => {
291 successFunction(['testCustomer1', 'testCustomer2']);
293 mockAaiService.getServices2 = (successFunction,failFunction) => {
294 successFunction('testListId');
301 expect( $scope.customerList ).toContain('testCustomer1','testCustomer2');
302 expect( dataService.getServiceIdList() ).toEqual('testListId');
305 test('Verify getSubs will call fetchSubs and fetchServices and return error message from AaiService on fail', () => {
307 mockAaiService.getSubList = (successFunction,failFunction) => {
308 failFunction({status: 404, data: 'getSubListTestErrorMessage'} );
310 mockAaiService.getServices2 = (successFunction,failFunction) => {
311 failFunction({status: 404, data: 'getServices02TestErrorMessage'} );
318 expect( $scope.errorDetails ).toEqual('getServices02TestErrorMessage');
321 test('Verify refreshServiceTypes will call getServiceTypesList and gets service type list from AaiService, with proper customerID ', () => {
323 dataService.setGlobalCustomerId('testCustomerID');
324 dataService.setServiceIdList(['testServiceId1','testServiceId2']);
326 mockAaiService.getSubscriptionServiceTypeList = (customerId, successFunction,failFunction) => {
327 if (customerId === 'testCustomerID'){
328 successFunction(['testServiceType1', 'testServiceType2']);
333 $scope.refreshServiceTypes('testCustomerID');
336 expect( $scope.serviceTypeList ).toContain('testServiceType1','testServiceType2');
339 test('Verify refreshServiceTypes will call getServiceTypesList and return error message with wrong customerID ', () => {
341 mockAaiService.getSubscriptionServiceTypeList = (customerId, successFunction,failFunction) => {
342 if (customerId === 'testWrongCustomerID'){
343 failFunction( {status: 404, data: 'testErrorMessage'} );
348 $scope.refreshServiceTypes('testWrongCustomerID');
351 expect( $scope.errorDetails ).toEqual('testErrorMessage');
354 test('Verify refreshServiceTypes will call getServiceTypesList and calls alert with no customerID ', () => {
356 alert = jestMock.fn();
359 $scope.refreshServiceTypes('');
362 expect( alert ).toHaveBeenCalledWith(mockFIELD.ERROR.SELECT);
365 test('Verify getAaiServiceModels will set correct location ', () => {
367 mockLocation.path = jestMock.fn();
370 $scope.getAaiServiceModels('testServiceType','testSubName');
373 expect(mockLocation.path).toHaveBeenCalledWith(mockCOMPONENT.CREATE_INSTANCE_PATH);
376 test('Verify getAaiServiceModels wont set correct location if service type is empty', () => {
378 mockLocation.path = jestMock.fn();
381 $scope.getAaiServiceModels('','testSubName');
384 expect(mockLocation.path).not.toHaveBeenCalled();
387 test('Verify getAaiServiceModelsList will call AaiService getServiceModelsByServiceType and will set wholeData ', () => {
390 mockAaiService.getServiceModelsByServiceType = (queryId,customerId,serviceType,successFunction,failFunction) => {
393 response.data['inventory-response-item'] = [[],[]];
394 response.data['inventory-response-item'][0]['inventory-response-items'] = [];
395 response.data['inventory-response-item'][0]['service-subscription'] = [];
398 testItem['extra-properties'] = [];
399 testItem['extra-properties']['extra-property'] = [[],[],[],[],[],[],[]];
400 testItem['extra-properties']['extra-property'][6]["property-value"] = 1.546;
402 testItem['extra-properties']['extra-property'][4]['property-value'] = 0;
404 response.data['inventory-response-item'][0]['service-subscription']['service-type'] = 'testServiceType';
405 response.data['inventory-response-item'][0]['inventory-response-items']['inventory-response-item'] = testItem;
408 successFunction(response);
411 mock_.reduce = (service,iterateeFunction,accumulatorFunction) => {
412 return iterateeFunction([],service);
414 mock_.forEach = (service,iterateeFunction) => {
415 iterateeFunction(service);
417 mock_.maxBy = (item,maxFunction) => {
418 return maxFunction( item[0][0] )
421 dataService.setServiceIdList(['testService1','testService2','testService3','testService4']);
422 dataService.setSubscribers([{subscriberName:'testSubscriber1'},{subscriberName:'testSubscriber2'},{subscriberName:'testSubscriber3'},{subscriberName:'testSubscriber4'}]);
423 dataService.setGlobalCustomerId(2);
424 dataService.setSubscriberName('testSubscriber1');
427 $scope.getAaiServiceModelsList();
430 expect($scope.services[0]).toEqual(1.546);
431 expect($scope.serviceType).toEqual('testServiceType');
434 test('Verify getAaiServiceModelsList will call AaiService getServiceModelsByServiceType and will return error data on fail ', () => {
436 dataService.setServiceIdList([['testServiceId1','testServiceId2']]);
437 dataService.setSubscribers(['testSubscriber1,testSubscriber2']);
439 mockAaiService.getServiceModelsByServiceType = (queryId,customerId,serviceType,successFunction,failFunction) => {
440 failFunction( {status: 404, data: 'testErrorMessage'})
444 $scope.getAaiServiceModelsList();
447 expect($scope.errorDetails).toEqual('testErrorMessage');
450 test('Verify getAaiServiceModelsList will call AaiService getServiceModelsByServiceType and will return error data if respose data is empty ', () => {
452 dataService.setServiceIdList([['testServiceId1','testServiceId2']]);
453 dataService.setSubscribers(['testSubscriber1,testSubscriber2']);
455 mockAaiService.getServiceModelsByServiceType = (queryId,customerId,serviceType,successFunction,failFunction) => {
458 response.data['inventory-response-item'] = [];
459 successFunction(response);
463 $scope.getAaiServiceModelsList();
466 expect($scope.status).toEqual('Failed to get service models from SDC.');
469 test('Verify deployService will call http get method to rest model service', () => {
471 mockedLog.error = jestMock.fn();
472 mockAsdcService.isMacro = (item) => { return true };
473 mockAsdcService.shouldTakeTheAsyncInstantiationFlow = (serviceModel) => {return 'testModel'};
474 mockUtilityService.convertModel = (serviceModel)=>{return serviceModel};
475 $scope.$broadcast = (broadcastType, broadcastObject) => {broadcastObject.callbackFunction(
480 {id:"subscriberName",value:"testSubscriber"},
481 {id:"serviceType",value:"testService"}
483 instanceId:"testInstance"
488 "model-version-id": 101
492 $scope.refreshSubs = jestMock.fn();
494 let mockedGetPromise = Promise.resolve({data: {service: {name: 'testServiceName' }}});
495 mockHttp.get = () => mockedGetPromise;
498 $scope.deployService(service,true);
501 test('Verify deployService will log error if get fails ', () => {
504 let mockedGetPromise = Promise.reject({code: 404});
505 mockHttp.get = () => mockedGetPromise;
509 "model-version-id": 101
514 $scope.deployService(service,false);
517 test('Verify refreshSubs fetches Subs and Services', () => {
519 $scope.fetchSubs = jestMock.fn();
520 $scope.fetchServices = jestMock.fn();
521 $scope.init = jestMock.fn();
523 mockFIELD.PROMPT.REFRESH_SUB_LIST = 'testRefreshMock';
526 $scope.refreshSubs();
529 expect($scope.init).toHaveBeenCalled();
530 expect($scope.fetchSubs).toHaveBeenCalledWith(mockFIELD.PROMPT.REFRESH_SUB_LIST);
531 expect($scope.fetchServices).toHaveBeenCalled();
535 test('Verify loadOwningEntity gets owning entity properties', () => {
537 mockOwningEntityService.getOwningEntityProperties = (callBack) => {
538 callBack({owningEntity:'testOwner',project:'testProject'});
542 $scope.loadOwningEntity();
545 expect($scope.owningEntities).toEqual('testOwner');
546 expect($scope.projects).toEqual('testProject');
549 test('Verify getPermitted returns items permission', () => {
551 mockFIELD.ID.IS_PERMITTED = 'testPermission';
555 $scope.getPermitted({})
556 ).toEqual(undefined);
559 $scope.getPermitted({isPermitted:true})
563 $scope.getPermitted({isPermitted:false})
564 ).toEqual(undefined);
567 $scope.getPermitted({isPermitted:false,testPermission:true})
571 $scope.getPermitted({testPermission:false,testPermission:false})
575 $scope.getPermitted({isPermitted:true,testPermission:false})
579 test('Verify getSubDetails calls to aaiService for service instance', () => {
581 let aaiPromise = Promise.resolve(
584 {globalCustomerId:"testCustomerId01",subscriberName:"testCustomer1"},
585 {globalCustomerId:"testCustomerId02",subscriberName:"testCustomer2"},
589 mockLocation.url = () => {return ""};
591 mockAaiService.searchServiceInstances = (query)=>aaiPromise;
594 $scope.getSubDetails();
597 test('Verify getSubDetails catches bad response', () => {
599 let aaiPromise = Promise.reject(
600 {data:'testError',status:404});
602 mockLocation.url = () => {return ""};
604 mockAaiService.searchServiceInstances = (query)=>aaiPromise;
607 $scope.getSubDetails();
610 test('Verify getComponentList returns list of components if query is correct', () => {
612 mockLocation.search = () => {
614 subscriberId: 'testSubscriberID',
615 serviceType: 'testService',
616 serviceInstanceId: "testServiceInstanceID",
617 subscriberName: "testSubscriber",
618 aaiModelVersionId: "testModelVersion"
622 mockVidService.getModel = () => {
625 uuid: "testModelVersion",
630 mockUtilityService.hasContents = (content) => {
631 if (content==="testModelVersion") {
637 mockQ.resolve = (item) => {return Promise.resolve("testModelVersion")};
639 $scope.prepareScopeWithModel = () => {return Promise.resolve()};
641 mockAaiService.getVlansByNetworksMapping = (globalCustomerId, serviceType, serviceInstanceId, modelServiceUuid) => {
642 return Promise.resolve({serviceNetworks:true});
648 uuid: 'testModelServiceUuid'
653 mockedLog.debug = () => {};
654 mockUtilityService.isObjectEmpty = () => {
658 mockFIELD.ID.INVENTORY_RESPONSE_ITEM = "testResponseItems";
659 mockFIELD.ID.SERVICE_SUBSCRIPTION = 0;
660 mockFIELD.ID.SERVICE_INSTANCES = 0;
661 mockFIELD.ID.SERVICE_INSTANCE = 0;
662 mockFIELD.ID.SERVICE_INSTANCE_ID = 'testServiceInstanceID';
663 mockFIELD.STATUS.ASSIGNED = 'teststatus';
665 mockAaiService.runNamedQuery = (namedQueryId,globalCustomerId,serviceType,serviceInstanceId,successFunction,failureFunction) => {
675 return Promise.resolve("testComponentList");
678 mockAaiService.getPortMirroringData = (portMirroringConfigurationIds) => {
679 return Promise.resolve({data:[8080,9090]});
682 mockAaiService.getPortMirroringSourcePorts = (portMirroringConfigurationIds) => {
683 return Promise.resolve({data:[8888,9999]})
686 mockAaiService.getSubscriberName = (customerId, successFunction) => {
687 successFunction({subscriberName:"testSubscriber1",serviceSubscriptions:[[
688 [[[{'testServiceInstanceID':'testServiceInstanceID','orchestration-status':'testStatus'},{'testServiceInstanceID':'','orchestration-status':''}]]],
689 [[[{'testServiceInstanceID':'','orchestration-status':''}]]]
694 mock_.map = (serviceNetworkVlans, networkId) => {
695 return ["aaiNetworkId1","aaiNetworkId2"];
699 return $scope.getComponentList('','').
701 expect(components).toEqual("testComponentList")
706 test('Verify handleServerError sets proper $scope.error and $scope.status', () => {
708 mockUtilityService.getHttpErrorMessage = (response) => {return response.statusText};
709 mockFIELD.ERROR.SYSTEM_ERROR = "testSystemError";
710 mockFIELD.STATUS.ERROR = "testStatusError";
713 $scope.handleServerError({statusText:'testStatusError'},'');
716 expect($scope.error).toEqual("testSystemError (testStatusError)");
717 expect($scope.status).toEqual("testStatusError");
720 test('Verify showContentError sets proper $scope.error and $scope.status if UtilityService has that content', () => {
722 mockFIELD.STATUS.ERROR = "testStatusError";
724 mockUtilityService.hasContents = (content) => {
725 return content === 'testContentError';
730 $scope.showContentError('testContentError');
733 expect($scope.error).toEqual("System failure (testContentError)");
734 expect($scope.status).toEqual("testStatusError");
737 test('Verify showContentError sets proper $scope.error and $scope.status if UtilityService has not that content', () => {
739 mockFIELD.ERROR.SYSTEM_ERROR = "testSystemError";
740 mockFIELD.STATUS.ERROR = "testStatusError";
742 mockUtilityService.hasContents = (content) => {
747 $scope.showContentError('testContentError');
750 expect($scope.error).toEqual("testSystemError");
751 expect($scope.status).toEqual("testStatusError");
754 test('Verify handleInitialResponse shows error for response codes other then 200,201,202', () => {
762 mockFIELD.ERROR.MSO = "testSystemError";
763 mockFIELD.ERROR.AAI_FETCHING_CUST_DATA = "testStatusError:";
765 $scope.showError = jestMock.fn();
768 $scope.handleInitialResponse(response);
771 expect($scope.showError).toHaveBeenCalledWith("testSystemError");
772 expect($scope.status).toEqual("testStatusError:404");
775 test('Verify handleInitialResponse updates customer list with response code 202', () => {
778 'globalCustomerId':'testCustomerID',
779 "subscriberName":'testSubscriber',
789 mockFIELD.ID.GLOBAL_CUSTOMER_ID = 'globalCustomerId';
790 mockFIELD.ID.SUBNAME = 'subscriberName';
791 mockFIELD.ID.IS_PERMITTED = 'isPermitted';
794 $scope.handleInitialResponse(response);
797 expect($scope.customerList).toContainEqual(customer);
800 test('Verify handleInitialResponse calls showContentError with wrong response ', () => {
802 $scope.showContentError = jestMock.fn();
805 $scope.handleInitialResponse(null);
808 expect($scope.showContentError).toHaveBeenCalledWith(expect.objectContaining({message:"Cannot read property 'data' of null"}));
811 test('Verify isConfigurationDataAvailiable will return proper response', () => {
813 mockedLog.debug = jestMock.fn();
815 expect( $scope.isConfigurationDataAvailiable({configData:{}}) ).toEqual(true);
816 expect( $scope.isConfigurationDataAvailiable({configData:{errorDescription:"testerror"}}) ).toEqual(false);
817 expect( $scope.isConfigurationDataAvailiable({}) ).toEqual(undefined);
821 test('Verify isActivateDeactivateEnabled will return proper response', () => {
823 mockedLog.debug = jestMock.fn();
825 $scope.serviceOrchestrationStatus = "active";
826 mockCOMPONENT.ACTIVATE_SERVICE_STATUSES = ["active","up"];
829 expect( $scope.isActivateDeactivateEnabled("deactivate")).toEqual(true);
830 expect( $scope.isActivateDeactivateEnabled("activate")).toEqual(true);
832 $scope.serviceOrchestrationStatus = "down";
833 mockCOMPONENT.ACTIVATE_SERVICE_STATUSES = ["active","up"];
835 expect( $scope.isActivateDeactivateEnabled("deactivate")).toEqual(false);
836 expect( $scope.isActivateDeactivateEnabled("activate")).toEqual(false);
838 $scope.serviceOrchestrationStatus = null;
840 expect( $scope.isActivateDeactivateEnabled(null)).toEqual(false);
844 test('Verify isShowVerifyService will return proper response base on feature flag', () => {
846 mockCOMPONENT.FEATURE_FLAGS.FLAG_SHOW_VERIFY_SERVICE = 'showVerifyService';
847 mockFeatureFlags.isOn = (flag) => {
848 if (flag === 'showVerifyService'){return true};
852 expect( $scope.isShowVerifyService()).toEqual(true);
855 test('Verify isEnableVerifyService will return false if is not ALaCarte', () => {
857 dataService.setALaCarte(false);
860 expect( $scope.isEnableVerifyService()).toEqual(false);
863 test('Verify isEnableVerifyService will return verifyButtonEnabled if is ALaCarte', () => {
865 dataService.setALaCarte(true);
868 $scope.verifyButtonEnabled = true;
869 expect( $scope.isEnableVerifyService()).toEqual(true);
871 $scope.verifyButtonEnabled = false;
872 expect( $scope.isEnableVerifyService()).toEqual(false);
875 test('Verify activateVerifyService will post POMBA verification', () => {
877 mockCOMPONENT.VERIFY_SERVICE_URL = "/testURL";
879 mockAaiService.postPOMBAverificationRequest = jestMock.fn();
881 $scope.serviceInstanceId = "testInstanceID";
882 $scope.service = {model:{service:{}},instance:{}};
883 $scope.service.model.service.uuid = "testUuid";
884 $scope.service.model.service.invariantUuid = "testInvariantUuid";
885 $scope.globalCustomerId = "testCustomerId";
886 $scope.service.instance.serviceType = "testServiceType";
889 $scope.activateVerifyService();
892 expect(mockAaiService.postPOMBAverificationRequest).toHaveBeenCalledWith(
894 expect.objectContaining({'serviceInstanceList':[expect.any(Object)]}),
895 expect.objectContaining({'headers':expect.any(Object)}));
898 test('Verify isShowAssignmentsEnabled will return proper response determine by feature flag', () => {
900 mockCOMPONENT.FEATURE_FLAGS.FLAG_SHOW_ASSIGNMENTS = "showAssignment";
902 mockFeatureFlags.isOn = (flag) => {
903 if (flag === 'showAssignment'){return true};
907 $scope.serviceOrchestrationStatus = "assigned";
908 expect( $scope.isShowAssignmentsEnabled() ).toEqual(true);
910 $scope.serviceOrchestrationStatus = "notAssigned";
911 expect( $scope.isShowAssignmentsEnabled() ).toEqual(false);
913 $scope.serviceOrchestrationStatus = null;
914 expect( $scope.isShowAssignmentsEnabled() ).toEqual(false);
917 test('Verify isActivateFabricConfiguration will return proper response determine by feature flag', () => {
919 mockCOMPONENT.FEATURE_FLAGS.FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS = "fabricConfigurationAssignment";
920 $scope.hasFabricConfigurations = true;
922 mockFeatureFlags.isOn = (flag) => {
923 if (flag === 'fabricConfigurationAssignment'){return true};
927 $scope.serviceOrchestrationStatus = "assigned";
928 expect( $scope.isActivateFabricConfiguration() ).toEqual(true);
930 $scope.serviceOrchestrationStatus = "notAssigned";
931 expect( $scope.isActivateFabricConfiguration() ).toEqual(false);
933 $scope.serviceOrchestrationStatus = null;
934 expect( $scope.isActivateFabricConfiguration() ).toEqual(false);
937 test('Verify isResumeShown will return proper response determine by feature flag with disabled ActivateDeactivate', () => {
939 $scope.serviceOrchestrationStatus = "assigned";
940 $scope.isActivateDeactivateEnabled = () => {return false};
943 expect( $scope.isResumeShown("assigned") ).toEqual(true);
944 expect( $scope.isResumeShown("unAssigned") ).toEqual(false);
948 test('Verify isResumeShown will return proper response determine by feature flag with enable ActivateDeactivate', () => {
950 $scope.serviceOrchestrationStatus = "assigned";
951 $scope.isActivateDeactivateEnabled = () => {return true};
954 expect( $scope.isResumeShown("assigned") ).toEqual(false);
955 expect( $scope.isResumeShown("unAssigned") ).toEqual(false);
959 test('Verify close will call time out cancel and hides pop up window if timer is defined', () => {
962 $scope.isPopupVisible = true;
964 timeout.cancel = jestMock.fn();
970 expect(timeout.cancel).toHaveBeenCalledWith(1000);
971 expect($scope.isPopupVisible).toEqual(false);
974 test('Verify close will hide pop up window if timer is undefined', () => {
976 $scope.timer = undefined;
977 $scope.isPopupVisible = true;
983 expect($scope.isPopupVisible).toEqual(false);
986 test('Verify reloadRoute will call reload on rout', () => {
988 mockRoute.reload = jestMock.fn();
991 $scope.reloadRoute();
994 expect(mockRoute.reload).toHaveBeenCalled();
997 test('Verify prevPage will decrease currentPage', () => {
999 $scope.currentPage = 5;
1005 expect($scope.currentPage).toEqual(4);
1008 test('Verify showAssignmentsSDNC will return proper response base on VIDCONFIGURATION', () => {
1010 $scope.service = {};
1011 $scope.service.instance = {};
1012 $scope.service.instance.id = "testServiceInstanceId";
1014 mockVIDCONFIGURATION.SDNC_SHOW_ASSIGNMENTS_URL = "test/ulr/to/<SERVICE_INSTANCE_ID>";
1017 expect( $scope.showAssignmentsSDNC() ).toEqual("test/ulr/to/testServiceInstanceId");
1020 test('Verify showAssignmentsSDNC will return null if service instance dos not exist or is null', () => {
1022 $scope.service = {};
1025 expect( $scope.showAssignmentsSDNC() ).toEqual(null);
1027 $scope.service.instance = null;
1028 expect( $scope.showAssignmentsSDNC() ).toEqual(null);
1031 test('Verify activateFabricConfigurationMSO with logged in user, will call uibModal open that will return response ', () => {
1035 mockCOMPONENT.MSO_ACTIVATE_FABRIC_CONFIGURATION_REQ = "testMsoActivateType";
1037 $scope.service = {};
1038 $scope.service.model = {};
1039 $scope.service = {};
1040 $scope.serviceInstanceId= "testServiceInstanceId";
1042 dataService.setLoggedInUserId("testUserId");
1044 mockUibModal.open = (testResponse) => {
1045 resopnse = testResponse.resolve;
1049 $scope.activateFabricConfigurationMSO();
1052 expect( resopnse.msoType() ).toEqual("testMsoActivateType");
1053 expect( resopnse.requestParams().serviceInstanceId ).toEqual("testServiceInstanceId");
1054 expect( resopnse.requestParams().userId ).toEqual("testUserId");
1055 expect( resopnse.configuration() ).toEqual(undefined);
1058 test('Verify activateFabricConfigurationMSO without logged in user will first get user id from AaiService , will call uibModal open that will return response ', () => {
1062 mockCOMPONENT.MSO_ACTIVATE_FABRIC_CONFIGURATION_REQ = "testMsoActivateType";
1064 $scope.service = {};
1065 $scope.service.model = {};
1066 $scope.service = {};
1067 $scope.serviceInstanceId= "testServiceInstanceId";
1070 mockAaiService.getLoggedInUserID = (onSuccess) => {
1071 onSuccess({data:"testAaiUserId"});
1074 mockUibModal.open = (testResponse) => {
1075 resopnse = testResponse.resolve;
1079 $scope.activateFabricConfigurationMSO();
1082 expect( resopnse.msoType() ).toEqual("testMsoActivateType");
1083 expect( resopnse.requestParams().serviceInstanceId ).toEqual("testServiceInstanceId");
1084 expect( resopnse.requestParams().userId ).toEqual("testAaiUserId");
1085 expect( resopnse.configuration() ).toEqual(undefined);
1088 test('Verify activateMSOInstance with logged in user, will get aicZone from AaiService and call uibModal open that will return response ', () => {
1092 mockCOMPONENT.MSO_ACTIVATE_SERVICE_REQ = "testMsoActivateType";
1094 $scope.service = {};
1095 $scope.service.model = {};
1096 $scope.service.instance = {};
1098 dataService.setLoggedInUserId("testUserId");
1100 mockAaiService.getAicZoneForPNF = (globalCustomerId,serviceType,serviceInstanceId,getZoneFunction) => {
1101 getZoneFunction("testAicZone");
1104 mockUibModal.open = (testResponse) => {
1105 resopnse = testResponse.resolve;
1109 $scope.activateMSOInstance();
1112 expect( resopnse.msoType() ).toEqual("testMsoActivateType");
1113 expect( resopnse.requestParams().aicZone ).toEqual("testAicZone");
1114 expect( resopnse.requestParams().userId ).toEqual("testUserId");
1115 expect( resopnse.configuration() ).toEqual(undefined);
1118 test('Verify activateMSOInstance without logged in user will first get user id from AaiService , will call uibModal open that will return response ', () => {
1122 mockCOMPONENT.MSO_ACTIVATE_SERVICE_REQ = "testMsoActivateType";
1124 $scope.service = {};
1125 $scope.service.model = {};
1126 $scope.service.instance = {};
1129 mockAaiService.getAicZoneForPNF = (globalCustomerId,serviceType,serviceInstanceId,getZoneFunction) => {
1130 getZoneFunction("testAicZone");
1133 mockAaiService.getLoggedInUserID = (onSuccess) => {
1134 onSuccess({data:"testAaiUserId"});
1137 mockUibModal.open = (testResponse) => {
1138 resopnse = testResponse.resolve;
1142 $scope.activateMSOInstance();
1145 expect( resopnse.msoType() ).toEqual("testMsoActivateType");
1146 expect( resopnse.requestParams().aicZone ).toEqual("testAicZone");
1147 expect( resopnse.requestParams().userId ).toEqual("testAaiUserId");
1148 expect( resopnse.configuration() ).toEqual(undefined);
1151 test('Verify deactivateMSOInstance will get call uibModal open that will return response ', () => {
1155 mockCOMPONENT.MSO_DEACTIVATE_SERVICE_REQ = "testMsoDeactivateType";
1157 $scope.service = {};
1158 $scope.service.model = {};
1159 $scope.service.instance = {};
1162 mockAaiService.getAicZoneForPNF = (globalCustomerId,serviceType,serviceInstanceId,getZoneFunction) => {
1163 getZoneFunction("testAicZone");
1166 mockAaiService.getLoggedInUserID = (onSuccess) => {
1167 onSuccess({data:"testAaiUserId"});
1170 mockUibModal.open = (testResponse) => {
1171 resopnse = testResponse.resolve;
1175 $scope.deactivateMSOInstance();
1178 expect( resopnse.msoType() ).toEqual("testMsoDeactivateType");
1179 expect( resopnse.requestParams().aicZone ).toEqual("testAicZone");
1180 expect( resopnse.requestParams().userId ).toEqual("testAaiUserId");
1181 expect( resopnse.configuration() ).toEqual(undefined);
1184 test('Verify deleteConfiguration will get call uibModal open that will return response ', () => {
1191 invariantUuid:"testInvariantUuid",
1194 version:"testVersion",
1197 serviceInstanceId:"testServiceInstanceId",
1202 modelInvariantId:"testModelInvariantId",
1203 modelVersionId:"testModelVersionId",
1204 modelCustomizationId:"testModelCustomizationId",
1205 nodeId:"testNodeId",
1206 DELETE:"testDELETE",
1209 mockCOMPONENT.MSO_DELETE_CONFIGURATION_REQ = "testMsoDeleteType";
1211 mockAaiService.getLoggedInUserID = (successFunction) => {
1212 successFunction( {data:"testLoggedInUserId"} );
1215 mockUibModal.open = (testResponse) => {
1216 resopnse = testResponse.resolve;
1220 $scope.deleteConfiguration(serviceObject, configuration);
1223 expect( resopnse.msoType() ).toEqual("testMsoDeleteType");
1224 expect( resopnse.requestParams().serviceModel.modelInvariantId ).toEqual("testInvariantUuid");
1225 expect( resopnse.requestParams().serviceModel.modelVersionId ).toEqual("testUuid");
1226 expect( resopnse.requestParams().serviceModel.modelName ).toEqual("testService");
1227 expect( resopnse.requestParams().serviceModel.modelVersion ).toEqual("testVersion");
1228 expect( resopnse.requestParams().serviceInstanceId ).toEqual("testServiceInstanceId");
1229 expect( resopnse.requestParams().configurationModel.modelInvariantId ).toEqual("testModelInvariantId");
1230 expect( resopnse.requestParams().configurationModel.modelVersionId ).toEqual("testModelVersionId");
1231 expect( resopnse.requestParams().configurationModel.modelCustomizationId ).toEqual("testModelCustomizationId");
1232 expect( resopnse.requestParams().configurationId ).toEqual("testNodeId");
1233 expect( resopnse.requestParams().configStatus ).toEqual("testDELETE");
1234 expect( resopnse.requestParams().userId ).toEqual("testLoggedInUserId");
1237 test('Verify toggleConfigurationStatus will get call uibModal open that will return response ', () => {
1244 invariantUuid:"testInvariantUuid",
1247 version:"testVersion",
1250 serviceInstanceId:"testServiceInstanceId",
1255 modelInvariantId:"testModelInvariantId",
1256 modelVersionId:"testModelVersionId",
1257 modelCustomizationId:"testModelCustomizationId",
1258 nodeId:"testNodeId",
1259 nodeStatus:"testNodeStatus",
1262 mockAaiService.getLoggedInUserID = (successFunction) => {
1263 successFunction( {data:"testLoggedInUserId"} );
1266 mockUibModal.open = (testResponse) => {
1267 resopnse = testResponse.resolve;
1270 mockCOMPONENT.MSO_CHANGE_CONFIG_STATUS_REQ = "testMsoChangeConfig";
1273 $scope.toggleConfigurationStatus(serviceObject, configuration);
1276 expect( resopnse.msoType() ).toEqual("testMsoChangeConfig");
1277 expect( resopnse.requestParams().serviceModel.modelInvariantId ).toEqual("testInvariantUuid");
1278 expect( resopnse.requestParams().serviceModel.modelVersionId ).toEqual("testUuid");
1279 expect( resopnse.requestParams().serviceModel.modelName ).toEqual("testService");
1280 expect( resopnse.requestParams().serviceModel.modelVersion ).toEqual("testVersion");
1281 expect( resopnse.requestParams().serviceInstanceId ).toEqual("testServiceInstanceId");
1282 expect( resopnse.requestParams().configurationModel.modelInvariantId ).toEqual("testModelInvariantId");
1283 expect( resopnse.requestParams().configurationModel.modelVersionId ).toEqual("testModelVersionId");
1284 expect( resopnse.requestParams().configurationModel.modelCustomizationId ).toEqual("testModelCustomizationId");
1285 expect( resopnse.requestParams().configurationId ).toEqual("testNodeId");
1286 expect( resopnse.requestParams().configStatus ).toEqual("testNodeStatus");
1287 expect( resopnse.requestParams().userId ).toEqual("testLoggedInUserId");
1290 test('Verify togglePortStatus will get call uibModal open that will return response ', () => {
1294 let serviceObject = {
1297 invariantUuid:"testInvariantUuid",
1300 version:"testVersion",
1303 serviceInstanceId:"testServiceInstanceId",
1307 let configuration = {
1308 modelInvariantId:"testModelInvariantId",
1309 modelVersionId:"testModelVersionId",
1310 modelCustomizationId:"testModelCustomizationId",
1311 nodeId:"testNodeId",
1319 mockAaiService.getLoggedInUserID = (successFunction) => {
1320 successFunction( {data:"testLoggedInUserId"} );
1323 mockUibModal.open = (testResponse) => {
1324 resopnse = testResponse.resolve;
1327 mockCOMPONENT.MSO_CHANGE_PORT_STATUS_REQ = "testMsoPortStatus";
1330 $scope.togglePortStatus(serviceObject, configuration,port);
1333 expect( resopnse.msoType() ).toEqual("testMsoPortStatus");
1334 expect( resopnse.requestParams().serviceModel.modelInvariantId ).toEqual("testInvariantUuid");
1335 expect( resopnse.requestParams().serviceModel.modelVersionId ).toEqual("testUuid");
1336 expect( resopnse.requestParams().serviceModel.modelName ).toEqual("testService");
1337 expect( resopnse.requestParams().serviceModel.modelVersion ).toEqual("testVersion");
1338 expect( resopnse.requestParams().serviceInstanceId ).toEqual("testServiceInstanceId");
1339 expect( resopnse.requestParams().configurationModel.modelInvariantId ).toEqual("testModelInvariantId");
1340 expect( resopnse.requestParams().configurationModel.modelVersionId ).toEqual("testModelVersionId");
1341 expect( resopnse.requestParams().configurationModel.modelCustomizationId ).toEqual("testModelCustomizationId");
1342 expect( resopnse.requestParams().configurationId ).toEqual("testNodeId");
1343 expect( resopnse.requestParams().userId ).toEqual("testLoggedInUserId");
1344 expect( resopnse.requestParams().portId ).toEqual("testPort");
1345 expect( resopnse.requestParams().portStatus ).toEqual("open");
1349 test('Verify getServiceInstancesSearchResults will get global customer Id from AaiService with proper service instance', () => {
1351 let selectedCustomer = 'testCustomer';
1352 let selectedInstanceIdentifierType = 'testInstanceIdentifierType';
1353 let selectedServiceInstance = 'testServiceInstance ';
1354 let selectedProject = "testProject";
1355 let selectedOwningEntity = "testOwningEntity";
1357 let globalCustomerId = 'testCustomerIdResponse';
1359 mockAaiService.getGlobalCustomerIdByInstanceIdentifier = jestMock.fn((serviceInstance, instanceIdentifierType) => {
1360 if(serviceInstance===selectedServiceInstance && instanceIdentifierType == selectedInstanceIdentifierType){
1361 return Promise.resolve(globalCustomerId);
1363 return Promise.reject();
1366 mockAaiService.getMultipleValueParamQueryString = ( element, subPath) => {
1367 return subPath + '/ ' + element;
1370 mockAaiService.getJoinedQueryString = jestMock.fn();
1372 mock_.map = (element,id) => {
1376 mockCOMPONENT.PROJECT_SUB_PATH = "test/project/sub";
1377 mockCOMPONENT.OWNING_ENTITY_SUB_PATH = "test/entity/sub";
1378 mockCOMPONENT.SELECTED_SUBSCRIBER_SUB_PATH = "test/subscriber/sub";
1379 mockCOMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH = "test/service/instance/sub";
1380 mockCOMPONENT.SELECTED_SERVICE_SUB_PATH = "text/service/sub";
1382 mockUtilityService.hasContents = (element) => {
1383 if ( element === selectedCustomer ||
1384 element === selectedServiceInstance ||
1385 element === globalCustomerId )
1389 window.location = {};
1392 $scope.getServiceInstancesSearchResults(selectedCustomer, selectedInstanceIdentifierType, selectedServiceInstance, selectedProject, selectedOwningEntity);
1395 expect(mockAaiService.getGlobalCustomerIdByInstanceIdentifier).toHaveBeenCalledWith(selectedServiceInstance,selectedInstanceIdentifierType);
1398 test('Verify getServiceInstancesSearchResults will alert error if non of parameters is located in UtilityService', () => {
1400 let selectedCustomer = 'testCustomer';
1401 let selectedInstanceIdentifierType = 'testInstanceIdentifierType';
1402 let selectedServiceInstance = 'testServiceInstance ';
1403 let selectedProject = "testProject";
1404 let selectedOwningEntity = "testOwningEntity";
1406 let globalCustomerId = 'testCustomerIdResponse';
1408 mockAaiService.getGlobalCustomerIdByInstanceIdentifier = (serviceInstance, instanceIdentifierType) => {
1409 if(serviceInstance===selectedServiceInstance && instanceIdentifierType == selectedInstanceIdentifierType){
1410 return Promise.resolve(globalCustomerId);
1412 return Promise.reject();
1415 mockAaiService.getMultipleValueParamQueryString = ( element, subPath) => {
1416 return subPath + '/ ' + element;
1419 mockAaiService.getJoinedQueryString = (queryArray) => {
1420 let joinedQuery = "";
1421 queryArray.forEach((element)=>{
1422 joinedQuery += element + "//"
1428 mock_.map = (element,id) => {
1432 mockCOMPONENT.PROJECT_SUB_PATH = "test/project/sub";
1433 mockCOMPONENT.OWNING_ENTITY_SUB_PATH = "test/entity/sub";
1434 mockCOMPONENT.SELECTED_SUBSCRIBER_SUB_PATH = "test/subscriber/sub";
1435 mockCOMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH = "test/service/instance/sub";
1436 mockCOMPONENT.SELECTED_SERVICE_SUB_PATH = "text/service/sub";
1438 mockUtilityService.hasContents = (element) => {
1442 alert = jestMock.fn();
1443 mockFIELD.ERROR.SELECT = "testError";
1445 window.location = {};
1448 $scope.getServiceInstancesSearchResults(selectedCustomer, selectedInstanceIdentifierType, selectedServiceInstance, selectedProject, selectedOwningEntity);
1451 expect(alert).toHaveBeenCalledWith("testError");
1454 test('Verify getServiceInstancesSearchResults will navigate to proper page if selected service instance is not present in UtilityService', () => {
1456 let selectedCustomer = 'testCustomer';
1457 let selectedInstanceIdentifierType = 'testInstanceIdentifierType';
1458 let selectedServiceInstance = 'testServiceInstance ';
1459 let selectedProject = "testProject";
1460 let selectedOwningEntity = "testOwningEntity";
1462 let globalCustomerId = 'testCustomerIdResponse';
1464 mockAaiService.getGlobalCustomerIdByInstanceIdentifier = (serviceInstance, instanceIdentifierType) => {
1465 if(serviceInstance===selectedServiceInstance && instanceIdentifierType == selectedInstanceIdentifierType){
1466 return Promise.resolve(globalCustomerId);
1468 return Promise.reject();
1471 mockAaiService.getMultipleValueParamQueryString = ( element, subPath) => {
1472 return subPath + element;
1475 mockAaiService.getJoinedQueryString = jestMock.fn();
1477 mock_.map = (element,id) => {
1481 mockCOMPONENT.PROJECT_SUB_PATH = "test/project/sub/";
1482 mockCOMPONENT.OWNING_ENTITY_SUB_PATH = "test/entity/sub/";
1483 mockCOMPONENT.SELECTED_SUBSCRIBER_SUB_PATH = "test/subscriber/sub/";
1484 mockCOMPONENT.SELECTED_SERVICE_INSTANCE_SUB_PATH = "test/service/instance/sub/";
1485 mockCOMPONENT.SELECTED_SERVICE_SUB_PATH = "text/service/sub/";
1488 mockUtilityService.hasContents = (element) => {
1489 return element === selectedCustomer;
1492 window.location = {};
1495 $scope.getServiceInstancesSearchResults(selectedCustomer, selectedInstanceIdentifierType, selectedServiceInstance, selectedProject, selectedOwningEntity);
1498 expect(mockAaiService.getJoinedQueryString).toHaveBeenCalledWith(expect.arrayContaining([
1499 mockCOMPONENT.PROJECT_SUB_PATH+selectedProject,
1500 mockCOMPONENT.OWNING_ENTITY_SUB_PATH+selectedOwningEntity,
1501 mockCOMPONENT.SELECTED_SUBSCRIBER_SUB_PATH+selectedCustomer