package org.onap.sdc.frontend.ci.tests.execute.sanity;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.anEmptyMap;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
+import com.aventstack.extentreports.Status;
import java.util.Arrays;
import java.util.Map;
import java.util.Optional;
+import org.apache.commons.collections.MapUtils;
import org.onap.sdc.backend.ci.tests.datatypes.enums.ComponentType;
import org.onap.sdc.backend.ci.tests.datatypes.enums.ResourceCategoryEnum;
import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory;
import org.onap.sdc.frontend.ci.tests.datatypes.ComponentData;
+import org.onap.sdc.frontend.ci.tests.datatypes.ModelName;
import org.onap.sdc.frontend.ci.tests.datatypes.ResourceCreateData;
import org.onap.sdc.frontend.ci.tests.exception.UnzipException;
import org.onap.sdc.frontend.ci.tests.execute.setup.DriverFactory;
+import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions;
import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest;
import org.onap.sdc.frontend.ci.tests.flow.AddNodeToCompositionFlow;
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.InterfaceDefinitionFlow;
import org.onap.sdc.frontend.ci.tests.flow.exception.UiTestFlowRuntimeException;
+import org.onap.sdc.frontend.ci.tests.pages.AttributeModal;
+import org.onap.sdc.frontend.ci.tests.pages.AttributesPage;
import org.onap.sdc.frontend.ci.tests.pages.ComponentPage;
+import org.onap.sdc.frontend.ci.tests.pages.ResourceCreatePage;
+import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionDetailSideBarComponent;
+import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionDetailSideBarComponent.CompositionDetailTabName;
+import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionInformationTab;
+import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionInterfaceOperationsTab;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage;
+import org.onap.sdc.frontend.ci.tests.pages.component.workspace.InterfaceDefinitionOperationsModal;
+import org.onap.sdc.frontend.ci.tests.pages.component.workspace.InterfaceDefinitionPage;
import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage;
import org.onap.sdc.frontend.ci.tests.pages.home.HomePage;
import org.onap.sdc.frontend.ci.tests.utilities.FileHandling;
+import org.openecomp.sdc.be.model.ComponentInstance;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
private HomePage homePage;
private ResourceCreateData vfcCreateData;
private ResourceCreateData vfCreateData;
+ private ComponentInstance createdComponentInstance;
+ private final String vfcCategory = ResourceCategoryEnum.NETWORK_L4.getSubCategory();
@BeforeClass
public void beforeClass() {
filePath = FileHandling.getFilePath("VFCs/");
+ webDriver = DriverFactory.getDriver();
+ homePage = new HomePage(webDriver);
}
@Test
public void importVFC_createVF_addVFC2VF_test() throws UnzipException {
- webDriver = DriverFactory.getDriver();
- homePage = new HomePage(webDriver);
+ ComponentPage componentPage;
// TC - Import VFC with root namespace
String fileName = "org.openecomp.resource.VFC-root.yml";
- CreateVfcFlow createVfcFlow = createVFC(fileName);
+ CreateVfcFlow createVfcFlow = createVFC(fileName, ModelName.DEFAULT_MODEL_NAME.getName(), vfcCategory);
- ComponentPage componentPage = createVfcFlow.getLandedPage()
- .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return ResourceCreatePage"));
+ componentPage = createVfcFlow.getLandedPage().orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return ResourceCreatePage"));
componentPage.isLoaded();
componentPage.certifyComponent();
componentPage.isLoaded();
// TC - Import hierarchy of VFCs
fileName = "org.openecomp.resource.VFC-child.yml";
- createVfcFlow = createVFC(fileName);
- componentPage = createVfcFlow.getLandedPage().orElseThrow();
+ createVfcFlow = createVFC(fileName, ModelName.DEFAULT_MODEL_NAME.getName(), vfcCategory);
+ componentPage = createVfcFlow.getLandedPage().orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return ResourceCreatePage"));
+ componentPage.isLoaded();
+
+ componentPage = manageAttributes(componentPage);
+ componentPage.isLoaded();
componentPage.certifyComponent();
componentPage.isLoaded();
- yamlObject = downloadToscaArtifact(createVfcFlow.getLandedPage().get());
+ yamlObject = downloadToscaArtifact(componentPage);
checkMetadata(yamlObject, vfcCreateData);
checkNodeTypes(yamlObject);
+
+ componentPage = viewInterfaceDefinitionFromVFC(componentPage);
+ componentPage.isLoaded();
+
homePage.getTopNavComponent().clickOnHome();
// TC - Import VFC with interface inputs
// TC - Import VFC with attributes
final CreateVfFlow createVfFlow = createVF();
- componentPage = createVfFlow.getLandedPage()
- .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return ResourceCreatePage"));
+ componentPage = createVfFlow.getLandedPage().orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return ResourceCreatePage"));
componentPage.isLoaded();
- final AddNodeToCompositionFlow addNodeToCompositionFlow = addNodeToCompositionFlow(componentPage);
-
- final CompositionPage compositionPage = addNodeToCompositionFlow.getLandedPage()
- .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return CompositionPage"));
+ final CompositionPage compositionPage = addInterfaceOperations(componentPage);
componentPage = compositionPage.goToGeneral();
componentPage.isLoaded();
componentPage.certifyComponent();
componentPage.isLoaded();
+
yamlObject = downloadToscaArtifact(componentPage);
checkMetadata(yamlObject, vfCreateData);
checkTopologyTemplate(yamlObject);
}
+ private ComponentPage viewInterfaceDefinitionFromVFC(final ComponentPage componentPage) {
+ final InterfaceDefinitionFlow interfaceDefinitionFlow = new InterfaceDefinitionFlow(webDriver);
+ interfaceDefinitionFlow.run(componentPage);
+ final InterfaceDefinitionPage interfaceDefinitionPage = interfaceDefinitionFlow.getLandedPage()
+ .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return InterfaceDefinitionPage"));
+ final var OPERATION_NAME = "create";
+ assertTrue(interfaceDefinitionPage.isInterfaceDefinitionOperationPresent(OPERATION_NAME));
+ final InterfaceDefinitionOperationsModal interfaceDefinitionOperationsModal = interfaceDefinitionPage.clickOnInterfaceDefinitionOperation(
+ OPERATION_NAME);
+ interfaceDefinitionOperationsModal.isLoaded();
+ ExtentTestActions
+ .takeScreenshot(Status.INFO, "clickOnOInterfaceOperation", "Interface Definition Operation Modal opened");
+ checkInterfaceDefinitionData(interfaceDefinitionOperationsModal);
+ interfaceDefinitionOperationsModal.clickOnCancel();
+ return interfaceDefinitionPage;
+ }
+
+ @Test
+ public void importVfcWithModel() {
+ final String fileName = "VFC-For-Model.yaml";
+ final CreateVfcFlow createVfcFlow = createVFC(fileName, ModelName.ETSI_SOL001_v2_5_1.getName(), vfcCategory);
+ final ComponentPage componentPage = createVfcFlow.getLandedPage()
+ .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return ResourceCreatePage"));
+ componentPage.isLoaded();
+ componentPage.certifyComponent();
+ componentPage.isLoaded();
+ }
+
+ private void checkInterfaceDefinitionData(final InterfaceDefinitionOperationsModal interfaceDefinitionOperationsModal) {
+ assertTrue(interfaceDefinitionOperationsModal.getDescription().isEmpty());
+ assertEquals(interfaceDefinitionOperationsModal.getImplementationName(), "path/to/my/implementation.sh");
+ assertEquals(interfaceDefinitionOperationsModal.getInputName(), "first");
+ assertEquals(interfaceDefinitionOperationsModal.getInputValue(), "1234");
+ }
+
+ private ComponentPage manageAttributes(final ComponentPage componentPage) {
+ final AttributesPage attributesPage = componentPage.goToAttributes();
+ attributesPage.isLoaded();
+
+ assertTrue(attributesPage.isAttributePresent("test_1"));
+ assertTrue(attributesPage.isAttributePresent("test_2"));
+ assertTrue(attributesPage.isAttributePresent("test_3"));
+ assertTrue(attributesPage.isAttributePresent("test_4"));
+
+ attributesPage.deleteAttribute("test_2");
+ assertFalse(attributesPage.isAttributePresent("test_2"));
+ ExtentTestActions.takeScreenshot(Status.INFO, "attributesPage.deleteAttribute", "Attribute 'test_2' successfully deleted");
+ attributesPage.addAttribute(new AttributeModal.AttributeData("test_9", "Additional attribute added from UI", "string", "one More Attribute"));
+ attributesPage.isLoaded();
+ assertTrue(attributesPage.isAttributePresent("test_9"));
+ ExtentTestActions.takeScreenshot(Status.INFO, "attributesPage.addAttribute", "Additional Attribute 'test_9' successfully added");
+
+ attributesPage.editAttribute(new AttributeModal.AttributeData("test_9", "Additional attribute added from UI".toUpperCase(), "string",
+ "one More Attribute".toUpperCase()));
+ attributesPage.isLoaded();
+ assertTrue(attributesPage.isAttributePresent("test_9"));
+ ExtentTestActions.takeScreenshot(Status.INFO, "attributesPage.editAttribute", "Additional Attribute 'test_9' successfully altered");
+
+ return attributesPage.clickOnGeneralMenuItem(ResourceCreatePage.class);
+ }
+
+ private CompositionPage addInterfaceOperations(final ComponentPage componentPage) {
+ final AddNodeToCompositionFlow addNodeToCompositionFlow = addNodeToCompositionFlow(componentPage);
+ final CompositionPage compositionPage = addNodeToCompositionFlow.getLandedPage()
+ .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected return CompositionPage"));
+ final CompositionDetailSideBarComponent detailSideBar = compositionPage.getDetailSideBar();
+ detailSideBar.isLoaded();
+
+ createdComponentInstance = addNodeToCompositionFlow.getCreatedComponentInstance()
+ .orElseThrow(() -> new UiTestFlowRuntimeException("Expecting a ComponentInstance"));
+
+ compositionPage.selectNode(createdComponentInstance.getName());
+
+ CompositionInterfaceOperationsTab compositionInterfaceOperationsTab =
+ (CompositionInterfaceOperationsTab) detailSideBar.selectTab(CompositionDetailTabName.INTERFACE_OPERATIONS);
+ compositionInterfaceOperationsTab.isLoaded();
+ ExtentTestActions.takeScreenshot(Status.INFO, "compositionInterfaceOperationsTab", "Composition Interface Operations Tab opened");
+ assertTrue(compositionInterfaceOperationsTab.isOperationPresent("create"));
+ InterfaceDefinitionOperationsModal compositionInterfaceOperationsModal = compositionInterfaceOperationsTab.clickOnOperation("create");
+ compositionInterfaceOperationsModal.isLoaded();
+ ExtentTestActions
+ .takeScreenshot(Status.INFO, "compositionInterfaceOperationsTab.clickOnOperation", "Composition Interface Operations Modal opened");
+ compositionInterfaceOperationsModal.clickOnDelete();
+ ExtentTestActions.takeScreenshot(Status.INFO, "compositionInterfaceOperationsModal.clickOnDelete", "Input deleted");
+ compositionInterfaceOperationsModal.addInput();
+ ExtentTestActions.takeScreenshot(Status.INFO, "compositionInterfaceOperationsModal.addInput", "Adding Input");
+
+ final InterfaceDefinitionOperationsModal.InterfaceOperationsData interfaceOperationsData = new InterfaceDefinitionOperationsModal.InterfaceOperationsData
+ ("This is CREATE operation", "fullPath/to/my/newImplementation.sh", "second", "9876");
+ compositionInterfaceOperationsModal.updateInterfaceOperation(interfaceOperationsData);
+ compositionInterfaceOperationsTab.isLoaded();
+
+ final CompositionInformationTab compositionInformationTab =
+ (CompositionInformationTab) detailSideBar.selectTab(CompositionDetailTabName.INFORMATION);
+ compositionInformationTab.isLoaded();
+
+ compositionInterfaceOperationsTab =
+ (CompositionInterfaceOperationsTab) detailSideBar.selectTab(CompositionDetailTabName.INTERFACE_OPERATIONS);
+ compositionInterfaceOperationsTab.isLoaded();
+
+ assertTrue(compositionInterfaceOperationsTab.isOperationPresent("create"));
+ assertTrue(compositionInterfaceOperationsTab.isDescriptionPresent());
+ ExtentTestActions.takeScreenshot(Status.INFO, "isDescriptionPresent", "Description is present");
+ compositionInterfaceOperationsModal = compositionInterfaceOperationsTab.clickOnOperation("create");
+ compositionInterfaceOperationsModal.isLoaded();
+ ExtentTestActions
+ .takeScreenshot(Status.INFO, "compositionInterfaceOperationsTab.clickOnOperation", "Composition Interface Operations Modal opened");
+
+ checkCompositionInterfaceOperations(compositionInterfaceOperationsModal, interfaceOperationsData);
+ compositionInterfaceOperationsModal.clickOnCancel();
+ compositionInterfaceOperationsTab.isLoaded();
+ return compositionPage;
+ }
+
private AddNodeToCompositionFlow addNodeToCompositionFlow(final ComponentPage componentPage) {
componentPage.isLoaded();
final ComponentData parentComponent = new ComponentData();
return downloadCsarArtifactFlow;
}
- private CreateVfcFlow createVFC(final String fileName) {
- vfcCreateData = createVfcFormData();
+ private CreateVfcFlow createVFC(final String fileName, final String model, final String category) {
+ vfcCreateData = createVfcFormData(model, category);
final CreateVfcFlow createVfcFlow = new CreateVfcFlow(webDriver, vfcCreateData, filePath + fileName);
createVfcFlow.run(homePage);
return createVfcFlow;
return createVfFlow;
}
- private ResourceCreateData createVfcFormData() {
+ private ResourceCreateData createVfcFormData(final String model, final String category) {
final ResourceCreateData vfcCreateData = new ResourceCreateData();
vfcCreateData.setRandomName(ElementFactory.getResourcePrefix() + "-VFC");
- vfcCreateData.setCategory(ResourceCategoryEnum.NETWORK_L4.getSubCategory());
+ vfcCreateData.setModel(model);
+ vfcCreateData.setCategory(category);
vfcCreateData.setTagList(Arrays.asList(vfcCreateData.getName(), "importVFC"));
vfcCreateData.setDescription("aDescription");
vfcCreateData.setVendorName("Ericsson");
final Map<String, Object> mapEntry = getMapEntry(map, "node_types");
final Map<String, Object> nodeTypes = getMapEntry(mapEntry, mapEntry.keySet().iterator().next());
- assertNotNull(nodeTypes);
+ assertFalse(MapUtils.isEmpty(nodeTypes));
assertEquals("aDescription", nodeTypes.get("description"));
final Map<String, Object> properties = getMapEntry(nodeTypes, "properties");
- assertThat(properties, not(anEmptyMap()));
+ assertFalse(MapUtils.isEmpty(properties));
final Map<String, Object> attributes = getMapEntry(nodeTypes, "attributes");
- assertThat(attributes, not(anEmptyMap()));
+ assertFalse(MapUtils.isEmpty(attributes));
final Map<String, Object> interfaces = getMapEntry(nodeTypes, "interfaces");
- assertThat(interfaces, not(anEmptyMap()));
+ assertFalse(MapUtils.isEmpty(interfaces));
}
private void checkTopologyTemplate(final Map<String, Object> map) {
- final Map<String, Object> mapEntry = getMapEntry(map, "topology_template");
- assertNotNull(mapEntry);
+ final Map<String, Object> topologyTemplate = getMapEntry(map, "topology_template");
+ assertNotNull(topologyTemplate);
+
+ final Map<String, Object> inputs = getMapEntry(topologyTemplate, "inputs");
+ assertFalse(MapUtils.isEmpty(inputs));
- final Map<String, Object> properties = getMapEntry(mapEntry, "inputs");
- assertThat(properties, not(anEmptyMap()));
+ final Map<String, Object> nodeTemplates = getMapEntry(topologyTemplate, "node_templates");
+ assertFalse(MapUtils.isEmpty(nodeTemplates));
- final Map<String, Object> attributes = getMapEntry(mapEntry, "node_templates");
- assertThat(attributes, not(anEmptyMap()));
+ final Map<String, Object> attributes = getMapEntry((Map<String, Object>) nodeTemplates.get(createdComponentInstance.getName()), "attributes");
+ assertFalse(MapUtils.isEmpty(attributes));
+ assertEquals(4, attributes.keySet().stream()
+ .filter(s -> (s.contains("test_1") || s.contains("test_3") || s.contains("test_4") || s.contains("test_9")) && !s.contains("test_2"))
+ .count());
- final Map<String, Object> interfaces = getMapEntry(mapEntry, "substitution_mappings");
- assertThat(interfaces, not(anEmptyMap()));
+ final Map<String, Object> substitutionMappings = getMapEntry(topologyTemplate, "substitution_mappings");
+ assertFalse(MapUtils.isEmpty(substitutionMappings));
+
+ }
+ private void checkCompositionInterfaceOperations(final InterfaceDefinitionOperationsModal compositionInterfaceOperationsModal,
+ final InterfaceDefinitionOperationsModal.InterfaceOperationsData interfaceOperationsData) {
+ assertEquals(interfaceOperationsData.getDescription(), compositionInterfaceOperationsModal.getDescription());
+ assertEquals(interfaceOperationsData.getImplementationName(), compositionInterfaceOperationsModal.getImplementationName());
+ assertEquals(interfaceOperationsData.getInputName(), compositionInterfaceOperationsModal.getInputName());
+ assertEquals(interfaceOperationsData.getInputValue(), compositionInterfaceOperationsModal.getInputValue());
}
}