diff options
author | vasraz <vasyl.razinkov@est.tech> | 2021-03-24 11:27:43 +0000 |
---|---|---|
committer | Christophe Closset <christophe.closset@intl.att.com> | 2021-03-25 07:21:06 +0000 |
commit | 6de0954fbde0a78ea1084248a59cdb7f5c0a18e4 (patch) | |
tree | 24bb801073fd0c49fb8b045d06d39ce85381b632 | |
parent | 908c0f0e5a3d1ae44de93b06d61e54869831415e (diff) |
Implement 'Import VFC' UI test
Change-Id: I1eb9c5f458f3861d21e37e0b5d0e2ef63862e97b
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Issue-ID: SDC-3531
20 files changed, 590 insertions, 81 deletions
diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/DataTestIdEnum.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/DataTestIdEnum.java index 7e8f93637a..506a686ddf 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/DataTestIdEnum.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/DataTestIdEnum.java @@ -20,13 +20,12 @@ package org.onap.sdc.frontend.ci.tests.datatypes; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.onap.sdc.frontend.ci.tests.pages.TopSearchComponent; - import java.util.Arrays; import java.util.Collections; import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.onap.sdc.frontend.ci.tests.pages.TopSearchComponent; public final class DataTestIdEnum { @@ -42,7 +41,7 @@ public final class DataTestIdEnum { BUTTON_ADD_SERVICE("createServiceButton"), IMPORT_VFC("importVFCbutton"), IMPORT_VF("importVFbutton"), - IMPORT_VFC_FILE("file-importVFCbutton"), + IMPORT_VFC_FILE("fileimportVFCbutton"), IMPORT_VF_FILE("file-importVFbutton"), BUTTON_ADD_PRODUCT("createProductButton"), BUTTON_ADD_PNF("createPNFButton"), diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/LifeCycleStateEnum.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/LifeCycleStateEnum.java index 4e8dcee546..3c6c9607d5 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/LifeCycleStateEnum.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/datatypes/LifeCycleStateEnum.java @@ -20,6 +20,11 @@ package org.onap.sdc.frontend.ci.tests.datatypes; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public enum LifeCycleStateEnum { CHECKOUT("IN DESIGN CHECK OUT"), @@ -33,15 +38,6 @@ public enum LifeCycleStateEnum { DISTRIBUTED("DISTRIBUTED"), IN_DESIGN("IN DESIGN"); - private String value; - private String value2; - - public String getValue() { - return value; - } - - LifeCycleStateEnum(String value) { - this.value = value; - } + private final String value; } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiOnboardVnfCnfUiTests.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiOnboardVnfCnfUiTests.java index 55b4f535db..dfe6679102 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiOnboardVnfCnfUiTests.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/EtsiOnboardVnfCnfUiTests.java @@ -135,7 +135,7 @@ public class EtsiOnboardVnfCnfUiTests extends SetupCDTest { webDriver); workspaceTopBarComponent.isLoaded(); final ComponentPage componentPage = Optional - .of(new ComponentPage(webDriver, topNavComponent, resourceLeftSideMenu, workspaceTopBarComponent)) + .of(new ComponentPage(webDriver)) .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected ComponentPage")); componentPage.isLoaded(); return componentPage; diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ImportVfcUiTest.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ImportVfcUiTest.java new file mode 100644 index 0000000000..336a2fb0ed --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ImportVfcUiTest.java @@ -0,0 +1,237 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +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.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + +import java.util.Arrays; +import java.util.Map; +import java.util.Optional; +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.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.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.exception.UiTestFlowRuntimeException; +import org.onap.sdc.frontend.ci.tests.pages.ResourceCreatePage; +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.openqa.selenium.WebDriver; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; +import org.yaml.snakeyaml.Yaml; + +public class ImportVfcUiTest extends SetupCDTest { + + private String filePath; + private WebDriver webDriver; + private HomePage homePage; + private ResourceCreateData vfcCreateData; + private ResourceCreateData vfCreateData; + + @BeforeClass + public void beforeClass() { + filePath = FileHandling.getFilePath("importVfc/"); + } + + @BeforeSuite + public void beforeSuite() { + webDriver = DriverFactory.getDriver(); + homePage = new HomePage(webDriver); + } + + @Test + public void importVFC_createVF_addVFC2VF_test() throws UnzipException { + // TC - Import VFC with root namespace + String fileName = "org.openecomp.resource.VFC-root.yml"; + CreateVfcFlow createVfcFlow = createVFC(fileName); + + createVfcFlow.getLandedPage().get().clickOnCertify(); + + Map<String, Object> yamlObject = downloadToscaArtifact(createVfcFlow.getLandedPage().get()); + checkMetadata(yamlObject, vfcCreateData); + checkNodeTypes(yamlObject); + homePage.getTopNavComponent().clickOnHome(); + + // TC - Import hierarchy of VFCs + fileName = "org.openecomp.resource.VFC-child.yml"; + createVfcFlow = createVFC(fileName); + createVfcFlow.getLandedPage().get().clickOnCertify(); + + yamlObject = downloadToscaArtifact(createVfcFlow.getLandedPage().get()); + checkMetadata(yamlObject, vfcCreateData); + checkNodeTypes(yamlObject); + homePage.getTopNavComponent().clickOnHome(); + + // TC - Import VFC with interface inputs + // TC - Import VFC with attributes + final CreateVfFlow createVfFlow = createVF(); + + final AddNodeToCompositionFlow addNodeToCompositionFlow = addNodeToCompositionFlow(createVfFlow); + + createVfFlow.getLandedPage().get().clickOnCertify(); + yamlObject = downloadToscaArtifact(createVfFlow.getLandedPage().get()); + checkMetadata(yamlObject, vfCreateData); + checkTopologyTemplate(yamlObject); + + } + + private AddNodeToCompositionFlow addNodeToCompositionFlow(final CreateVfFlow createVfFlow) { + final AddNodeToCompositionFlow addNodeToCompositionFlow = new AddNodeToCompositionFlow(webDriver, vfCreateData, vfcCreateData); + addNodeToCompositionFlow.run(createVfFlow.getLandedPage().get()); + return addNodeToCompositionFlow; + } + + private Map<String, Object> downloadToscaArtifact(final ResourceCreatePage resourceCreatePage) throws UnzipException { + final DownloadCsarArtifactFlow downloadCsarArtifactFlow = downloadCsarArtifact(resourceCreatePage); + final ToscaArtifactsPage toscaArtifactsPage = downloadCsarArtifactFlow.getLandedPage() + .orElseThrow(() -> new UiTestFlowRuntimeException("Missing expected ToscaArtifactsPage")); + + assertThat("No artifact download was found", toscaArtifactsPage.getDownloadedArtifactList(), not(empty())); + final String downloadedCsarName = toscaArtifactsPage.getDownloadedArtifactList().get(0); + final String downloadFolderPath = getConfig().getDownloadAutomationFolder(); + final Map<String, byte[]> filesFromZip = FileHandling.getFilesFromZip(downloadFolderPath, downloadedCsarName); + final Optional<String> resourceEntryOpt = filesFromZip.keySet().stream() + .filter(s -> s.equals("Definitions/" + downloadedCsarName.replace("-csar.csar", "-template.yml"))) + .findFirst(); + if (resourceEntryOpt.isEmpty()) { + fail("Could not find the resource package in Definitions"); + } + return loadYamlObject(filesFromZip.get(resourceEntryOpt.get())); + } + + private Map<String, Object> getMapEntry(final Map<String, Object> yamlObj, final String entryName) { + try { + return (Map<String, Object>) yamlObj.get(entryName); + } catch (final Exception e) { + final String errorMsg = String.format("Could not get the '%s' entry.", entryName); + fail(errorMsg + "Error message: " + e.getMessage()); + } + return null; + } + + private Map<String, Object> loadYamlObject(final byte[] mainDefinitionFileBytes) { + return new Yaml().load(new String(mainDefinitionFileBytes)); + } + + private DownloadCsarArtifactFlow downloadCsarArtifact(final ResourceCreatePage resourceCreatePage) { + final DownloadCsarArtifactFlow downloadCsarArtifactFlow = new DownloadCsarArtifactFlow(webDriver); + downloadCsarArtifactFlow.setWaitBeforeGetTheFile(5L); + downloadCsarArtifactFlow.run(resourceCreatePage); + return downloadCsarArtifactFlow; + } + + private CreateVfcFlow createVFC(final String fileName) { + vfcCreateData = createVfcFormData(); + final CreateVfcFlow createVfcFlow = new CreateVfcFlow(webDriver, vfcCreateData, filePath + fileName); + createVfcFlow.run(homePage); + return createVfcFlow; + } + + private CreateVfFlow createVF() { + vfCreateData = createVfFormData(); + final CreateVfFlow createVfFlow = new CreateVfFlow(webDriver, vfCreateData); + createVfFlow.run(homePage); + return createVfFlow; + } + + private ResourceCreateData createVfcFormData() { + final ResourceCreateData vfcCreateData = new ResourceCreateData(); + vfcCreateData.setRandomName(ElementFactory.getResourcePrefix() + "-VFC"); + vfcCreateData.setCategory(ResourceCategoryEnum.NETWORK_L4.getSubCategory()); + vfcCreateData.setTagList(Arrays.asList(vfcCreateData.getName(), "importVFC")); + vfcCreateData.setDescription("aDescription"); + vfcCreateData.setVendorName("Ericsson"); + vfcCreateData.setVendorRelease("1.2.3"); + vfcCreateData.setVendorModelNumber("4.5.6"); + return vfcCreateData; + } + + private ResourceCreateData createVfFormData() { + final ResourceCreateData vfCreateData = new ResourceCreateData(); + vfCreateData.setRandomName(ElementFactory.getResourcePrefix() + "-VF"); + vfCreateData.setCategory(ResourceCategoryEnum.NETWORK_L4.getSubCategory()); + vfCreateData.setTagList(Arrays.asList(vfCreateData.getName(), "createVF")); + vfCreateData.setDescription("aDescription"); + vfCreateData.setVendorName("Ericsson"); + vfCreateData.setVendorRelease("6.5.4"); + vfCreateData.setVendorModelNumber("3.2.1"); + return vfCreateData; + } + + private void checkMetadata(final Map<String, Object> map, final ResourceCreateData createdData) { + final Map<String, Object> metadata = getMapEntry(map, "metadata"); + + assertEquals(createdData.getName(), metadata.get("name")); + assertEquals(createdData.getDescription(), metadata.get("description")); + assertEquals("Network L4+", metadata.get("category")); + assertThat((String) metadata.get("type"), not(emptyString())); + assertEquals(createdData.getCategory(), metadata.get("subcategory")); + assertEquals(createdData.getVendorName(), metadata.get("resourceVendor")); + assertEquals(createdData.getVendorRelease(), metadata.get("resourceVendorRelease")); + assertEquals(createdData.getVendorModelNumber(), metadata.get("reourceVendorModelNumber")); + } + + private void checkNodeTypes(final Map<String, Object> map) { + final Map<String, Object> mapEntry = getMapEntry(map, "node_types"); + final Map<String, Object> nodeTypes = getMapEntry(mapEntry, mapEntry.keySet().iterator().next()); + + assertNotNull(nodeTypes); + assertEquals("aDescription", nodeTypes.get("description")); + + final Map<String, Object> properties = getMapEntry(nodeTypes, "properties"); + assertThat(properties, not(anEmptyMap())); + + final Map<String, Object> attributes = getMapEntry(nodeTypes, "attributes"); + assertThat(attributes, not(anEmptyMap())); + + final Map<String, Object> interfaces = getMapEntry(nodeTypes, "interfaces"); + assertThat(interfaces, not(anEmptyMap())); + + } + + private void checkTopologyTemplate(final Map<String, Object> map) { + final Map<String, Object> mapEntry = getMapEntry(map, "topology_template"); + assertNotNull(mapEntry); + + final Map<String, Object> properties = getMapEntry(mapEntry, "inputs"); + assertThat(properties, not(anEmptyMap())); + + final Map<String, Object> attributes = getMapEntry(mapEntry, "node_templates"); + assertThat(attributes, not(anEmptyMap())); + + final Map<String, Object> interfaces = getMapEntry(mapEntry, "substitution_mappings"); + assertThat(interfaces, not(anEmptyMap())); + + } +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddNodeToCompositionFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddNodeToCompositionFlow.java new file mode 100644 index 0000000000..fbc311d388 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/AddNodeToCompositionFlow.java @@ -0,0 +1,45 @@ +package org.onap.sdc.frontend.ci.tests.flow; + +import com.aventstack.extentreports.Status; +import java.util.Objects; +import java.util.Optional; +import org.onap.sdc.frontend.ci.tests.datatypes.ResourceCreateData; +import org.onap.sdc.frontend.ci.tests.pages.PageObject; +import org.onap.sdc.frontend.ci.tests.pages.ResourceCreatePage; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage; +import org.openqa.selenium.WebDriver; + +public class AddNodeToCompositionFlow extends AbstractUiTestFlow { + + private final ResourceCreateData destination; + private final ResourceCreateData resource; + private CompositionPage compositionPage; + private ResourceCreatePage resourceCreatePage; + + public AddNodeToCompositionFlow(final WebDriver webDriver, final ResourceCreateData destination, final ResourceCreateData resource) { + super(webDriver); + this.destination = destination; + this.resource = resource; + } + + @Override + public Optional<? extends PageObject> run(final PageObject... pageObjects) { + Objects.requireNonNull(destination); + Objects.requireNonNull(resource); + extendTest.log(Status.INFO, String.format("Adding Resource '%s' to VF/Service '%s'", resource.getName(), destination.getName())); + + resourceCreatePage = findParameter(pageObjects, ResourceCreatePage.class); + resourceCreatePage.isLoaded(); + + compositionPage = resourceCreatePage.goToComposition(); + compositionPage.isLoaded(); + compositionPage.addNodeToResourceCompositionUsingApi(destination.getName(), "0.1", resource.getName(), "1.0"); + compositionPage.goToGeneral(); + return Optional.of(compositionPage); + } + + @Override + public Optional<? extends PageObject> getLandedPage() { + return Optional.ofNullable(resourceCreatePage); + } +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVfFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVfFlow.java new file mode 100644 index 0000000000..898b2780a7 --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVfFlow.java @@ -0,0 +1,61 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.sdc.frontend.ci.tests.flow; + +import com.aventstack.extentreports.Status; +import java.util.Objects; +import java.util.Optional; +import org.onap.sdc.frontend.ci.tests.datatypes.ResourceCreateData; +import org.onap.sdc.frontend.ci.tests.pages.PageObject; +import org.onap.sdc.frontend.ci.tests.pages.ResourceCreatePage; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage; +import org.onap.sdc.frontend.ci.tests.pages.home.HomePage; +import org.openqa.selenium.WebDriver; + +public class CreateVfFlow extends AbstractUiTestFlow { + + private final ResourceCreateData vfCreateData; + private ResourceCreatePage vfCreatePage; + + public CreateVfFlow(final WebDriver webDriver, final ResourceCreateData vfCreateData) { + super(webDriver); + this.vfCreateData = vfCreateData; + } + + @Override + public Optional<? extends PageObject> run(final PageObject... pageObjects) { + Objects.requireNonNull(vfCreateData); + extendTest.log(Status.INFO, String.format("Creating VF '%s'", vfCreateData.getName())); + final HomePage homePage = findParameter(pageObjects, HomePage.class); + homePage.isLoaded(); + + vfCreatePage = homePage.clickOnAddVf(); + vfCreatePage.isLoaded(); + vfCreatePage.fillForm(vfCreateData); + + vfCreatePage.clickOnCreate(); + return Optional.of(vfCreatePage); + } + + @Override + public Optional<ResourceCreatePage> getLandedPage() { + return Optional.ofNullable(vfCreatePage); + } + +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVfcFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVfcFlow.java new file mode 100644 index 0000000000..94f69c1ebd --- /dev/null +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/CreateVfcFlow.java @@ -0,0 +1,63 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.sdc.frontend.ci.tests.flow; + +import com.aventstack.extentreports.Status; +import java.util.Objects; +import java.util.Optional; +import org.onap.sdc.frontend.ci.tests.datatypes.ResourceCreateData; +import org.onap.sdc.frontend.ci.tests.pages.PageObject; +import org.onap.sdc.frontend.ci.tests.pages.ResourceCreatePage; +import org.onap.sdc.frontend.ci.tests.pages.home.HomePage; +import org.openqa.selenium.WebDriver; + +public class CreateVfcFlow extends AbstractUiTestFlow { + + private final ResourceCreateData vfcCreateData; + private final String fullFileName; + private HomePage homePage; + private ResourceCreatePage vfcCreatePage; + + public CreateVfcFlow(final WebDriver webDriver, final ResourceCreateData vfcCreateData, final String fullFileName) { + super(webDriver); + this.vfcCreateData = vfcCreateData; + this.fullFileName = fullFileName; + } + + @Override + public Optional<? extends PageObject> run(final PageObject... pageObjects) { + Objects.requireNonNull(vfcCreateData); + extendTest.log(Status.INFO, String.format("Creating VFC '%s'", vfcCreateData.getName())); + homePage = findParameter(pageObjects, HomePage.class); + homePage.isLoaded(); + + vfcCreatePage = homePage.clickOnImportVfc(fullFileName); + vfcCreatePage.isLoaded(); + vfcCreatePage.fillForm(vfcCreateData); + + vfcCreatePage.clickOnCreate(); + return Optional.of(vfcCreatePage); + } + + @Override + public Optional<ResourceCreatePage> getLandedPage() { + return Optional.ofNullable(vfcCreatePage); + } + +} diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/DownloadCsarArtifactFlow.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/DownloadCsarArtifactFlow.java index a325f2b749..621d512e53 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/DownloadCsarArtifactFlow.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/flow/DownloadCsarArtifactFlow.java @@ -27,17 +27,21 @@ import com.aventstack.extentreports.Status; import java.io.File; import java.time.Duration; import java.util.Optional; +import lombok.Setter; import org.onap.sdc.frontend.ci.tests.execute.setup.ExtentTestActions; +import org.onap.sdc.frontend.ci.tests.pages.ComponentPage; import org.onap.sdc.frontend.ci.tests.pages.PageObject; -import org.onap.sdc.frontend.ci.tests.pages.ServiceComponentPage; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage; import org.onap.sdc.frontend.ci.tests.utilities.FileHandling; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.FluentWait; public class DownloadCsarArtifactFlow extends AbstractUiTestFlow { private ToscaArtifactsPage toscaArtifactsPage; + @Setter + private long waitBeforeGetTheFile = 0L; public DownloadCsarArtifactFlow(final WebDriver webDriver) { super(webDriver); @@ -45,16 +49,16 @@ public class DownloadCsarArtifactFlow extends AbstractUiTestFlow { @Override public Optional<PageObject> run(final PageObject... pageObjects) { - final ServiceComponentPage serviceComponentPage = findParameter(pageObjects, ServiceComponentPage.class); - toscaArtifactsPage = serviceComponentPage.goToToscaArtifacts(); + final ComponentPage componentPage = findParameter(pageObjects, ComponentPage.class); + toscaArtifactsPage = (ToscaArtifactsPage) componentPage.goToToscaArtifacts(); toscaArtifactsPage.isLoaded(); - toscaArtifactsPage.clickOnDownload("Tosca Model"); + toscaArtifactsPage.clickOnDownload("Tosca Model"); final File downloadedCsar = waitAndGetDowloadedCsar(); assertThat("The downloaded CSAR should exist", downloadedCsar, is(notNullValue())); assertThat("The downloaded CSAR should exist", downloadedCsar.exists(), is(true)); toscaArtifactsPage.addToDownloadedArtifactList(downloadedCsar.getName()); - ExtentTestActions.takeScreenshot(Status.INFO, "etsi-ns-csar-downloaded", "ETSI NS CSAR downloaded"); + ExtentTestActions.takeScreenshot(Status.INFO, "tosca-artifact-csar-download", "TOSCA Artifact downloaded"); return Optional.of(toscaArtifactsPage); } @@ -65,8 +69,8 @@ public class DownloadCsarArtifactFlow extends AbstractUiTestFlow { } private File waitAndGetDowloadedCsar() { - final FluentWait<String> fluentWait = new FluentWait<>("") - .withTimeout(Duration.ofSeconds(5)).pollingEvery(Duration.ofSeconds(1)); + new Actions(webDriver).pause(Duration.ofSeconds(waitBeforeGetTheFile)).perform(); + final FluentWait<String> fluentWait = new FluentWait<>("").withTimeout(Duration.ofSeconds(5)).pollingEvery(Duration.ofSeconds(1)); fluentWait.until(s -> FileHandling.getLastModifiedFileNameFromDir() != null); return FileHandling.getLastModifiedFileNameFromDir(); } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AbstractPageObject.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AbstractPageObject.java index 2564d0dd74..5983970770 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AbstractPageObject.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/AbstractPageObject.java @@ -16,17 +16,15 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - package org.onap.sdc.frontend.ci.tests.pages; +import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; -import java.util.List; - /** * Base UI test object that represents a page or component in a html page */ @@ -90,7 +88,7 @@ public abstract class AbstractPageObject implements PageObject { * Find an element inside the provided element using the provided xpath. * * @param element the parent element - * @param xpath the xpath expression to search for the internal element + * @param xpath the xpath expression to search for the internal element * @return the WebElement if found, otherwise throws an exception */ protected WebElement findSubElement(final WebElement element, final String xpath) { @@ -143,7 +141,7 @@ public abstract class AbstractPageObject implements PageObject { /** * Waits for element visibility with the provided timeout. * - * @param locator the By locator to search for the element + * @param locator the By locator to search for the element * @param timeoutInSeconds the wait timeout in seconds * @return the WebElement if visible before timeout, otherwise throws an exception */ @@ -166,7 +164,7 @@ public abstract class AbstractPageObject implements PageObject { /** * Waits for element invisibility with the provided timeout. * - * @param locator the By locator to search for the element + * @param locator the By locator to search for the element * @param timeoutInSeconds the wait timeout in seconds * @return the WebElement if invisible before timeout, false otherwise */ @@ -177,6 +175,7 @@ public abstract class AbstractPageObject implements PageObject { /** * Waits elements to be clickable with the default timeout. + * * @param xpath the xpath to find the element(s) * @return the WebElement if clickable before timeout, otherwise throws an exception */ @@ -186,6 +185,7 @@ public abstract class AbstractPageObject implements PageObject { /** * Waits elements to be clickable with the default timeout. + * * @param locator the By locator to search for the element(s) * @return the WebElement if clickable before timeout, otherwise throws an exception */ diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ComponentPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ComponentPage.java index 13ab884c70..50ee3273e7 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ComponentPage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ComponentPage.java @@ -16,7 +16,6 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - package org.onap.sdc.frontend.ci.tests.pages; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage; @@ -28,13 +27,11 @@ public class ComponentPage extends AbstractPageObject { private final ResourceLeftSideMenu resourceLeftSideMenu; private final ResourceWorkspaceTopBarComponent workspaceTopBarComponent; - public ComponentPage(final WebDriver webDriver, final TopNavComponent topNavComponent, - final ResourceLeftSideMenu resourceLeftSideMenu, - final ResourceWorkspaceTopBarComponent workspaceTopBarComponent) { + public ComponentPage(final WebDriver webDriver) { super(webDriver); - this.topNavComponent = topNavComponent; - this.resourceLeftSideMenu = resourceLeftSideMenu; - this.workspaceTopBarComponent = workspaceTopBarComponent; + this.topNavComponent = new TopNavComponent(webDriver); + this.resourceLeftSideMenu = new ResourceLeftSideMenu(webDriver); + this.workspaceTopBarComponent = new ResourceWorkspaceTopBarComponent(webDriver); } @Override @@ -47,5 +44,4 @@ public class ComponentPage extends AbstractPageObject { public ToscaArtifactsPage goToToscaArtifacts() { return resourceLeftSideMenu.clickOnToscaArtifactsMenuItem(); } - } diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceCreatePage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceCreatePage.java index 025c42a987..3737577c6f 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceCreatePage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceCreatePage.java @@ -21,33 +21,46 @@ package org.onap.sdc.frontend.ci.tests.pages; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalToIgnoringCase; +import static org.hamcrest.Matchers.startsWithIgnoringCase; import static org.hamcrest.core.Is.is; +import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; +import org.onap.sdc.frontend.ci.tests.datatypes.DataTestIdEnum; import org.onap.sdc.frontend.ci.tests.datatypes.LifeCycleStateEnum; import org.onap.sdc.frontend.ci.tests.datatypes.ResourceCreateData; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage; +import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage; +import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils; import org.onap.sdc.frontend.ci.tests.utilities.LoaderHelper; import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent; import org.onap.sdc.frontend.ci.tests.utilities.NotificationComponent.NotificationType; import org.openqa.selenium.By; +import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.Select; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Handles the Resource Create Page UI actions */ -public class ResourceCreatePage extends AbstractPageObject { +public class ResourceCreatePage extends ComponentPage { + private static final Logger LOGGER = LoggerFactory.getLogger(ResourceCreatePage.class); private final LoaderHelper loaderHelper; private final NotificationComponent notificationComponent; private final ResourceWorkspaceTopBarComponent topBarComponent; + private final ResourceLeftSideMenu resourceLeftSideMenu; public ResourceCreatePage(final WebDriver webDriver) { super(webDriver); - loaderHelper = new LoaderHelper(webDriver); - notificationComponent = new NotificationComponent(webDriver); - topBarComponent = new ResourceWorkspaceTopBarComponent(webDriver); + this.loaderHelper = new LoaderHelper(webDriver); + this.notificationComponent = new NotificationComponent(webDriver); + this.resourceLeftSideMenu = new ResourceLeftSideMenu(webDriver); + this.topBarComponent = new ResourceWorkspaceTopBarComponent(webDriver); timeoutInSeconds = 5; } @@ -56,7 +69,7 @@ public class ResourceCreatePage extends AbstractPageObject { topBarComponent.isLoaded(); final String lifeCycleState = topBarComponent.getLifecycleState(); assertThat("Life cycle state should be as expected", - lifeCycleState, is(equalToIgnoringCase(LifeCycleStateEnum.IN_DESIGN.getValue()))); + lifeCycleState, is(startsWithIgnoringCase(LifeCycleStateEnum.IN_DESIGN.getValue()))); } /** @@ -68,9 +81,30 @@ public class ResourceCreatePage extends AbstractPageObject { notificationComponent.waitForNotification(NotificationType.SUCCESS, 20); } + /** + * Certify the resource and wait for success notification. + */ + public void clickOnCertify() { + topBarComponent.clickOnCertify(); + findElement(By.xpath(XpathSelector.APPROVE_MESSAGE.getXpath())).sendKeys("Resource certified successfully"); + GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ModalItems.OK.getValue()).click(); + notificationComponent.waitForNotification(NotificationType.SUCCESS, 20); + } + + public ToscaArtifactsPage goToToscaArtifacts() { + resourceLeftSideMenu.isLoaded(); + return resourceLeftSideMenu.clickOnToscaArtifactsMenuItem(); + } + + public CompositionPage goToComposition() { + resourceLeftSideMenu.isLoaded(); + return resourceLeftSideMenu.clickOnCompositionMenuItem(); + } + public void fillForm(final ResourceCreateData resourceCreateData) { fillName(resourceCreateData.getName()); setCategory(resourceCreateData.getCategory()); + defineTags(resourceCreateData.getTagList()); fillDescription(resourceCreateData.getDescription()); fillContactId(resourceCreateData.getContactId()); fillVendorName(resourceCreateData.getVendorName()); @@ -78,31 +112,40 @@ public class ResourceCreatePage extends AbstractPageObject { fillVendorModelNumber(resourceCreateData.getVendorModelNumber()); } - public void fillName(final String name) { + private void fillName(final String name) { setInputField(By.xpath(XpathSelector.NAME_INPUT.getXpath()), name); } - public void setCategory(final String category) { + private void setCategory(final String category) { setSelectField(By.xpath(XpathSelector.CATEGORY_SELECT.getXpath()), category); } - public void fillDescription(final String description) { + private void defineTags(final List<String> tagList) { + final WebElement tagsTextbox = findElement(By.xpath(XpathSelector.TAGS.getXpath())); + for (final String tag : tagList) { + tagsTextbox.clear(); + tagsTextbox.sendKeys(tag); + tagsTextbox.sendKeys(Keys.ENTER); + } + } + + private void fillDescription(final String description) { setTextAreaField(By.xpath(XpathSelector.DESCRIPTION_TEXT_AREA.getXpath()), description); } - public void fillContactId(final String contactId) { + private void fillContactId(final String contactId) { setInputField(By.xpath(XpathSelector.CONTACT_ID_INPUT.getXpath()), contactId); } - public void fillVendorName(final String vendorName) { + private void fillVendorName(final String vendorName) { setInputField(By.xpath(XpathSelector.VENDOR_NAME_INPUT.getXpath()), vendorName); } - public void fillVendorRelease(final String vendorRelease) { + private void fillVendorRelease(final String vendorRelease) { setInputField(By.xpath(XpathSelector.VENDOR_RELEASE_INPUT.getXpath()), vendorRelease); } - public void fillVendorModelNumber(final String vendorModelNumber) { + private void fillVendorModelNumber(final String vendorModelNumber) { setInputField(By.xpath(XpathSelector.VENDOR_MODEL_NUMBER_INPUT.getXpath()), vendorModelNumber); } @@ -131,10 +174,12 @@ public class ResourceCreatePage extends AbstractPageObject { private enum XpathSelector { NAME_INPUT("name", "//input[@data-tests-id='%s']"), CATEGORY_SELECT("selectGeneralCategory", "//select[@data-tests-id='%s']"), + TAGS("i-sdc-tag-input", "//input[@data-tests-id='%s']"), DESCRIPTION_TEXT_AREA("description", "//textarea[@data-tests-id='%s']"), CONTACT_ID_INPUT("contactId", "//input[@data-tests-id='%s']"), VENDOR_NAME_INPUT("vendorName", "//input[@data-tests-id='%s']"), VENDOR_RELEASE_INPUT("vendorRelease", "//input[@data-tests-id='%s']"), + APPROVE_MESSAGE("checkindialog", "//textarea[@data-tests-id='%s']"), VENDOR_MODEL_NUMBER_INPUT("resourceVendorModelNumber", "//input[@data-tests-id='%s']"); @Getter diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceWorkspaceTopBarComponent.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceWorkspaceTopBarComponent.java index f92069e687..942c32a5db 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceWorkspaceTopBarComponent.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ResourceWorkspaceTopBarComponent.java @@ -16,7 +16,6 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - package org.onap.sdc.frontend.ci.tests.pages; import lombok.AllArgsConstructor; @@ -56,6 +55,10 @@ public class ResourceWorkspaceTopBarComponent extends AbstractPageObject { waitToBeClickable(XpathSelector.CREATE_BTN.getXpath()).click(); } + public void clickOnCertify() { + waitToBeClickable(XpathSelector.CERTIFY_BTN.getXpath()).click(); + } + public String getLifecycleState() { return lifecycleStateDiv.findElement(By.xpath(XpathSelector.FORM_LIFE_CYCLE_STATE.getXpath())).getText(); } @@ -70,6 +73,7 @@ public class ResourceWorkspaceTopBarComponent extends AbstractPageObject { VERSION_CONTAINER_DIV("version-container", "//div[@class='%s']"), ACTION_BUTTON_DIV("sdc-workspace-top-bar-buttons", "//div[@class='%s']"), CREATE_BTN("create/save", "//button[@data-tests-id='%s']"), + CERTIFY_BTN("certify", "//button[@data-tests-id='%s']"), FORM_LIFE_CYCLE_STATE("formlifecyclestate", "//span[@data-tests-id='%s']"); @Getter diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ServiceComponentPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ServiceComponentPage.java index a33bdc387c..d2b516722d 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ServiceComponentPage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/ServiceComponentPage.java @@ -23,7 +23,7 @@ import org.onap.sdc.frontend.ci.tests.pages.component.workspace.CompositionPage; import org.onap.sdc.frontend.ci.tests.pages.component.workspace.ToscaArtifactsPage; import org.openqa.selenium.WebDriver; -public class ServiceComponentPage extends AbstractPageObject { +public class ServiceComponentPage extends ComponentPage { private final TopNavComponent topNavComponent; private final ResourceLeftSideMenu resourceLeftSideMenu; diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionCanvasComponent.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionCanvasComponent.java index 6ecea473c5..f339412c14 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionCanvasComponent.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionCanvasComponent.java @@ -19,6 +19,8 @@ package org.onap.sdc.frontend.ci.tests.pages.component.workspace; +import static org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum.DESIGNER; + import com.aventstack.extentreports.Status; import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -31,7 +33,6 @@ import java.util.Set; import lombok.AllArgsConstructor; import lombok.Getter; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum; import org.onap.sdc.backend.ci.tests.utils.general.AtomicOperationUtils; import org.onap.sdc.frontend.ci.tests.datatypes.CanvasNodeElement; import org.onap.sdc.frontend.ci.tests.exception.CompositionCanvasRuntimeException; @@ -151,11 +152,11 @@ public class CompositionCanvasComponent extends AbstractPageObject { final Point pointFromCanvasCenter = calculateOffsetFromCenter(freePositionInCanvas); try { final Service service = - AtomicOperationUtils.getServiceObjectByNameAndVersion(UserRoleEnum.DESIGNER, serviceName, serviceVersion); + AtomicOperationUtils.getServiceObjectByNameAndVersion(DESIGNER, serviceName, serviceVersion); final Resource resourceToAdd = - AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceName, resourceVersion); + AtomicOperationUtils.getResourceObjectByNameAndVersion(DESIGNER, resourceName, resourceVersion); final ComponentInstance componentInstance = AtomicOperationUtils - .addComponentInstanceToComponentContainer(resourceToAdd, service, UserRoleEnum.DESIGNER, true, + .addComponentInstanceToComponentContainer(resourceToAdd, service, DESIGNER, true, String.valueOf(pointFromCanvasCenter.getX()), String.valueOf(pointFromCanvasCenter.getY())) .left().value(); @@ -166,6 +167,24 @@ public class CompositionCanvasComponent extends AbstractPageObject { } } + public ComponentInstance createNodeOnResourceCanvas(final String serviceName, final String serviceVersion, final String resourceName, + final String resourceVersion) { + final Point freePositionInCanvas = getFreePositionInCanvas(20); + final Point pointFromCanvasCenter = calculateOffsetFromCenter(freePositionInCanvas); + try { + final Resource service = AtomicOperationUtils.getResourceObjectByNameAndVersion(DESIGNER, serviceName, serviceVersion); + final Resource resourceToAdd = AtomicOperationUtils.getResourceObjectByNameAndVersion(DESIGNER, resourceName, resourceVersion); + final ComponentInstance componentInstance = + AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceToAdd, service, DESIGNER, true, + String.valueOf(pointFromCanvasCenter.getX()), String.valueOf(pointFromCanvasCenter.getY())).left().value(); + + LOGGER.debug("Created instance {} in the Service {}", componentInstance.getName(), serviceName); + return componentInstance; + } catch (final Exception e) { + throw new CompositionCanvasRuntimeException("Could not create node through the API", e); + } + } + private Point getFreePositionInCanvas(int maxAttempts) { boolean isPositionFree; final int minSpace = 150; diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionPage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionPage.java index c013247a28..19a21503e5 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionPage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/component/workspace/CompositionPage.java @@ -20,6 +20,7 @@ package org.onap.sdc.frontend.ci.tests.pages.component.workspace; import org.onap.sdc.frontend.ci.tests.pages.AbstractPageObject; +import org.onap.sdc.frontend.ci.tests.pages.ResourceCreatePage; import org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent; import org.onap.sdc.frontend.ci.tests.pages.ServiceComponentPage; import org.onap.sdc.frontend.ci.tests.pages.TopNavComponent; @@ -55,11 +56,16 @@ public class CompositionPage extends AbstractPageObject { compositionDetailSideBarComponent.isLoaded(); } - public ComponentInstance addNodeToCompositionUsingApi(final String serviceName, final String serviceVersion, final String resourceName, + public ComponentInstance addNodeToServiceCompositionUsingApi(final String serviceName, final String serviceVersion, final String resourceName, final String resourceVersion) { return compositionCanvasComponent.createNodeOnServiceCanvas(serviceName, serviceVersion, resourceName, resourceVersion); } + public ComponentInstance addNodeToResourceCompositionUsingApi(final String serviceName, final String serviceVersion, final String resourceName, + final String resourceVersion) { + return compositionCanvasComponent.createNodeOnResourceCanvas(serviceName, serviceVersion, resourceName, resourceVersion); + } + /** * Select a node in the canvas * @@ -70,9 +76,9 @@ public class CompositionPage extends AbstractPageObject { compositionDetailSideBarComponent.checkComponentIsSelected(nodeName); } - public ServiceComponentPage goToServiceGeneral() { + public ResourceCreatePage goToGeneral() { topNavComponent.clickOnBreadCrumb(1); - return new ServiceComponentPage(webDriver); + return new ResourceCreatePage(webDriver); } /** diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/home/HomePage.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/home/HomePage.java index 7a0d7a1e6b..94568ca1d2 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/home/HomePage.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/pages/home/HomePage.java @@ -51,6 +51,11 @@ public class HomePage extends AbstractPageObject { this.topNavComponent = topNavComponent; } + public HomePage(final WebDriver webDriver) { + super(webDriver); + this.topNavComponent = new TopNavComponent(webDriver); + } + @Override public void isLoaded() { new Actions(webDriver).pause(Duration.ofSeconds(2)).perform(); @@ -93,22 +98,26 @@ public class HomePage extends AbstractPageObject { } /** - * Clicks on the add PNF button. + * Clicks on the Import VFC button. * * @return the following resource create page */ - public ResourceCreatePage clickOnAddPnf() { - clickOnAdd(By.xpath(XpathSelector.ADD_PNF_BTN.getXpath())); + public ResourceCreatePage clickOnImportVfc(final String fullFileName) { + clickOnImport(By.xpath(XpathSelector.IMPORT_VFC_BTN.getXpath()), fullFileName); return new ResourceCreatePage(webDriver); } + private void clickOnImport(final By locator, final String fullFileName) { + hoverToImportArea().findElement(locator).sendKeys(fullFileName); + } + /** - * Clicks on the Import VFC button. + * Clicks on the add PNF button. * * @return the following resource create page */ - public ResourceCreatePage clickOnImportVfc() { - clickOnImport(By.xpath(XpathSelector.IMPORT_VFC_BTN.getXpath())); + public ResourceCreatePage clickOnAddPnf() { + clickOnAdd(By.xpath(XpathSelector.ADD_PNF_BTN.getXpath())); return new ResourceCreatePage(webDriver); } @@ -125,17 +134,12 @@ public class HomePage extends AbstractPageObject { throw new UnsupportedOperationException("Return not yet implemented for " + text); } - private void clickOnAdd(final By locator) { - hoverToAddArea(); - waitForElementVisibility(locator); - findElement(locator).click(); + hoverToAddArea().findElement(locator).click(); } private void clickOnImport(final By locator) { - hoverToImportArea(); - waitForElementVisibility(locator); - findElement(locator).click(); + hoverToImportArea().findElement(locator).click(); } /** @@ -143,7 +147,7 @@ public class HomePage extends AbstractPageObject { * * @return the add buttons area element */ - public WebElement hoverToAddArea() { + private WebElement hoverToAddArea() { return hoverTo(By.xpath(XpathSelector.ADD_BUTTONS_AREA.getXpath())); } @@ -152,11 +156,10 @@ public class HomePage extends AbstractPageObject { * * @return the Import buttons area element */ - public WebElement hoverToImportArea() { + private WebElement hoverToImportArea() { return hoverTo(By.xpath(XpathSelector.IMPORT_BUTTONS_AREA.getXpath())); } - private WebElement hoverTo(final By locator) { final WebElement addButtonsAreaElement = findElement(locator); final Actions actions = new Actions(webDriver); diff --git a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/LoaderHelper.java b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/LoaderHelper.java index e5bfc2bbbb..b45d329264 100644 --- a/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/LoaderHelper.java +++ b/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/utilities/LoaderHelper.java @@ -32,7 +32,7 @@ public class LoaderHelper extends AbstractPageObject { } public void waitForLoader(final int timeout) { - waitForElementVisibility(loaderLocator, 5); + waitForElementVisibility(loaderLocator, timeout); waitForElementInvisibility(loaderLocator, timeout); } diff --git a/integration-tests/src/test/resources/Files/importVfc/org.openecomp.resource.VFC-child.yml b/integration-tests/src/test/resources/Files/importVfc/org.openecomp.resource.VFC-child.yml new file mode 100644 index 0000000000..2c00cbd7e9 --- /dev/null +++ b/integration-tests/src/test/resources/Files/importVfc/org.openecomp.resource.VFC-child.yml @@ -0,0 +1,24 @@ +tosca_definitions_version: tosca_simple_yaml_1_3 +node_types: + org.openecomp.resource.VFC-child: + derived_from: org.openecomp.resource.VFC-root + properties: + aProperty: + type: string + required: false + attributes: + test_1: + type: string + default: 'MydefaultValue' + + test_2: + type: integer + default: 266305 + + test_3: + type: string + default: 'TestValue3' + + test_4: + type: boolean + default: true
\ No newline at end of file diff --git a/integration-tests/src/test/resources/Files/importVfc/org.openecomp.resource.VFC-root.yml b/integration-tests/src/test/resources/Files/importVfc/org.openecomp.resource.VFC-root.yml new file mode 100644 index 0000000000..679f1b64f9 --- /dev/null +++ b/integration-tests/src/test/resources/Files/importVfc/org.openecomp.resource.VFC-root.yml @@ -0,0 +1,8 @@ +tosca_definitions_version: tosca_simple_yaml_1_3 +node_types: + org.openecomp.resource.VFC-root: + derived_from: tosca.nodes.Root + properties: + aProperty: + type: string + required: false
\ No newline at end of file diff --git a/integration-tests/src/test/resources/ci/conf/sdc-conf.yaml b/integration-tests/src/test/resources/ci/conf/sdc-conf.yaml index e4b07d36ee..eb20978ad6 100644 --- a/integration-tests/src/test/resources/ci/conf/sdc-conf.yaml +++ b/integration-tests/src/test/resources/ci/conf/sdc-conf.yaml @@ -3,18 +3,17 @@ url: http://sdc-sim:8080/sdc1 remoteTestingMachineIP: 127.0.0.1 remoteTestingMachinePort: 4444 remoteTesting: true -useBrowserMobProxy: false -captureTraffic: false downloadAutomationFolder: /tmp/sdc-integration-tests/downloadAutomation -uiSimulator: true #### Local Front end testing #url: http://localhost:8285/sdc1 #remoteTesting: false -#useBrowserMobProxy: false -#captureTraffic: false #downloadAutomationFolder: /tmp/sdc-integration-tests/downloadAutomation -#uiSimulator: true + +##################### +useBrowserMobProxy: false +captureTraffic: false +uiSimulator: true #### Backend Testing outputFolder: target |