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 @DataProvider(name = "happyArts")
47 public Object[][] getHappyArtifacts() {
49 return new Object[][] { { "happy_VF_RI2_G2_two_different_artifacts_under_heatBaseheatVolheatNet2" },
50 { "happy_VF_RI2_G2_two_different_artifacts_under_heatBaseheatVolheatNet" },
51 { "happy_VF_RI2_G2_two_identical_artifacts_under_heatBaseheatVolheatNet" },
52 { "happy_VF_RI2_G2_two_different_artifacts_under_nested" },
53 { "happy_VF_RI2_G2_two_indentical_nested_under_different_groups" },
54 { "happy_VF_RI2_G2_two_different_nested_under_different_groups" },
55 { "happy_VF_RI2_G2_two_different_nested_under_same_group" },
60 @DataProvider(name = "negativeArts")
61 public Object[][] getNegativeArtifacts() {
63 return new Object[][] {
65 { "negative_VF_RI2_G2_same_heatVol_different_groups" },
66 { "negative_VF_RI2_G2_same_heatBase_different_envs" },
67 { "negative_VF_RI2_G2_heatBaseHeatVolHeatNet_under_nested" },
68 { "negative_VF_RI2_G2_two_indentical_artifacts_under_nested" },
69 { "negative_VF_RI2_G2_nested_under_nested" }, { "negative_VF_RI2_G2_same_heatVol_different_groups" }, };
72 @Test(dataProvider = "happyArts")
73 public void createResourceFromCsarArtsHappy(String artifactName) throws Exception {
75 ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
76 resourceDetails.setCsarUUID(artifactName);
77 resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
78 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails,
79 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
81 BaseRestUtils.checkCreateResponse(createResource);
82 Resource resource = ResponseParser.parseToObjectUsingMapper(createResource.getResponse(), Resource.class);
83 CsarValidationUtils.validateCsarVfArtifact(artifactName, resource);
87 @Test(dataProvider = "negativeArts")
88 public void createResourceFromCsarArtsNegative(String artifactName) throws Exception {
90 ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource();
91 resourceDetails.setCsarUUID(artifactName);
92 resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
93 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails,
94 ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER));
95 assertTrue(createResource.getErrorCode() != 201 && createResource.getErrorCode() != 500);