1 package org.openecomp.sdc.ci.tests.execute.imports;
3 import org.junit.rules.TestName;
4 import org.openecomp.sdc.be.model.Service;
5 import org.openecomp.sdc.be.model.User;
6 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
7 import org.openecomp.sdc.ci.tests.config.Config;
8 import org.openecomp.sdc.ci.tests.datatypes.ImportReqDetails;
9 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
10 import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
11 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
12 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
13 import org.openecomp.sdc.ci.tests.utils.ToscaParserUtils;
14 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
15 import org.openecomp.sdc.ci.tests.utils.general.ImportUtils;
16 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
17 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
18 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
19 import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
20 import org.testng.annotations.BeforeMethod;
21 import org.testng.annotations.Test;
24 import java.nio.file.Paths;
27 import static org.junit.Assert.assertEquals;
29 public class ToscaTemplateVersionTest extends ComponentBaseTest {
31 private static final String EXPECTED_EXPORT_TOSCA_VERSION = "tosca_simple_yaml_1_1";
32 private static final String YML_110_VERSION = "loadBalancerTestVersion.yml";
33 public static TestName name = new TestName();
34 private String SOURCE_DIR;
35 private static String WORK_DIR = "importToscaResourceByCreateUrl";
37 public ToscaTemplateVersionTest() {
38 super(name, ToscaTemplateVersionTest.class.getName());
42 public void setUp() throws Exception {
43 SOURCE_DIR = config.getResourceConfigDir();
47 public void verifyExportYamlVersion() throws Exception {
48 User defaultUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
49 ServiceReqDetails serviceDetails = ElementFactory.getDefaultService("ciYamlVersionTest", ServiceCategoriesEnum.MOBILITY, defaultUser.getUserId());
50 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, defaultUser);
51 BaseRestUtils.checkCreateResponse(serviceResponse);
52 Service service = ResponseParser.parseToObjectUsingMapper(serviceResponse.getResponse(), Service.class);
53 Map<String, Object> load = ToscaParserUtils.downloadAndParseToscaTemplate(defaultUser, service);
54 assertEquals(ToscaParserUtils.getToscaVersion(load), EXPECTED_EXPORT_TOSCA_VERSION);
58 public void testVerifyImportYamlVersion_1_1_0() throws Exception {
59 String testResourcesPath = Paths.get(SOURCE_DIR, WORK_DIR).toString();
60 ImportReqDetails importReqDetails = ImportUtils.getImportResourceDetailsByPathAndName(ElementFactory.getDefaultImportResource(), testResourcesPath,
62 RestResponse importResourceResponse = ResourceRestUtils.createImportResource(importReqDetails, ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER),
64 BaseRestUtils.checkCreateResponse(importResourceResponse);