Merge "cypress test - adding option transpileOnly: true"
authorIttay Stern <ittay.stern@att.com>
Thu, 2 Jan 2020 09:43:16 +0000 (09:43 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 2 Jan 2020 09:43:16 +0000 (09:43 +0000)
18 files changed:
vid-app-common/src/main/java/org/onap/vid/dal/AsyncInstantiationRepository.kt
vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceModelController.js
vid-app-common/src/main/webapp/app/vid/scripts/controller/creationDialogController.js
vid-app-common/src/main/webapp/app/vid/scripts/services/dataService.js
vid-app-common/src/test/java/org/onap/vid/dal/AsyncInstantiationRepositoryTest.java
vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
vid-automation/src/main/java/vid/automation/test/test/DrawingBoardTest.java
vid-automation/src/main/java/vid/automation/test/test/NewServiceInstanceTest.java
vid-automation/src/test/java/org/onap/vid/api/InstantiationTemplatesApiTest.java
vid-webpack-master/cypress/integration/iFrames/browse-sdc.e2e.ts
vid-webpack-master/cypress/integration/iFrames/instantiation-templates.e2e.ts
vid-webpack-master/cypress/integration/iFrames/instantiation.templates.modal.e2e.ts
vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts
vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.html
vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.component.ts
vid-webpack-master/src/app/shared/components/searchMembersModal/search-elements-modal.component.ts
vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts [new file with mode: 0644]
vid-webpack-master/src/app/shared/utils/iframe.service.ts

index e262472..b638a03 100644 (file)
@@ -90,12 +90,16 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService:
                 "   and created >= '" + filterDate + "' "
     }
 
-    private fun filterInstantiatedServiceByServiceModelId(serviceModelUuid: UUID): String {
+    private fun filterByInstantiateActionStatus(): String{
         return filterServicesByNotHiddenAndNotDeleted() +
-                " and SERVICE_MODEL_ID = '$serviceModelUuid'" +
                 " and ACTION  = 'INSTANTIATE'"
     }
 
+    private fun filterInstantiatedServiceByServiceModelId(serviceModelUuid: UUID): String {
+        return filterByInstantiateActionStatus() +
+                " and SERVICE_MODEL_ID = '$serviceModelUuid'"
+    }
+
     private fun filterServicesByNotHiddenAndNotDeleted(): String {
         return " WHERE" +
                 "   hidden = false" +
@@ -157,4 +161,13 @@ class AsyncInstantiationRepository @Autowired constructor(val dataAccessService:
 
     fun listInstantiatedServicesByServiceModelId(serviceModelId: UUID): List<ServiceInfo> =
             dataAccessService.getList(ServiceInfo::class.java, filterInstantiatedServiceByServiceModelId(serviceModelId), orderByCreatedDateAndStatus(), null) as List<ServiceInfo>;
+
+    fun getAllTemplatesServiceModelIds(): Set<String> {
+        val allTemplatesInfo =
+                dataAccessService.getList(ServiceInfo::class.java, filterByInstantiateActionStatus(), null, null) as List<ServiceInfo>
+
+        return allTemplatesInfo
+                .map { it.serviceModelId }
+                .toHashSet()
+    }
 }
index b29680f..1b64573 100755 (executable)
-/*-\r
- * ============LICENSE_START=======================================================\r
- * VID\r
- * ================================================================================\r
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.\r
- * Modifications Copyright (C) 2019 IBM.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-(function () {\r
-       'use strict';\r
-\r
-       appDS2.controller("ServiceModelController",function ($uibModal, $scope, $http, $location, COMPONENT, VIDCONFIGURATION, FIELD, DataService, vidService,\r
-                       PropertyService, UtilityService, AsdcService, $timeout, featureFlags) {\r
-\r
-               $scope.popup = {};\r
-               var defaultViewPerPage = 10;\r
-       //      var baseEndpoint = "vid";\r
-               var pathQuery = COMPONENT.SERVICES_DIST_STATUS_PATH + VIDCONFIGURATION.ASDC_MODEL_STATUS;\r
-               \r
-               if ( VIDCONFIGURATION.ASDC_MODEL_STATUS === FIELD.STATUS.ALL) {\r
-                       pathQuery = COMPONENT.SERVICES_PATH;\r
-               }\r
-        window.addEventListener("message", receiveMessage, false);\r
-\r
-               function receiveMessage(event){\r
-            if(event.data == 'navigateTo') {\r
-                $location.path('/models/services').search({});\r
-                $scope.$apply();\r
-                $scope.rememberFilter = true;\r
-            }\r
-            if(event.data == 'navigateToInstantiationStatus') {\r
-                $location.path('/instantiationStatus').search({});\r
-                $scope.$apply();\r
-            }\r
-               }\r
-\r
-               $scope.getServiceModels = function() {\r
-                       $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG_ASDC;\r
-\r
-                       $http.get(pathQuery)\r
-                       .then(function (response) {\r
-                               $scope.services = [];\r
-                               if (response.data && angular.isArray(response.data.services)) {\r
-                                       wholeData = response.data.services;\r
-                    $scope.services = $scope.filterDataWithHigherVersion(wholeData);\r
-                    $scope.viewPerPage = defaultViewPerPage;\r
-                    $scope.totalPage=$scope.services.length/$scope.viewPerPage;\r
-                    $scope.sortBy=COMPONENT.NAME;\r
-                    $scope.scrollViewPerPage=2;\r
-                    $scope.currentPage=1;\r
-                    $scope.currentPageNum=1;\r
-                    $scope.isSpinnerVisible = false;\r
-                    $scope.isProgressVisible = false;\r
-                                       var searchKey = sessionStorage.getItem("searchKey");\r
-                    if (searchKey != 'undefined' && searchKey!=null && ($scope.rememberFilter)) {\r
-                        var searchKey = JSON.parse(sessionStorage.getItem("searchKey"));\r
-                        $scope.searchString = searchKey.searchString || '';\r
-                        $scope.viewPerPage = searchKey.viewPerPage || defaultViewPerPage;\r
-                        $scope.totalPage = $scope.services.length / $scope.viewPerPage;\r
-                        $timeout(function () {\r
-                               // the table controller handles the current page once\r
-                                                       // data is loaded, therefore we're delying the paging\r
-                                                       // override\r
-                            $scope.currentPage = $scope.currentPageNum = searchKey.currentPage ? parseInt(searchKey.currentPage) : 1;\r
-                        }, 0);\r
-                        $scope.rememberFilter = false;\r
-                    }\r
-                               } else {\r
-                                       $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC;\r
-                                       $scope.error = true;\r
-                                       $scope.isSpinnerVisible = false;\r
-                               }\r
-                               $scope.deployButtonType = response.data.readOnly ? 'disabled' : 'primary';\r
-                       }, function (response) {\r
-                               console.log("Error: " + response);\r
-                       });\r
-               };\r
-\r
-               $scope.isShowOrchestrationType = function() {\r
-                       return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_SHOW_ORCHESTRATION_TYPE);\r
-               };\r
-\r
-               var wholeData=[];\r
-\r
-               $scope.filterDataWithHigherVersion = function(serviceData){\r
-                       var delimiter = '$$';\r
-                       var fiterDataServices = {};\r
-                       for(var i=0;i<serviceData.length;i++) {\r
-                               var index = serviceData[i].invariantUUID.trim() + delimiter + serviceData[i].name.trim();\r
-                               if(!fiterDataServices[index]) {\r
-                    var hasPreviousVersion = false;\r
-                    fiterDataServices[index] = {\r
-                        service: serviceData[i],\r
-                        hasPreviousVersion: false\r
-                    };\r
-                }\r
-                else {\r
-                    fiterDataServices[index].hasPreviousVersion = true;\r
-                    if(parseFloat(serviceData[i].version.trim())>parseFloat(fiterDataServices[index].service.version.trim())) {\r
-                        fiterDataServices[index].service = serviceData[i];\r
-                                       }\r
-                               }\r
-                       }\r
-            return Object.keys(fiterDataServices).map(function(key) {\r
-               var service = fiterDataServices[key].service;\r
-               service.hasPreviousVersion = fiterDataServices[key].hasPreviousVersion;\r
-                return  service;\r
-            });\r
-               };\r
-\r
-               $scope.init = function() {\r
-               var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec();\r
-               PropertyService.setMsoMaxPollingIntervalMsec(msecs);\r
-               \r
-               var polls = PropertyService.retrieveMsoMaxPolls();\r
-               PropertyService.setMsoMaxPolls(polls);\r
-        };\r
-               \r
-               $scope.prevPage = function() {\r
-                       $scope.currentPage--;\r
-               };\r
-               \r
-               $scope.nextPage = function() {\r
-                       $scope.currentPage++;\r
-               };\r
-\r
-               $scope.showReportWindow = function() {\r
-\r
-                       const modalWindow = $uibModal.open({\r
-                               templateUrl: 'app/vid/scripts/modals/report-modal/report-modal.html',\r
-                               controller: 'reportModalController',\r
-                               controllerAs: 'vm',\r
-                               resolve: {\r
-                                       errorMsg: function () {\r
-                                               return $scope.status;\r
-                                       }\r
-                               }\r
-                       });\r
-\r
-               };\r
-\r
-               $scope.isShowErrorReport = function() {\r
-                       return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_CREATE_ERROR_REPORTS);\r
-               };\r
-               \r
-               $scope.createType = COMPONENT.A_LA_CARTE;\r
-               $scope.deployService = function(service) {\r
-                       var searchKey = {\r
-                               searchString: $scope.searchString,\r
-                viewPerPage: $scope.viewPerPage,\r
-                currentPage: $scope.currentPage\r
-                       };\r
-                       sessionStorage.setItem("searchKey",JSON.stringify(searchKey));\r
-\r
-                       console.log("Instantiating SDC service " + service.uuid);\r
-\r
-                       $http.get(COMPONENT.SERVICES_PATH + service.uuid)\r
-                               .then(function (getServiceResponse) {\r
-\r
-                                       var serviceModel = getServiceResponse.data;\r
-\r
-                                       //VID-233 bug fix when models doesn't exists\r
-                                       if(typeof(serviceModel)==="string"){  //not an object\r
-                                               $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC;\r
-                                               $scope.error = true;\r
-                                               $scope.isSpinnerVisible = false;\r
-                                               $scope.isProgressVisible = true;\r
-                                               return;\r
-                                       } else{ //clean error message\r
-                                               $scope.status = "";\r
-                                               $scope.error = false;\r
-                                               $scope.isSpinnerVisible = false;\r
-                                               $scope.isProgressVisible = false;\r
-                                       }\r
-\r
-                                       DataService.setServiceName(serviceModel.service.name);\r
-\r
-                                       //VOLTE services need input list generated and macro style\r
-                                       DataService.setE2EService(false);\r
-                                       if(serviceModel.service.category === 'E2E Service') {\r
-                                               DataService.setE2EService(true);\r
-                                               DataService.setHideServiceFields(false);\r
-                                               VIDCONFIGURATION.MACRO_SERVICES.push(serviceModel.service.invariantUuid);\r
-                                       }\r
-\r
-                                       DataService.setModelInfo(COMPONENT.SERVICE, {\r
-                                               "modelInvariantId": serviceModel.service.invariantUuid,\r
-                                               "modelVersion": serviceModel.service.version,\r
-                                               "serviceType" : serviceModel.service.serviceType,\r
-                                               "serviceRole": serviceModel.service.serviceRole,\r
-                                               "modelNameVersionId": serviceModel.service.uuid,\r
-                                               "modelName": serviceModel.service.name,\r
-                                               "description": serviceModel.service.description,\r
-                                               "category":serviceModel.service.category\r
-                                       });\r
-\r
-                    var shouldTakeTheAsyncInstantiationFlow = AsdcService.shouldTakeTheAsyncInstantiationFlow(serviceModel);\r
-                    DataService.setShouldIncludeInAsyncInstantiationFlow(shouldTakeTheAsyncInstantiationFlow);\r
-\r
-                    DataService.setALaCarte (true);\r
-                    DataService.setPnf(!angular.equals(serviceModel.pnfs, {}));\r
-                                       $scope.createType = COMPONENT.A_LA_CARTE;\r
-                                       var broadcastType = COMPONENT.CREATE_COMPONENT;\r
-                    if (AsdcService.isMacro(serviceModel) || DataService.getE2EService()) {\r
-                        DataService.setALaCarte(false);\r
-                        if(!shouldTakeTheAsyncInstantiationFlow){\r
-                            $scope.createType = COMPONENT.MACRO;\r
-                            var convertedAsdcModel = UtilityService.convertModel(serviceModel);\r
-\r
-                            DataService.setModelInfo(COMPONENT.SERVICE, {\r
-                                "modelInvariantId": serviceModel.service.invariantUuid,\r
-                                "modelVersion": serviceModel.service.version,\r
-                                "modelNameVersionId": serviceModel.service.uuid,\r
-                                "modelName": serviceModel.service.name,\r
-                                "description": serviceModel.service.description,\r
-                                "category": serviceModel.service.category,\r
-                                "serviceEcompNaming": serviceModel.service.serviceEcompNaming,\r
-                                "inputs": serviceModel.service.inputs,\r
-                                "serviceType": serviceModel.service.serviceType,\r
-                                "serviceRole": serviceModel.service.serviceRole,\r
-                                "displayInputs": convertedAsdcModel.completeDisplayInputs\r
-                            });\r
-                        }\r
-                    }\r
-\r
-                                       $scope.$broadcast(broadcastType, {\r
-                                           componentId : COMPONENT.SERVICE,\r
-                        modelNameVersionId: serviceModel.service.uuid,\r
-                                           callbackFunction : function(response) {\r
-                                               if (response.isSuccessful) {\r
-                                                               vidService.setModel(serviceModel);\r
-\r
-                                                               var subscriberId = FIELD.STATUS.NOT_FOUND;\r
-                                                               var serviceType = FIELD.STATUS.NOT_FOUND;\r
-\r
-                                                               var serviceInstanceId = response.instanceId;\r
-\r
-                                                               for (var i = 0; i < response.control.length; i++) {\r
-                                                                       if (response.control[i].id == COMPONENT.SUBSCRIBER_NAME) {\r
-                                                                               subscriberId = response.control[i].value;\r
-                                                                       } else if (response.control[i].id == FIELD.ID.SERVICE_TYPE) {\r
-                                                                               serviceType = response.control[i].value;\r
-                                                                       }\r
-                                                               }\r
-\r
-\r
-                                                               $scope.refreshSubs(subscriberId,serviceType,serviceInstanceId);\r
-\r
-                                               }\r
-                                           }\r
-                                       });\r
-                               }, function (response) {\r
-                                       console.log("Error: " + response);\r
-                               });\r
-               };\r
-               \r
-               $scope.tableData=[];\r
-               var oldData=[];\r
-               $scope.loadPreviousVersionData=function(invariantUUID , name, version){\r
-                       $scope.tableData =[];\r
-                       oldData=[];\r
-                       for(var i=0;i<wholeData.length;i++){\r
-                               if(wholeData[i].invariantUUID == invariantUUID && wholeData[i].name == name && version!=wholeData[i].version){\r
-                                       oldData.push(wholeData[i]);\r
-                               }\r
-                       }\r
-                       $scope.tableData = oldData;\r
-                       $scope.createType = "Previous Version";\r
-                       var broadcastType = "createTableComponent";\r
-                       $scope.componentName = name;\r
-                       $scope.$broadcast(broadcastType, {\r
-                           componentId : COMPONENT.OLDVERSION,\r
-                           callbackFunction : function(response) {\r
-                           }\r
-                       });\r
-               };\r
-\r
-               $scope.refreshSubs = function(subscriberId, serviceType, serviceInstanceId) {\r
-                       $scope.status = FIELD.STATUS.FETCHING_SUBSCRIBER_LIST_AAI;\r
-                       $scope.init();\r
-                       $http.get( FIELD.ID.AAI_REFRESH_FULL_SUBSCRIBERS, {\r
-\r
-                       },{\r
-                               timeout: $scope.responseTimeoutMsec\r
-                       }).then(function(response){\r
-                               \r
-                               if (response.data.status < 200 || response.data.status > 202) {\r
-                                       $scope.showError(FIELD.ERROR.MSO);\r
-                                       return;\r
-                               }\r
-\r
-                               $scope.customer = response.data.customer; // get data from json\r
-\r
-                               $scope.customerList = [];\r
-\r
-                               $scope.serviceInstanceToCustomer = [];\r
-                               \r
-                               angular.forEach($scope.customer, function(subVal, subKey) {\r
-                                       var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME] };\r
-                                       $scope.customerList.push(cust);\r
-                                       if (subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) {\r
-                                                       angular.forEach(subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) {\r
-                                                               $scope.serviceInstanceId = [];\r
-                                                               if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) {\r
-                                                                       $scope.serviceType = serviceSubscription[FIELD.ID.SERVICETYPE];\r
-                                                               } else {\r
-                                                                       $scope.serviceType = FIELD.STATUS.NO_SERVICE_SUBSCRIPTION_FOUND;\r
-                                                               }\r
-                                                               if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) {\r
-                                                                       angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) {\r
-                                                                               var foo = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID], \r
-                                                                                               "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID],\r
-                                                                                               "subscriberName": subVal[FIELD.ID.SUBNAME] };\r
-                                                                               $scope.serviceInstanceToCustomer.push(foo);\r
-                                                                       });\r
-                                                               }\r
-                                                       });\r
-                                       }\r
-                               });     \r
-                               DataService.setServiceInstanceToCustomer($scope.serviceInstanceToCustomer);\r
-                               var serviceIdList = [];\r
-                               $http.get( FIELD.ID.AAI_GET_SERVICES, {\r
-                               },{\r
-                                       timeout: $scope.responseTimeoutMsec\r
-                               }).then(function(response) {\r
-                                       angular.forEach(response.data, function(value, key) {\r
-                                               angular.forEach(value, function(subVal, key) {\r
-                                                       var newVal = { "id" : subVal[FIELD.ID.SERVICE_ID], "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION] ,"isPermitted" : subVal[FIELD.ID.IS_PERMITTED] };\r
-                                                       serviceIdList.push(newVal);\r
-                                                       DataService.setServiceIdList(serviceIdList);\r
-                                                       \r
-                                                       $location.search({\r
-                                                               "subscriberId": subscriberId,\r
-                                                               "serviceType": serviceType,\r
-                                                               "serviceInstanceId": serviceInstanceId,\r
-                                                               "isPermitted": newVal.isPermitted.toString()\r
-                                                       });\r
-                                                       \r
-                                                       $location.path(COMPONENT.INSTANTIATE_PATH);\r
-                                               });\r
-                                       });\r
-                               });     \r
-                       })\r
-                       ["catch"]($scope.handleServerError);\r
-               };\r
-       });\r
-})();\r
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 IBM.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+(function () {
+       'use strict';
+
+       appDS2.controller("ServiceModelController",function ($uibModal, $scope, $http, $location, COMPONENT, VIDCONFIGURATION, FIELD, DataService, vidService,
+                       PropertyService, UtilityService, AsdcService, $timeout, featureFlags) {
+
+               $scope.popup = {};
+               var defaultViewPerPage = 10;
+       //      var baseEndpoint = "vid";
+               var pathQuery = COMPONENT.SERVICES_DIST_STATUS_PATH + VIDCONFIGURATION.ASDC_MODEL_STATUS;
+               
+               if ( VIDCONFIGURATION.ASDC_MODEL_STATUS === FIELD.STATUS.ALL) {
+                       pathQuery = COMPONENT.SERVICES_PATH;
+               }
+        window.addEventListener("message", receiveMessage, false);
+
+               function receiveMessage(event){
+            if(event.data == 'navigateTo') {
+                $location.path('/models/services').search({});
+                $scope.$apply();
+                $scope.rememberFilter = true;
+            }
+            if(event.data == 'navigateToInstantiationStatus') {
+                $location.path('/instantiationStatus').search({});
+                $scope.$apply();
+            }
+               }
+
+               $scope.getServiceModels = function() {
+                       $scope.status = FIELD.STATUS.FETCHING_SERVICE_CATALOG_ASDC;
+
+                       $http.get(pathQuery)
+                       .then(function (response) {
+                               $scope.services = [];
+                               if (response.data && angular.isArray(response.data.services)) {
+                                       wholeData = response.data.services;
+                    $scope.services = $scope.filterDataWithHigherVersion(wholeData);
+                    $scope.viewPerPage = defaultViewPerPage;
+                    $scope.totalPage=$scope.services.length/$scope.viewPerPage;
+                    $scope.sortBy=COMPONENT.NAME;
+                    $scope.scrollViewPerPage=2;
+                    $scope.currentPage=1;
+                    $scope.currentPageNum=1;
+                    $scope.isSpinnerVisible = false;
+                    $scope.isProgressVisible = false;
+                                       var searchKey = sessionStorage.getItem("searchKey");
+                    if (searchKey != 'undefined' && searchKey!=null && ($scope.rememberFilter)) {
+                        var searchKey = JSON.parse(sessionStorage.getItem("searchKey"));
+                        $scope.searchString = searchKey.searchString || '';
+                        $scope.viewPerPage = searchKey.viewPerPage || defaultViewPerPage;
+                        $scope.totalPage = $scope.services.length / $scope.viewPerPage;
+                        $timeout(function () {
+                               // the table controller handles the current page once
+                                                       // data is loaded, therefore we're delying the paging
+                                                       // override
+                            $scope.currentPage = $scope.currentPageNum = searchKey.currentPage ? parseInt(searchKey.currentPage) : 1;
+                        }, 0);
+                        $scope.rememberFilter = false;
+                    }
+                               } else {
+                                       $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC;
+                                       $scope.error = true;
+                                       $scope.isSpinnerVisible = false;
+                               }
+                               $scope.deployButtonType = response.data.readOnly ? 'disabled' : 'primary';
+                       }, function (response) {
+                               console.log("Error: " + response);
+                       });
+               };
+
+               $scope.isShowOrchestrationType = function() {
+                       return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_SHOW_ORCHESTRATION_TYPE);
+               };
+
+               var wholeData=[];
+
+               $scope.filterDataWithHigherVersion = function(serviceData){
+                       var delimiter = '$$';
+                       var fiterDataServices = {};
+                       for(var i=0;i<serviceData.length;i++) {
+                               var index = serviceData[i].invariantUUID.trim() + delimiter + serviceData[i].name.trim();
+                               if(!fiterDataServices[index]) {
+                    var hasPreviousVersion = false;
+                    fiterDataServices[index] = {
+                        service: serviceData[i],
+                        hasPreviousVersion: false
+                    };
+                }
+                else {
+                    fiterDataServices[index].hasPreviousVersion = true;
+                    if(parseFloat(serviceData[i].version.trim())>parseFloat(fiterDataServices[index].service.version.trim())) {
+                        fiterDataServices[index].service = serviceData[i];
+                                       }
+                               }
+                       }
+            return Object.keys(fiterDataServices).map(function(key) {
+               var service = fiterDataServices[key].service;
+               service.hasPreviousVersion = fiterDataServices[key].hasPreviousVersion;
+                return  service;
+            });
+               };
+
+               $scope.init = function() {
+               var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec();
+               PropertyService.setMsoMaxPollingIntervalMsec(msecs);
+               
+               var polls = PropertyService.retrieveMsoMaxPolls();
+               PropertyService.setMsoMaxPolls(polls);
+        };
+               
+               $scope.prevPage = function() {
+                       $scope.currentPage--;
+               };
+               
+               $scope.nextPage = function() {
+                       $scope.currentPage++;
+               };
+
+               $scope.showReportWindow = function() {
+
+                       const modalWindow = $uibModal.open({
+                               templateUrl: 'app/vid/scripts/modals/report-modal/report-modal.html',
+                               controller: 'reportModalController',
+                               controllerAs: 'vm',
+                               resolve: {
+                                       errorMsg: function () {
+                                               return $scope.status;
+                                       }
+                               }
+                       });
+
+               };
+
+               $scope.isShowErrorReport = function() {
+                       return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_CREATE_ERROR_REPORTS);
+               };
+               
+               $scope.createType = COMPONENT.A_LA_CARTE;
+               $scope.deployService = function(service) {
+                       var searchKey = {
+                               searchString: $scope.searchString,
+                viewPerPage: $scope.viewPerPage,
+                currentPage: $scope.currentPage
+                       };
+                       DataService.setHasTemplate(service.hasTemplate);
+                       sessionStorage.setItem("searchKey",JSON.stringify(searchKey));
+
+                       console.log("Instantiating SDC service " + service.uuid);
+
+                       $http.get(COMPONENT.SERVICES_PATH + service.uuid)
+                               .then(function (getServiceResponse) {
+
+                                       var serviceModel = getServiceResponse.data;
+
+                                       //VID-233 bug fix when models doesn't exists
+                                       if(typeof(serviceModel)==="string"){  //not an object
+                                               $scope.status = FIELD.STATUS.FAILED_SERVICE_MODELS_ASDC;
+                                               $scope.error = true;
+                                               $scope.isSpinnerVisible = false;
+                                               $scope.isProgressVisible = true;
+                                               return;
+                                       } else{ //clean error message
+                                               $scope.status = "";
+                                               $scope.error = false;
+                                               $scope.isSpinnerVisible = false;
+                                               $scope.isProgressVisible = false;
+                                       }
+
+                                       DataService.setServiceName(serviceModel.service.name);
+
+                                       //VOLTE services need input list generated and macro style
+                                       DataService.setE2EService(false);
+                                       if(serviceModel.service.category === 'E2E Service') {
+                                               DataService.setE2EService(true);
+                                               DataService.setHideServiceFields(false);
+                                               VIDCONFIGURATION.MACRO_SERVICES.push(serviceModel.service.invariantUuid);
+                                       }
+
+                                       DataService.setModelInfo(COMPONENT.SERVICE, {
+                                               "modelInvariantId": serviceModel.service.invariantUuid,
+                                               "modelVersion": serviceModel.service.version,
+                                               "serviceType" : serviceModel.service.serviceType,
+                                               "serviceRole": serviceModel.service.serviceRole,
+                                               "modelNameVersionId": serviceModel.service.uuid,
+                                               "modelName": serviceModel.service.name,
+                                               "description": serviceModel.service.description,
+                                               "category":serviceModel.service.category
+                                       });
+
+                    var shouldTakeTheAsyncInstantiationFlow = AsdcService.shouldTakeTheAsyncInstantiationFlow(serviceModel);
+                    DataService.setShouldIncludeInAsyncInstantiationFlow(shouldTakeTheAsyncInstantiationFlow);
+
+                    DataService.setALaCarte (true);
+                    DataService.setPnf(!angular.equals(serviceModel.pnfs, {}));
+                                       $scope.createType = COMPONENT.A_LA_CARTE;
+                                       var broadcastType = COMPONENT.CREATE_COMPONENT;
+                    if (AsdcService.isMacro(serviceModel) || DataService.getE2EService()) {
+                        DataService.setALaCarte(false);
+                        if(!shouldTakeTheAsyncInstantiationFlow){
+                            $scope.createType = COMPONENT.MACRO;
+                            var convertedAsdcModel = UtilityService.convertModel(serviceModel);
+
+                            DataService.setModelInfo(COMPONENT.SERVICE, {
+                                "modelInvariantId": serviceModel.service.invariantUuid,
+                                "modelVersion": serviceModel.service.version,
+                                "modelNameVersionId": serviceModel.service.uuid,
+                                "modelName": serviceModel.service.name,
+                                "description": serviceModel.service.description,
+                                "category": serviceModel.service.category,
+                                "serviceEcompNaming": serviceModel.service.serviceEcompNaming,
+                                "inputs": serviceModel.service.inputs,
+                                "serviceType": serviceModel.service.serviceType,
+                                "serviceRole": serviceModel.service.serviceRole,
+                                "displayInputs": convertedAsdcModel.completeDisplayInputs
+                            });
+                        }
+                    }
+
+                                       $scope.$broadcast(broadcastType, {
+                                           componentId : COMPONENT.SERVICE,
+                        modelNameVersionId: serviceModel.service.uuid,
+                                           callbackFunction : function(response) {
+                                               if (response.isSuccessful) {
+                                                               vidService.setModel(serviceModel);
+
+                                                               var subscriberId = FIELD.STATUS.NOT_FOUND;
+                                                               var serviceType = FIELD.STATUS.NOT_FOUND;
+
+                                                               var serviceInstanceId = response.instanceId;
+
+                                                               for (var i = 0; i < response.control.length; i++) {
+                                                                       if (response.control[i].id == COMPONENT.SUBSCRIBER_NAME) {
+                                                                               subscriberId = response.control[i].value;
+                                                                       } else if (response.control[i].id == FIELD.ID.SERVICE_TYPE) {
+                                                                               serviceType = response.control[i].value;
+                                                                       }
+                                                               }
+
+
+                                                               $scope.refreshSubs(subscriberId,serviceType,serviceInstanceId);
+
+                                               }
+                                           }
+                                       });
+                               }, function (response) {
+                                       console.log("Error: " + response);
+                               });
+               };
+               
+               $scope.tableData=[];
+               var oldData=[];
+               $scope.loadPreviousVersionData=function(invariantUUID , name, version){
+                       $scope.tableData =[];
+                       oldData=[];
+                       for(var i=0;i<wholeData.length;i++){
+                               if(wholeData[i].invariantUUID == invariantUUID && wholeData[i].name == name && version!=wholeData[i].version){
+                                       oldData.push(wholeData[i]);
+                               }
+                       }
+                       $scope.tableData = oldData;
+                       $scope.createType = "Previous Version";
+                       var broadcastType = "createTableComponent";
+                       $scope.componentName = name;
+                       $scope.$broadcast(broadcastType, {
+                           componentId : COMPONENT.OLDVERSION,
+                           callbackFunction : function(response) {
+                           }
+                       });
+               };
+
+               $scope.refreshSubs = function(subscriberId, serviceType, serviceInstanceId) {
+                       $scope.status = FIELD.STATUS.FETCHING_SUBSCRIBER_LIST_AAI;
+                       $scope.init();
+                       $http.get( FIELD.ID.AAI_REFRESH_FULL_SUBSCRIBERS, {
+
+                       },{
+                               timeout: $scope.responseTimeoutMsec
+                       }).then(function(response){
+                               
+                               if (response.data.status < 200 || response.data.status > 202) {
+                                       $scope.showError(FIELD.ERROR.MSO);
+                                       return;
+                               }
+
+                               $scope.customer = response.data.customer; // get data from json
+
+                               $scope.customerList = [];
+
+                               $scope.serviceInstanceToCustomer = [];
+                               
+                               angular.forEach($scope.customer, function(subVal, subKey) {
+                                       var cust = { "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID], "subscriberName": subVal[FIELD.ID.SUBNAME] };
+                                       $scope.customerList.push(cust);
+                                       if (subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS] != null) {
+                                                       angular.forEach(subVal[FIELD.ID.SERVICE_SUBSCRIPTIONS][FIELD.ID.SERVICE_SUBSCRIPTION], function(serviceSubscription, key) {
+                                                               $scope.serviceInstanceId = [];
+                                                               if (serviceSubscription[FIELD.ID.SERVICETYPE] != null) {
+                                                                       $scope.serviceType = serviceSubscription[FIELD.ID.SERVICETYPE];
+                                                               } else {
+                                                                       $scope.serviceType = FIELD.STATUS.NO_SERVICE_SUBSCRIPTION_FOUND;
+                                                               }
+                                                               if (serviceSubscription[FIELD.ID.SERVICE_INSTANCES] != null) {
+                                                                       angular.forEach(serviceSubscription[FIELD.ID.SERVICE_INSTANCES][FIELD.ID.SERVICE_INSTANCE], function(instValue, instKey) {
+                                                                               var foo = { "serviceInstanceId": instValue[FIELD.ID.SERVICE_INSTANCE_ID], 
+                                                                                               "globalCustomerId": subVal[FIELD.ID.GLOBAL_CUSTOMER_ID],
+                                                                                               "subscriberName": subVal[FIELD.ID.SUBNAME] };
+                                                                               $scope.serviceInstanceToCustomer.push(foo);
+                                                                       });
+                                                               }
+                                                       });
+                                       }
+                               });     
+                               DataService.setServiceInstanceToCustomer($scope.serviceInstanceToCustomer);
+                               var serviceIdList = [];
+                               $http.get( FIELD.ID.AAI_GET_SERVICES, {
+                               },{
+                                       timeout: $scope.responseTimeoutMsec
+                               }).then(function(response) {
+                                       angular.forEach(response.data, function(value, key) {
+                                               angular.forEach(value, function(subVal, key) {
+                                                       var newVal = { "id" : subVal[FIELD.ID.SERVICE_ID], "description" : subVal[FIELD.ID.SERVICE_DESCRIPTION] ,"isPermitted" : subVal[FIELD.ID.IS_PERMITTED] };
+                                                       serviceIdList.push(newVal);
+                                                       DataService.setServiceIdList(serviceIdList);
+                                                       
+                                                       $location.search({
+                                                               "subscriberId": subscriberId,
+                                                               "serviceType": serviceType,
+                                                               "serviceInstanceId": serviceInstanceId,
+                                                               "isPermitted": newVal.isPermitted.toString()
+                                                       });
+                                                       
+                                                       $location.path(COMPONENT.INSTANTIATE_PATH);
+                                               });
+                                       });
+                               });     
+                       })
+                       ["catch"]($scope.handleServerError);
+               };
+       });
+})();
index a35411d..002bcb9 100755 (executable)
@@ -93,9 +93,13 @@ var creationDialogController = function (COMPONENT, FIELD, PARAMETER, $scope, $h
 
 
         if (!$scope.shouldShowOldPopup()) {
-            $scope.url = COMPONENT.SERVICE_POPUP_IFRAME_URL + request.modelNameVersionId + "&isCreate=true&r=" + Math.random();
-            window.addEventListener("message", receiveMessage, false);
-
+            if(DataService.getHasTemplate()){
+                $scope.url = COMPONENT.INSTANTIATION_TEMPLATES_IFRAME_URL + request.modelNameVersionId;
+                window.addEventListener("message", receiveMessage, false);
+            }else {
+                $scope.url = COMPONENT.SERVICE_POPUP_IFRAME_URL + request.modelNameVersionId + "&isCreate=true&r=" + Math.random();
+                window.addEventListener("message", receiveMessage, false);
+            }
         }
         else {
             callbackFunction = request.callbackFunction;
index 56729f2..10c4277 100755 (executable)
@@ -319,6 +319,12 @@ var DataService = function($log, DataService) {
                },
                setOwningEntityProperties: function (properties) {
                                _this.owningEntityProperties = properties;
+               },
+               getHasTemplate: function () {
+                               return _this.hasTemplate;
+               },
+               setHasTemplate: function (hasTemplate) {
+                               _this.hasTemplate = hasTemplate;
                }
        };
 };
index 27be3fb..5f425fa 100644 (file)
@@ -32,10 +32,12 @@ import static org.hamcrest.core.IsEqual.equalTo;
 import static org.onap.vid.job.Job.JobStatus.COMPLETED;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
 import java.time.LocalDateTime;
 import java.time.ZonedDateTime;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
 import javax.inject.Inject;
 import org.onap.portalsdk.core.service.DataAccessService;
@@ -84,6 +86,8 @@ public class AsyncInstantiationRepositoryTest extends AsyncInstantiationBaseTest
             MODEL_UUID, ServiceAction.INSTANTIATE);
         addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "hidden", NOW, NOW, COMPLETED, true, false,
             MODEL_UUID, ServiceAction.INSTANTIATE);
+        addNewServiceInfoWithAction(UUID.randomUUID(), "abc", "4", NOW, NOW, COMPLETED, false, false,
+            MODEL_UUID_3, ServiceAction.UPDATE);
     }
 
     @DataProvider
@@ -102,6 +106,13 @@ public class AsyncInstantiationRepositoryTest extends AsyncInstantiationBaseTest
             contains(expectedResult));
     }
 
+    @Test
+    public void getAllTemplatesServiceModelIds_givenDbWithSeveralModelIDs_2ReturnedAnd1OmittedAndDuplicatesRemoved() {
+            Set<String> actual = asyncInstantiationRepository.getAllTemplatesServiceModelIds();
+            // MODEL_UUID3 is Action=UPDATE, therefore omitted
+            assertThat(actual, equalTo(ImmutableSet.of(MODEL_UUID, MODEL_UUID_2)));
+    }
+
     @Test
     public void whenFilterServiceByNotExistUUID_emptyListIsReturned() {
         List<ServiceInfo> serviceInfoListResult = asyncInstantiationRepository.listInstantiatedServicesByServiceModelId(UUID.randomUUID());
index 7c0abbe..b953500 100644 (file)
@@ -79,6 +79,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
 
     public static final String MODEL_UUID = "337be3fc-293e-43ec-af0b-cf932dad07e6";
     public static final String MODEL_UUID_2 = "ce052844-22ba-4030-a838-822f2b39eb9b";
+    public static final String MODEL_UUID_3 = "47a071cd-99f7-49bb-bc8b-f957979d6fe1";
 
     public static final String OWNING_ENTITY_ID = "038d99af-0427-42c2-9d15-971b99b9b489";
     public static final String JULIO_ERICKSON = "JULIO ERICKSON";
index fa7181c..e2f3380 100644 (file)
@@ -1,27 +1,40 @@
 package vid.automation.test.test;
 
 
+import static org.testng.AssertJUnit.assertFalse;
+import static vid.automation.test.Constants.DrawingBoard.AVAILABLE_MODELS_TREE;
+import static vid.automation.test.Constants.DrawingBoard.BACK_BUTTON;
+import static vid.automation.test.Constants.DrawingBoard.CONTEXT_MENU_BUTTON_HEADER;
+import static vid.automation.test.Constants.DrawingBoard.CONTEXT_MENU_HEADER_EDIT_ITEM;
+import static vid.automation.test.Constants.DrawingBoard.DEFAULT_SERVICE_NAME;
+import static vid.automation.test.Constants.DrawingBoard.DRAWING_BOARD_TREE;
+import static vid.automation.test.Constants.DrawingBoard.SEARCH_LEFT_TREE;
+import static vid.automation.test.Constants.DrawingBoard.SERVICE_QUANTITY;
+import static vid.automation.test.infra.ModelInfo.macroDrawingBoardComplexService;
+import static vid.automation.test.infra.ModelInfo.macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails;
+
 import com.google.common.collect.ImmutableList;
-import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2;
 import org.onap.sdc.ci.tests.datatypes.UserCredentials;
 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
+import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2;
 import org.openqa.selenium.WebDriver;
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 import vid.automation.test.Constants;
-import vid.automation.test.infra.*;
+import vid.automation.test.infra.Click;
+import vid.automation.test.infra.Exists;
+import vid.automation.test.infra.Get;
+import vid.automation.test.infra.Input;
+import vid.automation.test.infra.ModelInfo;
+import vid.automation.test.infra.SelectOption;
+import vid.automation.test.infra.Wait;
 import vid.automation.test.model.User;
 import vid.automation.test.sections.BrowseASDCPage;
 import vid.automation.test.sections.DrawingBoardPage;
 import vid.automation.test.sections.VidBasePage;
 
-import static org.testng.AssertJUnit.assertFalse;
-import static vid.automation.test.Constants.DrawingBoard.*;
-import static vid.automation.test.infra.ModelInfo.macroDrawingBoardComplexService;
-import static vid.automation.test.infra.ModelInfo.macroSriovNoDynamicFieldsEcompNamingFalseFullModelDetails;
-
 public class DrawingBoardTest extends VidBaseTestCase {
 
     private DrawingBoardPage drawingBoardPage = new DrawingBoardPage();
@@ -323,6 +336,7 @@ public class DrawingBoardTest extends VidBaseTestCase {
         Click.byTestId(CONTEXT_MENU_BUTTON_HEADER);
         Click.byTestId(CONTEXT_MENU_HEADER_EDIT_ITEM);
         Assert.assertTrue(Exists.byId("instance-popup"), "context menu should not appear");
+        GeneralUIUtils.ultimateWait();
         SelectOption.byIdAndVisibleText("quantity-select", String.valueOf(updatedQuantity));
         Input.replaceText(updatedInstanceName,Constants.BrowseASDC.NewServicePopup.INSTANCE_NAME );
         Click.byTestId(Constants.BrowseASDC.NewServicePopup.SET_BUTTON);
@@ -341,6 +355,7 @@ public class DrawingBoardTest extends VidBaseTestCase {
         Click.byTestId(CONTEXT_MENU_BUTTON_HEADER);
         Click.byTestId(CONTEXT_MENU_HEADER_EDIT_ITEM);
         Assert.assertTrue(Exists.byId("instance-popup"), "context menu should not appear");
+        GeneralUIUtils.ultimateWait();
         SelectOption.byIdAndVisibleText("quantity-select", String.valueOf(updatedQuantity));
         Input.replaceText(updatedInstanceName,Constants.BrowseASDC.NewServicePopup.INSTANCE_NAME );
         Click.byTestId(Constants.BrowseASDC.NewServicePopup.CANCEL_BUTTON);
index 8a5a2f1..68a3cde 100644 (file)
@@ -378,12 +378,10 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
 
         // Wizard pages of Network and VPN
         Click.byTestIdOnceItsAvailable("10a74149-c9d7-4918-bbcf-d5fb9b1799ce", 20);
-        Click.byTestId("setMembersBtn");
-        GeneralUIUtils.ultimateWait();
+        clickToCloseModal("setMembersBtn");
 
         Click.byTestIdOnceItsAvailable("120d39fb-3627-473d-913c-d228dd0f8e5b", 20);
-        Click.byTestId("setMembersBtn");
-        GeneralUIUtils.ultimateWait();
+        clickToCloseModal("setMembersBtn");
 
         Assert.assertEquals(Get.byTestId("node-type-indicator").getText(),"VRF");
 
@@ -538,7 +536,7 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
     private void editVfModuleAndJustSetName(String vfModuleName, String vfModuleUUID) {
         hoverAndClickEditButton(vfModuleUUID + "-" + vfModuleName);
         Input.text("VF instance name ZERO", "instanceName");
-        Click.byTestId(VNF_SET_BUTTON_TEST_ID);
+        clickToCloseModal(VNF_SET_BUTTON_TEST_ID);
     }
 
     @Test
@@ -1209,7 +1207,7 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
         }
 
         vidBasePage.screenshotDeployDialog("createVnf-" + serviceInstanceName);
-        Click.byTestId(VNF_SET_BUTTON_TEST_ID);
+        clickToCloseModal(VNF_SET_BUTTON_TEST_ID);
         if (isNetwork) {
             return;
         }
@@ -1224,8 +1222,7 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
 
             Assert.assertTrue(Get.isOptionSelectedInMultiSelect(Constants.OwningEntity.PLATFORM_MULTI_SELECT_TEST_ID, "platform"));
 
-            Click.byTestId(Constants.CANCEL_BUTTON_TEST_ID);
-            GeneralUIUtils.ultimateWait();
+            clickToCloseModal(Constants.CANCEL_BUTTON_TEST_ID);
         } else {
             toggleItemInTree(Constants.DrawingBoard.AVAILABLE_MODELS_TREE);
         }
@@ -1345,7 +1342,12 @@ public class NewServiceInstanceTest extends CreateInstanceDialogBaseTest {
         uploadSupplementaryFile("sample.json", true, browseASDCPage, setButtonTestId);
 
         browseASDCPage.screenshotDeployDialog("createVfModule-" + serviceInstanceName);
-        Click.byTestId(setButtonTestId);
+        clickToCloseModal(setButtonTestId);
+    }
+
+    private void clickToCloseModal(String setOrCancelButtonTestId) {
+        Click.byTestId(setOrCancelButtonTestId);
+        GeneralUIUtils.ultimateWait();
     }
 
     private void clickEditVfModule(ServiceData serviceData) {
index cf3d508..9d84e96 100644 (file)
@@ -138,13 +138,12 @@ public class InstantiationTemplatesApiTest extends AsyncInstantiationBase {
 
         String jobId = postAsyncInstanceRequest(request);
 
-        assertThat(fetchRecentTemplateInfo(request.at("/modelInfo/modelVersionId").asText()), allOf(
-            jsonPartEquals("jobId", jobId),
+        assertThat(fetchTemplateInfo(request.at("/modelInfo/modelVersionId").asText(), jobId),
             jsonPartEquals("requestSummary", ImmutableMap.of(
                 "vnf", 1L,
                 "vfModule", 2L,
                 "volumeGroup", 1L
-            ))));
+            )));
     }
 
     @Test
@@ -157,8 +156,7 @@ public class InstantiationTemplatesApiTest extends AsyncInstantiationBase {
 
         String jobId = postAsyncInstanceRequest(request);
 
-        assertThat(fetchRecentTemplateInfo(request.at("/modelInfo/modelVersionId").asText()), allOf(
-            jsonPartEquals("jobId", jobId),
+        assertThat(fetchTemplateInfo(request.at("/modelInfo/modelVersionId").asText(), jobId), allOf(
             jsonEquals(templateInfoFromFile()).when(IGNORING_VALUES), // Assert only field types
             jsonEquals(templateInfoFromFile()).whenIgnoringPaths(
                 // Ignore the fields where values are always changing
@@ -169,8 +167,9 @@ public class InstantiationTemplatesApiTest extends AsyncInstantiationBase {
             )));
     }
 
-    private JsonNode fetchRecentTemplateInfo(String serviceModelId) {
+    private JsonNode fetchTemplateInfo(String serviceModelId, String jobId) {
         return stream(restTemplate.getForObject(getTemplateInfoUrl(serviceModelId), JsonNode[].class))
+            .filter(it -> it.at("/jobId").asText().equals(jobId))
             .findFirst()
             .orElseGet(() -> {
                 throw new AssertionError(getTemplateInfoUrl(serviceModelId) + " returned zero results");
index b3ef7f0..4276965 100644 (file)
@@ -4,72 +4,105 @@ import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder';
 import {ServiceModel} from '../../support/jsonBuilders/models/service.model';
 
 describe('Browse SDC', function () {
-    var jsonBuilderAndMock : JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
+  const jsonBuilderAndMock: JsonBuilder<ServiceModel> = new JsonBuilder<ServiceModel>();
 
 
-    beforeEach(() => {
-        cy.clearSessionStorage();
-        cy.preventErrorsOnLoading();
-        cy.initAAIMock();
-        cy.initVidMock();
-        cy.initZones();
-        cy.login();
-        cy.visit("welcome.htm")
+  beforeEach(() => {
+    cy.clearSessionStorage();
+    cy.preventErrorsOnLoading();
+    cy.initAAIMock();
+    cy.initVidMock();
+    cy.initZones();
+    cy.login();
+    cy.visit("welcome.htm")
+  });
+
+  afterEach(() => {
+    cy.screenshot();
+  });
+
+  it(`browse sdc open macro with network and then macro for new flow`, function () {
+    // const MACRO_WITH_CONFIGURATION_ID: string = 'ee6d61be-4841-4f98-8f23-5de9da846ca7';
+    const MACRO_WITH_NETWORK_ID: string = "bd8ffd14-da36-4f62-813c-6716ba9f4354";
+    const MACRO_FOR_NEW_FLOW_ID: string = '74fa72dd-012b-49c3-800d-06b12bcaf1a0';
+    const CANCEL_BUTTON = "cancelButton";
+
+    cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/list-services.json').then((res) => {
+      jsonBuilderAndMock.basicJson(res,
+        Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED',
+        200,
+        0,
+        'list_services');
     });
 
-    afterEach(() => {
-      cy.screenshot();
+    cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/service-with-configuration.json').then((res) => {
+      jsonBuilderAndMock.basicJson(res,
+        Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_WITH_NETWORK_ID,
+        200,
+        0,
+        'MACRO_WITH_CONFIGURATION');
     });
 
-    it(`browse sdc open macro with network and then macro for new flow`, function () {
-       // const MACRO_WITH_CONFIGURATION_ID: string = 'ee6d61be-4841-4f98-8f23-5de9da846ca7';
-      const MACRO_WITH_NETWORK_ID: string = "bd8ffd14-da36-4f62-813c-6716ba9f4354";
-      const MACRO_FOR_NEW_FLOW_ID: string = '74fa72dd-012b-49c3-800d-06b12bcaf1a0';
-      const CANCEL_BUTTON = "cancelButton";
-
-      cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/list-services.json').then((res) => {
-        jsonBuilderAndMock.basicJson(res,
-          Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED',
-          200,
-          0,
-          'list_services');
-      });
+    cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/Dror_service1806_Macro1.json').then((res) => {
+      jsonBuilderAndMock.basicJson(res,
+        Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_FOR_NEW_FLOW_ID,
+        200,
+        0,
+        'MACRO_FOR_NEW_FLOW');
+    });
 
-      cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/service-with-configuration.json').then((res) => {
-        jsonBuilderAndMock.basicJson(res,
-          Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_WITH_NETWORK_ID,
-          200,
-          0,
-          'MACRO_WITH_CONFIGURATION');
-      });
+    cy.get('span').contains('Browse SDC Service Models').click({force: true});
+    cy.wait("@list_services").then(() => {
+      cy.getElementByDataTestsId('deploy-' + MACRO_WITH_NETWORK_ID).click({force: true})
+        .getElementByDataTestsId(CANCEL_BUTTON).click({force: true});
+      cy.getElementByDataTestsId('deploy-' + MACRO_FOR_NEW_FLOW_ID).click({force: true});
+      cy.get("iframe");
+    });
 
-      cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/Dror_service1806_Macro1.json').then((res) => {
-        jsonBuilderAndMock.basicJson(res,
-          Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_FOR_NEW_FLOW_ID,
-          200,
-          0,
-          'MACRO_FOR_NEW_FLOW');
-      });
+    cy.visit("welcome.htm"); //relaod page to not break the following tests
+
+  });
+
+  it(`browse sdc should open instantiation template modal if service hasTemplate is true`, function () {
+    const SERVICE_MODEL_ID: string = '74fa72dd-012b-49c3-800d-06b12bcaf1a0';
 
-      cy.get('span').contains('Browse SDC Service Models').click({force: true});
-      cy.wait("@list_services").then(() => {
-        cy.getElementByDataTestsId('deploy-' + MACRO_WITH_NETWORK_ID).click({force: true})
-          .getElementByDataTestsId(CANCEL_BUTTON).click({force: true});
-        cy.getElementByDataTestsId('deploy-' + MACRO_FOR_NEW_FLOW_ID).click({force: true});
-        cy.get("iframe");
+    cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/list-services.json').then((res) => {
+      res.services = res.services.map((service: { uuid: string, hasTemplate: boolean }) => {
+        if (service.uuid === SERVICE_MODEL_ID) {
+          service.hasTemplate = true;
+        }
+        return service;
       });
+      jsonBuilderAndMock.basicJson(res,
+        Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED',
+        200,
+        0,
+        'list_services');
+    });
 
-      cy.visit("welcome.htm"); //relaod page to not break the following tests
+    cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/Dror_service1806_Macro1.json').then((res) => {
+      jsonBuilderAndMock.basicJson(res,
+        Cypress.config('baseUrl') + '/rest/models/services/' + SERVICE_MODEL_ID,
+        200,
+        0,
+        'MACRO_FOR_NEW_FLOW');
+    });
 
+
+    cy.get('span').contains('Browse SDC Service Models').click({force: true});
+    cy.wait("@list_services").then(() => {
+      cy.getElementByDataTestsId('deploy-' + SERVICE_MODEL_ID).click({force: true});
+      cy.get('iframe').then(function ($iframe) {
+        expect($iframe.attr('src')).to.contain(`app/ui/#/instantiationTemplatesPopup?serviceModelId=${SERVICE_MODEL_ID}`);
+      });
     });
+  });
 
   it(`browse sdc of service without instantiationType open aLaCarte popup`, function () {
     const VERY_OLD_SERVICE_UUID: string = "09c476c7-91ae-44b8-a731-04d8d8fa3695";
-    const TEST_MOCKS_PATH="cypress/support/jsonBuilders/mocks/jsons/bug_aLaCarteServiceWrongPopup/";
+    const TEST_MOCKS_PATH = "cypress/support/jsonBuilders/mocks/jsons/bug_aLaCarteServiceWrongPopup/";
 
-    const CANCEL_BUTTON = "cancelButton";
-
-    cy.readFile(TEST_MOCKS_PATH+'list-services.json').then((res) => {
+    cy.readFile(TEST_MOCKS_PATH + 'list-services.json').then((res) => {
       jsonBuilderAndMock.basicJson(res,
         Cypress.config('baseUrl') + '/rest/models/services?distributionStatus=DISTRIBUTED',
         200,
@@ -77,7 +110,7 @@ describe('Browse SDC', function () {
         'list_services');
     });
 
-    cy.readFile(TEST_MOCKS_PATH+'serviceWithoutInstantiationType.json').then((res) => {
+    cy.readFile(TEST_MOCKS_PATH + 'serviceWithoutInstantiationType.json').then((res) => {
       jsonBuilderAndMock.basicJson(res,
         Cypress.config('baseUrl') + '/rest/models/services/' + VERY_OLD_SERVICE_UUID,
         200,
@@ -96,5 +129,4 @@ describe('Browse SDC', function () {
   });
 
 
-
 });
index 1da12a5..5afcc97 100644 (file)
@@ -182,6 +182,21 @@ describe('Drawing Board: Instantiation Templates', function () {
 
       });
 
+      it('Given a template - User can remove existing vfmodule', function () {
+
+        loadDrawingBoardWithRecreateMode();
+        nodeAction('node-c09e4530-8fd8-418f-9483-2f57ce927b05-vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1', 'Remove');
+        let removed_vfModule_Path = [
+          ...vnfPath, "vfModules",
+          "vprobe_nc_vnf0..VprobeNcVnf..FE_Add_On_Module_vlbagent_eph..module-1",
+        ];
+
+        assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd([
+          {path: [...vnfPath, "vnfStoreKey"], value: "vProbe_NC_VNF 0"}, // side-effect
+          {path: [...removed_vfModule_Path], value: undefined},
+        ]);
+      });
+
       [
         {desc: "with changes", modifySomeValues: true},
         {desc: "without changes", modifySomeValues: false},
@@ -246,7 +261,46 @@ describe('Drawing Board: Instantiation Templates', function () {
         assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd_network();
       });
 
+      it(`Given a stored template of Network - User can remove existing network`,  () => {
+
+        loadDrawingBoardWithRecreateModeNetwork();
+
+        nodeAction('node-01f4c475-3f89-4f00-a2f4-39a873dba0ae-SR-IOV Provider 2-1', 'Remove');
+        let removed_network_Path = [
+          "networks", "SR-IOV Provider 2-1",
+        ];
 
+        let removed_network_counter_Path = [
+          "existingNetworksCounterMap", "f6b6d141-0d4c-427d-ad35-797f3d1abe71",
+        ];
+
+        assertThatBodyFromDeployRequestEqualsToTemplateFromBackEnd_network([
+          {path: removed_network_Path, value: undefined},
+          {path: removed_network_counter_Path, value: 0},
+        ]);
+      });
+
+      it('Given a template - User can add a new network', () => {
+
+        loadDrawingBoardWithRecreateModeNetwork();
+
+        // add new node
+        addNewNode('node-SR-IOV Provider 2-1-add-btn')
+        .fillNetworkPopup()
+        .getDrawingBoardDeployBtn().click()
+        .wait('@expectedPostAsyncInstantiation').then(xhr => {
+          const networkRequest = bodyOf(xhr).networks['SR-IOV Provider 2-1_1'];
+
+          expect(networkRequest.action).equals("Create");
+          expect(networkRequest.rollbackOnFailure).equals("true");
+          expect(networkRequest.originalName).equals("SR-IOV Provider 2-1");
+          expect(networkRequest.productFamilyId).equals("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
+          expect(networkRequest.lcpCloudRegionId).equals("hvf6");
+          expect(networkRequest.lineOfBusiness).equals("zzz1");
+          expect(networkRequest.platformName).equals("xxx1");
+          expect(networkRequest.tenantId).equals("229bcdc6eaeb4ca59d55221141d01f8e");
+        });
+      });
     });
   });
 });
index dd17e7d..7fb7ea5 100644 (file)
@@ -1,89 +1,45 @@
 ///<reference path="../../../node_modules/cypress/types/index.d.ts"/>
 describe('Template', () => {
-
-  const instantiationTemplates = [
-    {
-      "id": 8,
-      "created": 1525075968000,
-      "modified": 1525075971000,
-      "action": "INSTANTIATE",
-      "createdId": null,
-      "modifiedId": null,
-      "rowNum": null,
-      "auditUserId": null,
-      "auditTrail": null,
-      "jobId": "5c2cd8e5-27d0-42e3-85a1-85db5eaba459",
-      "templateId": "d42ba7c8-9e19-4e34-ae2c-d8af3f24498e",
-      "userId": "16807000",
-      "aLaCarte": false,
-      "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d9c",
-      "jobStatus": "FAILED",
-      "statusModifiedDate": 1525075968000,
-      "hidden": false,
-      "pause": false,
-      "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
-      "owningEntityName": "WayneHolland",
-      "project": "WATKINS",
-      "aicZoneId": "NFT1",
-      "aicZoneName": "NFTJSSSS-NFT1",
-      "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
-      "tenantName": "AIN Web Tool-15-D-testalexandria",
-      "regionId": "hvf6",
-      "regionName": null,
-      "serviceType": "TYLER SILVIA",
-      "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89",
-      "serviceInstanceId": null,
-      "serviceInstanceName": "nWUfl instance name_002",
-      "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
-      "serviceModelName": "action-data",
-      "serviceModelVersion": "1.0",
-      "createdBulkDate": 1525075968000,
-      "isRetryEnabled": true,
-      "requestSummary": {
-        "vnf": 1,
-        "vfModule": 2,
-        "volumeGroup": 1
-      }
-    },
-    {
-      "id": 7,
-      "created": 1525075968000,
-      "modified": 1525075971000,
-      "action": "INSTANTIATE",
-      "createdId": null,
-      "modifiedId": null,
-      "rowNum": null,
-      "auditUserId": null,
-      "auditTrail": null,
-      "jobId": "13063a83-924e-4500-a3a1-e53d1b58450b",
-      "templateId": "d42ba7c8-9e19-4e34-ae2c-d8af3f24498e",
-      "userId": "17807000",
-      "aLaCarte": false,
-      "msoRequestId": "c0011670-0e1a-4b74-945d-8bf5aede1d9d",
-      "jobStatus": "IN_PROGRESS",
-      "statusModifiedDate": 1525075968000,
-      "hidden": false,
-      "pause": false,
-      "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
-      "owningEntityName": "WayneHolland",
-      "project": "WATKINS",
-      "aicZoneId": "NFT1",
-      "aicZoneName": "NFTJSSSS-NFT1",
-      "tenantId": "bae71557c5bb4d5aac6743a4e5f1d054",
-      "tenantName": "AIN Web Tool-15-D-testalexandria",
-      "regionId": "hvf6",
-      "regionName": null,
-      "serviceType": "TYLER SILVIA",
-      "subscriberName": "e433710f-9217-458d-a79d-1c7aff376d89",
-      "serviceInstanceId": null,
-      "serviceInstanceName": "nWUfl instance name_001",
-      "serviceModelId": "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
-      "serviceModelName": "action-data",
-      "serviceModelVersion": "1.0",
-      "createdBulkDate": 1525075968000,
-      "isRetryEnabled": false
-    }
-  ];
+  const templateJobIdFromE2EFile = 'ef3430f8-6350-454c-a7c2-89ba301522c1';
+
+  const aSecondTemplateInfo = {
+    id: 7,
+    created: 1525075968000,
+    modified: 1525075971000,
+    action: "INSTANTIATE",
+    createdId: null,
+    modifiedId: null,
+    rowNum: null,
+    auditUserId: null,
+    auditTrail: null,
+    jobId: "13063a83-924e-4500-a3a1-e53d1b58450b",
+    templateId: "d42ba7c8-9e19-4e34-ae2c-d8af3f24498e",
+    userId: "17807000",
+    aLaCarte: false,
+    msoRequestId: "c0011670-0e1a-4b74-945d-8bf5aede1d9d",
+    jobStatus: "IN_PROGRESS",
+    statusModifiedDate: 1525075968000,
+    hidden: false,
+    pause: false,
+    owningEntityId: "d61e6f2d-12fa-4cc2-91df-7c244011d6fc",
+    owningEntityName: "WayneHolland",
+    project: "WATKINS",
+    aicZoneId: "NFT1",
+    aicZoneName: "NFTJSSSS-NFT1",
+    tenantId: "bae71557c5bb4d5aac6743a4e5f1d054",
+    tenantName: "AIN Web Tool-15-D-testalexandria",
+    regionId: "hvf6",
+    regionName: null,
+    serviceType: "TYLER SILVIA",
+    subscriberName: "e433710f-9217-458d-a79d-1c7aff376d89",
+    serviceInstanceId: null,
+    serviceInstanceName: "nWUfl instance name_001",
+    serviceModelId: "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
+    serviceModelName: "action-data",
+    serviceModelVersion: "1.0",
+    createdBulkDate: 1525075968000,
+    isRetryEnabled: false
+  };
 
   beforeEach(() => {
     cy.clearSessionStorage();
@@ -107,8 +63,13 @@ describe('Template', () => {
       }).as('initFlags');
     });
 
-    cy.route(Cypress.config('baseUrl') + "/instantiationTemplates**", instantiationTemplates);
-    cy.route(Cypress.config('baseUrl') + "/getuserID", '16807000');
+    cy.readFile('fixture:../../../vid-automation/src/test/resources/asyncInstantiation/vidRequestCreateBulkOfMacro__template_info.json').then((templateInfoFromE2EFile)=>{
+      cy.route(Cypress.config('baseUrl') + "/instantiationTemplates?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd",
+        [ templateInfoFromE2EFile, aSecondTemplateInfo ]
+      )
+    });
+
+    cy.route(Cypress.config('baseUrl') + "/getuserID", 'us16807000');
 
     cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true');
 
@@ -124,8 +85,7 @@ describe('Template', () => {
       .getElementByDataTestsId('template-modal-title').contains('Templates') // Check Modal header
       .getElementByDataTestsId('description-part-1').contains('The following list presents previous instantiations done for this model in this version.')
       .getElementByDataTestsId('description-part-2').contains('You may use one of them as a baseline for your instantiation or start from scratch.')
-      .getElementByDataTestsId('description-part-3').contains('Once you selecting one allows you to change the data before start instantiating.')
-
+      .getElementByDataTestsId('description-part-3').contains('Once you selecting one allows you to change the data before start instantiating.');
 
     //check table headers
     cy.get(`#header-userId`).contains('User ID');
@@ -137,19 +97,19 @@ describe('Template', () => {
     cy.get(`#header-aicZone`).contains('AIC Zone');
 
     // check table body row
-    cy.getElementByDataTestsId(`userId-${instantiationTemplates[0].jobId}`).contains('16807000');
-    cy.getElementByDataTestsId(`createDate-${instantiationTemplates[0].jobId}`).contains('2018-04-30 11:12:48');
-    cy.getElementByDataTestsId(`instanceName-${instantiationTemplates[0].jobId}`).contains('nWUfl instance name_002');
-    cy.getElementByDataTestsId(`instantiationStatus-${instantiationTemplates[0].jobId}`).contains('FAILED');
-    cy.getElementByDataTestsId(`summary-${instantiationTemplates[0].jobId}`).contains('vnf: 1, vfModule: 2, volumeGroup: 1');
-    cy.getElementByDataTestsId(`region-${instantiationTemplates[0].jobId}`).contains('hvf6 (WAYNEHOLLAND)');
-    cy.getElementByDataTestsId(`tenant-${instantiationTemplates[0].jobId}`).contains('AIN Web Tool-15-D-testalexandria');
-    cy.getElementByDataTestsId(`aicZone-${instantiationTemplates[0].jobId}`).contains('NFTJSSSS-NFT1');
+    cy.getElementByDataTestsId(`userId-${templateJobIdFromE2EFile}`).contains('16807000');
+    cy.getElementByDataTestsId(`createDate-${templateJobIdFromE2EFile}`).contains('2019-12-26 11:57:05');
+    cy.getElementByDataTestsId(`instanceName-${templateJobIdFromE2EFile}`).contains('SERVICE_NAME');
+    cy.getElementByDataTestsId(`instantiationStatus-${templateJobIdFromE2EFile}`).contains('IN_PROGRESS');
+    cy.getElementByDataTestsId(`summary-${templateJobIdFromE2EFile}`).contains('vnf: 1, vfModule: 2, volumeGroup: 1');
+    cy.getElementByDataTestsId(`region-${templateJobIdFromE2EFile}`).contains('hvf3 (SOMENAME)');
+    cy.getElementByDataTestsId(`tenant-${templateJobIdFromE2EFile}`).contains('greatTenant');
+    cy.getElementByDataTestsId(`aicZone-${templateJobIdFromE2EFile}`).contains('NFTJSSSS-NFT1');
 
 
     //check load button is disabled
     cy.getElementByDataTestsId('LoadTemplateButton').should('be.disabled');
-    cy.getElementByDataTestsId('row-5c2cd8e5-27d0-42e3-85a1-85db5eaba459').click();
+    cy.getElementByDataTestsId(`row-${templateJobIdFromE2EFile}`).click();
     cy.getElementByDataTestsId('LoadTemplateButton').should('not.be.disabled');
 
     //filter by userId
@@ -164,18 +124,16 @@ describe('Template', () => {
     cy.getElementByDataTestsId('templateButton').contains('Template')
     .getElementByDataTestsId('templateButton').click({force: true}) // Open template Modal
 
-    const serviceModelId = 'e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0';
-    const jobId = '5c2cd8e5-27d0-42e3-85a1-85db5eaba459';
+    const serviceModelId = '5c9e863f-2716-467b-8799-4a67f378dcaa';
     const vidBaseUrl = `http://localhost:8080/vid/serviceModels.htm`;
 
-    cy.getElementByDataTestsId('row-5c2cd8e5-27d0-42e3-85a1-85db5eaba459').click();
+    cy.getElementByDataTestsId(`row-${templateJobIdFromE2EFile}`).click();
     cy.getElementByDataTestsId('LoadTemplateButton').click().setViewportToDefault();
 
     cy.location().should((loc) => {
-      expect(loc.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/RECREATE?serviceModelId=${serviceModelId}&jobId=${jobId}`);
+      expect(loc.toString()).to.eq(`${vidBaseUrl}#/servicePlanning/RECREATE?serviceModelId=${serviceModelId}&jobId=${templateJobIdFromE2EFile}`);
     });
   });
 
-
 });
 
index 3cd633d..eb60865 100644 (file)
@@ -70,11 +70,7 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole
   }
 
   closeDialog(that): void {
-    this._iframeService.removeClassCloseModal(that.parentElementClassName);
-    this.dialogService.removeDialog(this);
-    setTimeout(() => {
-      window.parent.postMessage("closeIframe", "*");
-    }, 15);
+    this._iframeService.closeIframe(this.dialogService, this);
   }
 
   shouldShowNotification(): boolean {
index 211f593..47f8490 100644 (file)
@@ -60,11 +60,7 @@ export class SearchElementsModalComponent extends DialogComponent<{ modalInforma
 
   closeDialog(): void {
     this._iframeService.removeFullScreen();
-    this._iframeService.removeClassCloseModal(this.parentElementClassName);
-    this.dialogService.removeDialog(this);
-    setTimeout(() => {
-      window.parent.postMessage("closeIframe", "*");
-    }, 15);
+    this._iframeService.closeIframe(this.dialogService, this);
   }
 
   selectedMembersAmountChange(selectedMembersAmount: number): void {
diff --git a/vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts b/vid-webpack-master/src/app/shared/utils/iframe.service.spec.ts
new file mode 100644 (file)
index 0000000..fd5fe0e
--- /dev/null
@@ -0,0 +1,40 @@
+import {getTestBed, TestBed} from "@angular/core/testing";
+import {IframeService} from "./iframe.service";
+import {DialogService} from "ng2-bootstrap-modal";
+
+export class DialogServiceMock extends DialogService {
+  removeDialog: (that) => ({})
+}
+
+describe('Iframe service', () => {
+  let injector;
+  let service: IframeService;
+  beforeAll(done => (async () => {
+    TestBed.configureTestingModule({
+      providers : [
+        IframeService
+      ]
+    });
+    await TestBed.compileComponents();
+
+    injector = getTestBed();
+    service = injector.get(IframeService);
+
+  })().then(done).catch(done.fail));
+
+
+  test('service should be defined', ()=>{
+    expect(service).toBeDefined();
+  });
+
+  test('closeIframe: should call removeClassCloseModal', ()=>{
+    const dialogService = new DialogServiceMock(null, null, null, null);
+    spyOn(service, 'removeClassCloseModal');
+    spyOn(dialogService, 'removeDialog');
+    service.closeIframe(dialogService, {})
+
+    expect(service.removeClassCloseModal).toBeCalledWith('content');
+    expect(dialogService.removeDialog).toBeCalledWith({});
+  });
+
+});
index 4c69982..ab93d1a 100644 (file)
@@ -1,22 +1,31 @@
 import {Injectable} from "@angular/core";
+import {DialogService} from "ng2-bootstrap-modal";
 
 @Injectable()
 export class IframeService {
 
   addClassOpenModal(elementClassName: string) {
-    var parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0];
+    const parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0];
     if (parentBodyElement)  {
       parentBodyElement.classList.add("modal-open");
     }
   }
 
   removeClassCloseModal(elementClassName: string) {
-    var parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0];
+    const parentBodyElement = parent.document.getElementsByClassName(elementClassName)[0];
     if (parentBodyElement)  {
       parentBodyElement.classList.remove("modal-open");
     }
   }
 
+  closeIframe(dialogService : DialogService, that){
+    this.removeClassCloseModal('content');
+    dialogService.removeDialog(that);
+    setTimeout(() => {
+      window.parent.postMessage("closeIframe", "*");
+    }, 15);
+  }
+
 
   addFullScreen(){
     let parentBodyElement =  parent.document.getElementsByClassName('service-model-content')[0];