1 package org.openecomp.sdc.uici.tests.utilities;
3 import static org.openecomp.sdc.common.datastructure.FunctionalInterfaces.retryMethodOnException;
7 import org.json.simple.JSONObject;
8 import org.json.simple.JSONValue;
9 import org.openecomp.sdc.uici.tests.datatypes.CreateAndUpdateStepsEnum;
10 import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum;
11 import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.Artifatcs;
12 import org.openecomp.sdc.uici.tests.datatypes.DataTestIdEnum.InformationalArtifatcs;
13 import org.openqa.selenium.WebElement;
15 import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
16 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
17 import org.openecomp.sdc.common.datastructure.FunctionalInterfaces;
19 public final class ArtifactUIUtils {
21 private ArtifactUIUtils() {
22 throw new UnsupportedOperationException();
25 public static void addInformationArtifact(ArtifactReqDetails artifact, String filePath,
26 final InformationalArtifatcs dataTestEnum) {
27 GeneralUIUtils.waitForLoader();
28 GeneralUIUtils.sleep(2000);
29 GeneralUIUtils.getWebElementWaitForVisible(dataTestEnum.getValue()).click();
31 final WebElement browseWebElement = FunctionalInterfaces.retryMethodOnException(
32 () -> GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.BROWSE_BUTTON.getValue()));
33 browseWebElement.sendKeys(filePath);
35 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.DESCRIPTION.getValue())
36 .sendKeys(artifact.getDescription());
37 GeneralUIUtils.getWebElementWaitForVisible(DataTestIdEnum.ModalItems.DONE.getValue()).click();
41 public static Map<String, Map<String, Object>> getArtifactsListFromResponse(String jsonResponse,
42 String fieldOfArtifactList) {
43 JSONObject object = (JSONObject) JSONValue.parse(jsonResponse);
44 Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) object.get(fieldOfArtifactList);
49 * Creates a deployment artifact on the vf. <br>
50 * Moves automatically to DeploymentArtifact Section
52 * @param artifactPayloadPath
55 public static void createDeploymentArtifactOnVf(final String artifactPayloadPath,
56 final ArtifactTypeEnum artifactType) {
57 GeneralUIUtils.moveToStep(CreateAndUpdateStepsEnum.DEPLOYMENT_ARTIFACT);
58 GeneralUIUtils.getWebElementWaitForClickable(Artifatcs.ADD_DEPLOYMENT_ARTIFACT.getValue()).click();
59 GeneralUIUtils.getSelectList("Create New Artifact", Artifatcs.SELECT_ARTIFACT_DROPDOWN.getValue());
60 GeneralUIUtils.getSelectList(artifactType.getType(), Artifatcs.ARTIFACT_TYPE_DROPDOWN.getValue());
61 GeneralUIUtils.getWebElementWaitForVisible(Artifatcs.ARTIFACT_DESCRIPTION.getValue())
62 .sendKeys("Artifact Description");
63 GeneralUIUtils.getWebElementWaitForVisible(Artifatcs.ARTIFACT_LABEL.getValue()).sendKeys("MyArtifactLabel");
64 retryMethodOnException(() -> GeneralUIUtils.getWebElementByDataTestId(Artifatcs.BROWSE_BUTTON.getValue())
65 .sendKeys(artifactPayloadPath));
66 GeneralUIUtils.getWebElementWaitForVisible(Artifatcs.ADD_BUTTON.getValue()).click();
67 GeneralUIUtils.waitForLoader();