2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.execute.devCI;
23 import org.junit.Rule;
24 import org.junit.rules.TestName;
25 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
26 import org.openecomp.sdc.be.model.Resource;
27 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
28 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
29 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
30 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
31 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
32 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
33 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
34 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
35 import org.openecomp.sdc.ci.tests.utils.validation.CsarValidationUtils;
36 import org.testng.annotations.DataProvider;
37 import org.testng.annotations.Test;
39 import static org.testng.AssertJUnit.assertTrue;
41 public class ImportCsarValidateArtifacts extends ComponentBaseTest {
44 public static TestName name = new TestName();
46 public ImportCsarValidateArtifacts() {
47 super(name, ImportCsarValidateArtifacts.class.getName());
50 @DataProvider(name = "happyArts")
51 public Object[][] getHappyArtifacts() {
53 return new Object[][] { { "happy_VF_RI2_G2_two_different_artifacts_under_heatBaseheatVolheatNet2" },
54 { "happy_VF_RI2_G2_two_different_artifacts_under_heatBaseheatVolheatNet" },
55 { "happy_VF_RI2_G2_two_identical_artifacts_under_heatBaseheatVolheatNet" },
56 { "happy_VF_RI2_G2_two_different_artifacts_under_nested" },
57 { "happy_VF_RI2_G2_two_indentical_nested_under_different_groups" },
58 { "happy_VF_RI2_G2_two_different_nested_under_different_groups" },
59 { "happy_VF_RI2_G2_two_different_nested_under_same_group" },
64 @DataProvider(name = "negativeArts")
65 public Object[][] getNegativeArtifacts() {
67 return new Object[][] {
69 { "negative_VF_RI2_G2_same_heatVol_different_groups" },
70 { "negative_VF_RI2_G2_same_heatBase_different_envs" },
71 { "negative_VF_RI2_G2_heatBaseHeatVolHeatNet_under_nested" },
72 { "negative_VF_RI2_G2_two_indentical_artifacts_under_nested" },
73 { "negative_VF_RI2_G2_nested_under_nested" }, { "negative_VF_RI2_G2_same_heatVol_different_groups" }, };
76 @Test(dataProvider = "happyArts")
77 public void createResourceFromCsarArtsHappy(String artifactName) throws Exception {
79 ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
80 resourceDetails.setCsarUUID(artifactName);
81 resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
82 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails,
83 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
85 BaseRestUtils.checkCreateResponse(createResource);
86 Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
87 CsarValidationUtils.validateCsarVfArtifact(artifactName, resource);
91 @Test(dataProvider = "negativeArts")
92 public void createResourceFromCsarArtsNegative(String artifactName) throws Exception {
94 ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
95 resourceDetails.setCsarUUID(artifactName);
96 resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
97 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails,
98 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
99 assertTrue(createResource.getErrorCode() != 201 && createResource.getErrorCode() != 500);