Add drop down Source subscriber name on the PMC instantiation form 59/106259/9
authorAlexey Sandler <alexey.sandler@intl.att.com>
Mon, 20 Apr 2020 09:57:09 +0000 (12:57 +0300)
committerIttay Stern <ittay.stern@att.com>
Wed, 22 Apr 2020 09:56:28 +0000 (12:56 +0300)
Add the "Source Subscriber Name" drop down for the source VNF on the PMC (Port Mirroring Configuration) instantiation form.

Issue-ID: VID-809

Change-Id: Iab01675e815bbc9809c67e31e475613973d868ea
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Signed-off-by: Alexey Sandler <alexey.sandler@intl.att.com>
Signed-off-by: Amichai Hemli <amichai.hemli@intl.att.com>
Signed-off-by: Ittay Stern <ittay.stern@att.com>
vid-app-common/src/main/webapp/app/vid/scripts/controller/ServiceProxyConfigController.js
vid-app-common/src/main/webapp/app/vid/scripts/view-models/serviceProxyConfig.htm
vid-automation/src/main/java/vid/automation/test/Constants.java
vid-automation/src/main/java/vid/automation/test/sections/ServiceProxyPage.java
vid-automation/src/main/java/vid/automation/test/test/CreatePortMirroringConfigurationTest.java

index 8e3b5b8..c85187e 100644 (file)
@@ -60,25 +60,58 @@ appDS2.controller(
 
         $scope.serviceTypes = [];
 
-        function init() {
-            loadServiceTypes();
+        $scope.isSourceSubscriberEnabled = function() {
+            return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_2006_PORT_MIRRORING_LET_SELECTING_SOURCE_SUBSCRIBER)
+                && !$scope.configurationByPolicy;
+        };
 
+        function init() {
+            if ($scope.isSourceSubscriberEnabled())  {
+                loadSourceSubscriber();
+            }
+            loadServiceTypes(DataService.getGlobalCustomerId(), handleGetSourceAndCollectorServiceTypesResponse);
             generateMetadata(sourceServiceProxy);
             generateMetadata(collectorServiceProxy);
 
         }
 
+        function loadSourceSubscriber() {
+            AaiService.getSubList(function (response) {
+                $scope.sourceSubscribers = response;
+                $scope.sourceSubscriber = response.find((subscriber)=>{
+                    return subscriber.globalCustomerId === DataService.getGlobalCustomerId();
+                });
+            }, function (response) { // failure
+                $scope.sourceSubscribers = [];
+            });
+        }
+
+        function getSourceSubscriberId() {
+            return $scope.isSourceSubscriberEnabled()
+                ? $scope.sourceSubscriber && $scope.sourceSubscriber.globalCustomerId
+                : DataService.getGlobalCustomerId()
+        }
+
         function setDefaultCollectorServiceType() {
             const configServiceType = DataService.getServiceType();
             $scope.collectorServiceType = mustFind($scope.serviceTypes, {"service-type": configServiceType});
             loadCollectorProxies();
         }
 
-        function handleGetServiceTypesResponse(response) {
+        function handleGetSourceAndCollectorServiceTypesResponse(response) {
+            handleGetSourceServiceTypesResponse(response)
+            handleGetCollectorServiceTypesResponse(response)
+        }
+
+        function handleGetCollectorServiceTypesResponse(response) {
             $scope.serviceTypes = response.data;
             setDefaultCollectorServiceType();
         }
 
+        function handleGetSourceServiceTypesResponse(response) {
+            $scope.sourceServiceTypes = response.data;
+        }
+
         var handleGetParametersResponse = function(parameters) {
             $scope.serviceMetadataFields = parameters.summaryList;
             $scope.nodeTemplateFields =  DataService.getPortMirroningConfigFields();
@@ -97,11 +130,14 @@ appDS2.controller(
             $window.history.back();
         };
 
+        $scope.onSourceSubscriberChange = function(selectedSubscriber) {
+            $scope.sourceSubscriber = selectedSubscriber
+            loadServiceTypes(selectedSubscriber.globalCustomerId, handleGetSourceServiceTypesResponse)
+        }
 
-        function loadServiceTypes() {
-            const subscriberId = DataService.getGlobalCustomerId();
+        function loadServiceTypes(subscriberId, handleGetServiceTypesResponseCallback) {
             AaiService.getSubscriberServiceTypes(subscriberId)
-                .then(handleGetServiceTypesResponse)
+                .then(handleGetServiceTypesResponseCallback)
                 .catch(function (error) {
                     $log.error(error);
                 });
@@ -288,7 +324,7 @@ appDS2.controller(
             if (service.name === 'collectorInstanceName' && $scope.configurationByPolicy) {
                 var configurationModel = DataService.getModelInfo(COMPONENT.VNF);
                 AaiService.getPnfInstancesList(
-                    DataService.getGlobalCustomerId(),
+                    getSourceSubscriberId(),
                     serviceType,
                     serviceProxy.sourceModelUuid,
                     serviceProxy.sourceModelInvariant,
@@ -307,7 +343,7 @@ appDS2.controller(
                     });
             } else {
                 AaiService.getVnfInstancesList(
-                    DataService.getGlobalCustomerId(),
+                    getSourceSubscriberId(),
                     serviceType,
                     serviceProxy.sourceModelUuid,
                     serviceProxy.sourceModelInvariant,
index 42732bb..99d8305 100644 (file)
@@ -64,10 +64,18 @@ limitations under the License.
             </div>
             <form name="proxiesInstanceName" class="bottom">
                 <div class="wrapper-list source-vnf">
-                    <div class="title-txt"><b>Source</b> Service Type</div>
+                    <div class="title-txt" ng-if="isSourceSubscriberEnabled()"><b>Source</b> Subscriber name </div>
+                    <select ng-model="sourceSubscriber"
+                            ng-change="onSourceSubscriberChange(sourceSubscriber)" name="sourceSubscriber" id="sourceSubscriber"
+                            ng-options="item['subscriberName'] disable when !(item['isPermitted']) for item in sourceSubscribers"
+                            ng-if="isSourceSubscriberEnabled()"
+                            required data-tests-id="sourceSubscriberName">
+                    </select>
+
+                    <div class="title-txt" ng-class="{'select-vnf-title': isSourceSubscriberEnabled()}"><b>Source</b> Service Type</div>
                     <select ng-model="sourceServiceType"
                             ng-change="onSourceServiceTypeSelected()" name="sourceServiceType" id="sourceServiceType"
-                            ng-options="item['service-type'] disable when !(item['is-permitted']) for item in serviceTypes"
+                            ng-options="item['service-type'] disable when !(item['is-permitted']) for item in sourceServiceTypes"
                             required data-tests-id="sourceServiceType">
                         <option value="" disabled>Select service type</option>
                     </select>
index e639ee0..1130107 100644 (file)
@@ -450,6 +450,7 @@ public class Constants {
         public static final String SOURCE_DROPDOWN_TEST_ID = "sourceDropDown";
         public static final String COLLECTOR_DROPDOWN_TEST_ID = "collectorDropDown";
         public static final String COLLECTOR_INSTANCE_NAME_TEST_ID = "collectorInstanceName";
+        public static final String SOURCE_SUBSCRIBER_NAME = "sourceSubscriberName";
         public static final String SOURCE_INSTANCE_NAME_TEST_ID = "sourceInstanceName";
         public static final String MODEL_NAME_TEST_ID = "modelName";
         public static final String COLLECTOR_NO_RESULT_MSG_TEST_ID = "collectorNoResults";
index b96a7d3..e3b924a 100644 (file)
@@ -4,6 +4,7 @@ import org.junit.Assert;
 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
 import org.openqa.selenium.WebElement;
 import vid.automation.test.Constants;
+import vid.automation.test.Constants.ConfigurationCreation;
 import vid.automation.test.Constants.ViewEdit;
 import vid.automation.test.infra.SelectOption;
 
@@ -15,6 +16,13 @@ public class ServiceProxyPage extends VidBasePage {
         SelectOption.byTestIdAndVisibleText(source, Constants.ConfigurationCreation.SOURCE_DROPDOWN_TEST_ID);
         return this;
     }
+
+    public ServiceProxyPage chooseSourceSubscriberName(String subscriberName){
+        SelectOption.byTestIdAndVisibleText(subscriberName, "sourceSubscriberName");
+        GeneralUIUtils.ultimateWait();
+      return this;
+    };
+
     public ServiceProxyPage chooseSourceServiceType(String sourceServiceType){
         SelectOption.byTestIdAndVisibleText(sourceServiceType, "sourceServiceType");
         GeneralUIUtils.ultimateWait();
@@ -25,6 +33,12 @@ public class ServiceProxyPage extends VidBasePage {
         GeneralUIUtils.ultimateWait();
         return this;
     }
+
+    public void assertSourceSubscriberName(String sourceSubscriberName){
+        String displayedSubscriberName = SelectOption.getSelectedOption(ConfigurationCreation.SOURCE_SUBSCRIBER_NAME);
+        Assert.assertEquals("The displayed source subscriber name is not correct", sourceSubscriberName, displayedSubscriberName);
+    }
+
     public void assertCollectorServiceType(String collectorServiceType) {
         String displayedCollectorServiceType = SelectOption.getSelectedOption("collectorServiceType");
         Assert.assertEquals("The displayed collector service type is incorrect", collectorServiceType, displayedCollectorServiceType);
index eac0951..a3699e3 100644 (file)
@@ -1,6 +1,8 @@
 package vid.automation.test.test;
 
 import com.google.common.collect.ImmutableMap;
+import java.util.HashMap;
+import java.util.Map;
 import org.junit.Assert;
 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
 import org.openqa.selenium.WebElement;
@@ -17,9 +19,6 @@ import vid.automation.test.sections.ViewEditPage;
 import vid.automation.test.services.BulkRegistration;
 import vid.automation.test.services.SimulatorApi;
 
-import java.util.HashMap;
-import java.util.Map;
-
 public class CreatePortMirroringConfigurationTest extends VidBaseTestCase {
 
     private ViewEditPage viewEditPage = new ViewEditPage();
@@ -32,6 +31,7 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase {
     private String pnfInstanceName = "AS-pnf2-10219--as988q";
     private String pnfServiceType = "DARREN MCGEE";
     private String vnfServiceType = "TYLER SILVIA";
+    private String sourceSubscriberName = "SILVIA ROBBINS";
     private String defaultCollectorServiceType = "TYLER SILVIA";
     private String vnfInstanceName = "zhvf6aepdg01";
     private String active = "Active";
@@ -42,6 +42,10 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase {
         return Features.FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY.isActive();
     }
 
+    private boolean featureFlagLetSelectingSourceSubscriber() {
+        return Features.FLAG_2006_PORT_MIRRORING_LET_SELECTING_SOURCE_SUBSCRIBER.isActive();
+    }
+
     private String expectedPnfCollectorServiceType() {
         return (featureFlagLetsSelectingCollector() ? pnfServiceType : defaultCollectorServiceType).replace(" ", "%20");
     }
@@ -234,6 +238,10 @@ public class CreatePortMirroringConfigurationTest extends VidBaseTestCase {
 
         //select source & collector
         serviceProxyPage.assertCollectorServiceType(defaultCollectorServiceType);
+        if(featureFlagLetSelectingSourceSubscriber()){
+            serviceProxyPage.assertSourceSubscriberName(sourceSubscriberName);
+            serviceProxyPage.chooseSourceSubscriberName(sourceSubscriberName);
+        }
         serviceProxyPage.chooseCollectorServiceType(vnfServiceType);
         serviceProxyPage.chooseCollector(vnfInstanceName);
         serviceProxyPage.assertSelectedInstanceIcon(Constants.ConfigurationCreation.COLLECTOR_INSTANCE_SELECTED_ICON_TEST_ID);