Integration Tests - Add inputs to a base service 98/121598/2
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>
Wed, 21 Apr 2021 15:18:12 +0000 (16:18 +0100)
committerChristophe Closset <christophe.closset@intl.att.com>
Tue, 8 Jun 2021 06:57:14 +0000 (06:57 +0000)
Issue-ID: SDC-3609
Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech>
Change-Id: Iaf281999d29317e5c8caff2f2da765551571dc0f

catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html
integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ServiceTemplateDesignUiTests.java
integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentInputTab.java
integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentPage.java
integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourcePropertiesAssignmentTab.java
integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml

index 46e4d47..8847e96 100644 (file)
@@ -79,7 +79,7 @@
                         *ngIf="isPropertiesTabSelected && !isSelf()"
                         [disabled]="checkedPropertiesCount != 1 || isReadonly || hasChangedData"
                         class="tlv-btn blue declare-button"
-                        data-tests-id="declare-button declare-input">{{btnSelectInputText}}</button>
+                        data-tests-id="declare-button select-input">{{btnSelectInputText}}</button>
                 <button class="tlv-btn blue declare-button" [disabled]="!checkedPropertiesCount || isReadonly || hasChangedData" (click)="declareProperties()" data-tests-id="declare-button declare-input">Declare Input</button>
                 <button class="tlv-btn blue declare-button" [disabled]="!checkedPropertiesCount || isReadonly || hasChangedData || isSelf()" (click)="declarePropertiesToPolicies()" data-tests-id="declare-button declare-policy">Declare Policy</button>
                 <button class="tlv-btn blue declare-button" [disabled]="!checkedPropertiesCount || checkedChildPropertiesCount || isReadonly || hasChangedData" (click)="declareListProperties()" data-tests-id="declare-but($event)ton declare-list-input">Create List Input</button>
index 2fcd29f..2a803ea 100644 (file)
@@ -64,8 +64,8 @@ import org.onap.sdc.frontend.ci.tests.flow.CreateDirectiveNodeFilterFlow;
 import org.onap.sdc.frontend.ci.tests.flow.CreateSubstitutionFilterFlow;
 import org.onap.sdc.frontend.ci.tests.flow.CreateVfFlow;
 import org.onap.sdc.frontend.ci.tests.flow.CreateVfcFlow;
-import org.onap.sdc.frontend.ci.tests.flow.DownloadCsarArtifactFlow;
 import org.onap.sdc.frontend.ci.tests.flow.DownloadToscaTemplateFlow;
+import org.onap.sdc.frontend.ci.tests.flow.DownloadCsarArtifactFlow;
 import org.onap.sdc.frontend.ci.tests.flow.EditComponentPropertiesFlow;
 import org.onap.sdc.frontend.ci.tests.flow.composition.CreateRelationshipFlow;
 import org.onap.sdc.frontend.ci.tests.flow.exception.UiTestFlowRuntimeException;
@@ -308,6 +308,19 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
         verifyToscaTemplateHasDirectiveNodeFilter(yaml, serviceDependencyProperty, vfcNameInComposition);
     }
 
+    @Test(dependsOnMethods = "addComponentProperty")
+    public void declareInputFromProperties() throws Exception {
+        componentPage = (ComponentPage) homePage.clickOnComponent(vfResourceCreateData.getName());
+        componentPage.isLoaded();
+
+        ResourcePropertiesAssignmentPage propertiesAssignmentPage = componentPage.goToPropertiesAssignment();
+        propertiesAssignmentPage.isLoaded();
+
+        declareInputToBaseService(propertiesAssignmentPage, "property1");
+        declareInputToInstanceProperties(propertiesAssignmentPage, "resourceSubtype");
+        verifyToscaTemplateHasDeclareInput(downloadToscaTemplate());
+    }
+
     private void checkMetadata(final Map<String, Object> map, final ResourceCreateData createdData) {
         final Map<String, Object> metadata = getMapEntry(map, "metadata");
 
@@ -453,6 +466,23 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
         return loadYamlObject(filesFromZip.get(resourceEntryOpt.get()));
     }
 
+    private void declareInputToBaseService(ResourcePropertiesAssignmentPage propertiesAssignmentPage, String propertyName){
+        propertiesAssignmentPage.selectProperty(propertyName);
+        propertiesAssignmentPage.clickOnDeclareInput();
+        propertiesAssignmentPage.clickInputTab(propertyName);
+        propertiesAssignmentPage.isInputPresent(vfResourceCreateData.getName() + "_" + propertyName);
+    }
+
+    private void declareInputToInstanceProperties(ResourcePropertiesAssignmentPage propertiesAssignmentPage, String propertyName){
+        propertiesAssignmentPage.selectPropertiesTab();
+        propertiesAssignmentPage.loadCompositionTab();
+        propertiesAssignmentPage.loadComponentInstanceProperties(vfcs.get(0).getName().concat(" 0"));
+        propertiesAssignmentPage.selectProperty(propertyName);
+        propertiesAssignmentPage.clickOnDeclareInput();
+        propertiesAssignmentPage.clickInputTab(propertyName);
+        propertiesAssignmentPage.isInputPresent(vfResourceCreateData.getName() + "_" + vfcs.get(0).getName());
+    }
+
     private CreateVfFlow createVF() {
         final ResourceCreateData vfCreateData = createVfFormData();
         final CreateVfFlow createVfFlow = new CreateVfFlow(webDriver, vfCreateData);
@@ -740,6 +770,26 @@ public class ServiceTemplateDesignUiTests extends SetupCDTest {
         return expectedDefinitionFolderFileList;
     }
 
+    private void verifyToscaTemplateHasDeclareInput(Map<?, ?> yaml) {
+        assertNotNull(yaml, "No contents in TOSCA Template");
+        final Map<String, Object> toscaYaml = (Map<String, Object>) yaml;
+        final Map<String, Object> topologyTemplateTosca = getMapEntry(toscaYaml, "topology_template");
+        assertThat(String.format("'%s' should contain a topology_template entry", toscaYaml), topologyTemplateTosca,
+            notNullValue());
+        final Map<String, Object> inputsTosca = getMapEntry(topologyTemplateTosca, "inputs");
+        assertThat(String.format("'%s' should contain a inputs entry", toscaYaml), inputsTosca, notNullValue());
+        assertEquals(2, inputsTosca.keySet().stream()
+            .filter(s -> (s.contains("resourceSubtype") || s.contains("property1"))).count());
+        final Map<String, Object> substitutionMapping = getMapEntry(topologyTemplateTosca, "substitution_mappings");
+        assertThat(String.format("'%s' should contain a substitution_mappings entry", toscaYaml), substitutionMapping,
+            notNullValue());
+        final Map<String, Object> substitutionMappingProperties = getMapEntry(substitutionMapping, "properties");
+        assertThat(String.format("'%s' should contain a properties entry", toscaYaml), substitutionMappingProperties,
+            notNullValue());
+        assertEquals(2, substitutionMappingProperties.keySet().stream()
+            .filter(s -> (s.contains("resourceSubtype") || s.contains("property1"))).count());
+    }
+
     private Map<String, Object> getMapEntry(final Map<?, ?> yamlObj, final String entryName) {
         try {
             return (Map<String, Object>) yamlObj.get(entryName);
index dedb084..d1b07dc 100644 (file)
@@ -84,6 +84,21 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
         waitForElementInvisibility(By.xpath(XpathSelector.PROPERTY_SAVE_MESSAGE.getXpath()));
     }
 
+    /**
+     * Checks if a input exists.
+     * @param inputName the property name
+     * @return the value of the input
+     */
+    public boolean isInputPresent(final String inputName) {
+        isInputPropertiesTableLoaded();
+        try {
+            waitForElementVisibility(By.xpath(XpathSelector.INPUT_CHECKBOX.formatXpath(inputName)), 5);
+        } catch (final Exception ignored) {
+            return false;
+        }
+        return true;
+    }
+
     /**
      * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
      */
@@ -92,6 +107,7 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
     private enum XpathSelector {
         INPUT_TAB("//*[contains(@data-tests-id, 'Inputs') and contains(@class, 'active')]"),
         PROPERTIES_TABLE("//div[contains(@class,'properties-table')]"),
+        INPUT_CHECKBOX("//checkbox[@data-tests-id='%s']"),
         NO_DATA_MESSAGE("//div[contains(@class,'no-data') and text()='No data to display']"),
         PROPERTY_SAVE_BTN("//button[@data-tests-id='properties-save-button']"),
         PROPERTY_SAVE_MESSAGE("//div[contains(text(), 'Successfully saved')]"),
@@ -100,6 +116,7 @@ public class ResourcePropertiesAssignmentInputTab extends AbstractPageObject {
         INPUT_PROPERTY_ADD_METADATA_BUTTON(INPUT_PROPERTY_TABLE_ROW.getXpath().concat("//a")),
         INPUT_PROPERTY_METADATA_KEY_VALUE_PAIR(INPUT_PROPERTY_TABLE_ROW.getXpath().concat("//input"));
 
+        @Getter
         private final String xpath;
 
         public String formatXpath(Object... params) {
index e69f113..4db048b 100644 (file)
 
 package org.onap.sdc.frontend.ci.tests.pages;
 
+import com.aventstack.extentreports.Status;
 import java.util.List;
 import java.util.Map;
 
+import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
 import org.openqa.selenium.By;
 import org.openqa.selenium.WebDriver;
 
@@ -77,6 +79,13 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject {
         return resourcePropertiesAssignmentTab.isPropertyPresent(propertyName);
     }
 
+    public boolean isInputPresent(final String inputName) {
+        return resourcePropertiesAssignmentInputTab.isInputPresent(inputName);
+    }
+
+    /**
+     * Saves a property
+     */
     public void saveProperties() {
         resourcePropertiesAssignmentTab.saveProperties();
     }
@@ -97,6 +106,31 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject {
         return resourcePropertiesAssignmentInputTab.getInputPropertyNames();
     }
 
+    /**
+     * select property
+     */
+    public void selectProperty(String propertyName){
+        resourcePropertiesAssignmentTab.selectProperty(propertyName);
+    }
+
+    public void loadComponentInstanceProperties(final String instanceName){
+        resourcePropertiesAssignmentTab.loadComponentInstanceProperties(instanceName);
+    }
+
+    public void clickOnDeclareInput(){
+        resourcePropertiesAssignmentTab.clickOnDeclareInput();
+    }
+
+    public void loadCompositionTab(){
+        resourcePropertiesAssignmentTab.loadCompositionTab();
+    }
+
+    public void clickInputTab(String propertyName){
+        waitForElementVisibility(By.xpath(XpathSelector.DECLARE_NOTIFIFICATION.getXpath()));
+        ExtentTestActions.takeScreenshot(Status.INFO, "Declare-Input", String.format("Added declared input for property %s", propertyName));
+        selectInputTab();
+    }
+
     /**
      * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
      */
@@ -105,7 +139,8 @@ public class ResourcePropertiesAssignmentPage extends AbstractPageObject {
         MAIN_DIV("w-sdc-main-right-container", "//div[@class='%s']"),
         TITLE_DIV("tab-title", "//div[contains(@class,'%s') and contains(text(), 'Properties Assignment')]"),
         PROPERTIES_TAB("//*[contains(@data-tests-id, 'Properties') and contains(@class, 'tab')]"),
-        INPUT_TAB("//*[contains(@data-tests-id, 'Inputs') and contains(@class, 'tab')]");
+        INPUT_TAB("//*[contains(@data-tests-id, 'Inputs') and contains(@class, 'tab')]"),
+        DECLARE_NOTIFIFICATION("//div[@data-tests-id='Inputs']/div[contains(@class, 'tab-indication')]");
 
         @Getter
         private String id;
index b237b17..32a20dd 100644 (file)
@@ -308,6 +308,26 @@ public class ResourcePropertiesAssignmentTab extends AbstractPageObject {
             String.format("%s Property should be listed but found %s", propertyName, this.getPropertyNamesAndTypes().toString()));
     }
 
+    /**
+     * select property
+     */
+    public void selectProperty(String propertyName){
+        isPropertyPresent(propertyName);
+        waitToBeClickable(By.xpath(ResourcePropertiesAssignmentTab.XpathSelector.PROPERTY_CHECKBOX.getXpath(propertyName))).click();
+    }
+
+    public void loadComponentInstanceProperties(final String instanceName){
+        waitToBeClickable(By.xpath(ResourcePropertiesAssignmentTab.XpathSelector.INSTANCE_SPAN.getXpath(instanceName))).click();
+    }
+
+    public void clickOnDeclareInput(){
+        waitToBeClickable(By.xpath(ResourcePropertiesAssignmentTab.XpathSelector.DECLARE_INPUT_BTN.getXpath())).click();
+    }
+
+    public void loadCompositionTab(){
+        waitToBeClickable(By.xpath(ResourcePropertiesAssignmentTab.XpathSelector.COMPOSITION_TAB.getXpath())).click();
+    }
+
     /**
      * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
      */
@@ -329,7 +349,10 @@ public class ResourcePropertiesAssignmentTab extends AbstractPageObject {
         INPUT_PROPERTY("//input[@data-tests-id='value-prop-%s']"),
         SELECT_INPUT_PROPERTY("//select[@data-tests-id='value-prop-%s']"),
         PROPERTY_TYPES("//*[contains(@data-tests-id, 'propertyType')]"),
-        PROPERTY_NAMES("//*[contains(@data-tests-id, 'propertyName')]");
+        PROPERTY_NAMES("//*[contains(@data-tests-id, 'propertyName')]"),
+        DECLARE_INPUT_BTN("declare-button declare-input", "//button[@data-tests-id='%s']"),
+        COMPOSITION_TAB("Composition", "//div[contains(@class,'tab') and contains(text(), '%s')]"),
+        INSTANCE_SPAN("//span[@data-tests-id='%s']");
 
         @Getter
         private String id;
index ce2436e..73e369b 100644 (file)
@@ -41,6 +41,7 @@
           <include name="addRelationshipTemplate"/>
           <include name="addComponentProperty"/>
           <include name="addOutputsToVF_test"/>
+          <include name="declareInputFromProperties"/>
           <include name="createSubstitutionFilter"/>
           <include name="createDirectiveNodeFilterTest"/>
           <include name="updateInterfaceOperation"/>