1 package org.openecomp.sdc.ci.tests.execute.sanity;
3 import com.aventstack.extentreports.Status;
4 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
5 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ToscaArtifactsScreenEnum;
6 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
7 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
8 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
9 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
10 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
11 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
12 import org.openecomp.sdc.ci.tests.tosca.datatypes.ToscaDefinition;
13 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
14 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
15 import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
16 import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils;
17 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
18 import org.testng.annotations.BeforeMethod;
19 import org.testng.annotations.Test;
23 import static org.assertj.core.api.Assertions.assertThat;
25 public class Annotation extends SetupCDTest {
26 private String filePath;
29 public void beforeTest() {
30 filePath = FileHandling.getFilePath("SRIOV");
34 public void importCsarWithAnnotationVerifyDownloadYmlContainsAnnotationSection() throws Exception {
35 String fileName = "SIROV_annotations_VSP.csar";
36 ResourceReqDetails vfMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF,
37 NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
38 ResourceUIUtils.importVfFromCsar(vfMetaData, filePath, fileName, getUser());
39 getExtendTest().log(Status.INFO, "Csar with annotations imported successfully.");
40 ResourceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen();
41 GeneralUIUtils.clickOnElementByTestId(ToscaArtifactsScreenEnum.TOSCA_MODEL.getValue());
42 File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir();
43 ToscaDefinition toscaMainVfDefinition = ToscaParserUtils.parseToscaMainYamlToJavaObjectByCsarLocation(latestFilefromDir);
44 assertTrueAnnotationTestSuite(toscaMainVfDefinition);
45 getExtendTest().log(Status.INFO, "Success to validate the ToscaMainYaml contains annotation type source with properties.");
49 public void assertTrueAnnotationTestSuite(ToscaDefinition toscaMainVfDefinition) {
50 assertThat(toscaMainVfDefinition.getTopology_template().getInputs().get("availabilityzone_name").annotations).containsKey("source");
51 assertThat(toscaMainVfDefinition.getTopology_template().getInputs().get("availabilityzone_name").getAnnotations().get("source").getType()).isEqualTo("org.openecomp.annotations.Source");
52 assertThat(toscaMainVfDefinition.getTopology_template().getInputs().get("availabilityzone_name").getAnnotations().get("source").getProperties().get("source_type")).isEqualTo("HEAT");
56 protected UserRoleEnum getRole() {
57 return UserRoleEnum.DESIGNER;