[SDC-29] rebase continue work to align source
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / preRequisites / SimpleOneRsrcOneServiceTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.preRequisites;
22
23 import static org.testng.AssertJUnit.assertTrue;
24
25 import java.io.IOException;
26
27 import org.apache.log4j.lf5.util.ResourceUtils;
28 import org.junit.rules.TestName;
29 import org.openecomp.sdc.be.model.User;
30 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
31 import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
32 import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
33 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
34 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
35 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
36 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
37 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
38 import org.openecomp.sdc.ci.tests.utils.ArtifactUtils;
39 import org.openecomp.sdc.ci.tests.utils.Utils;
40 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
41 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
42 import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
43 import org.testng.annotations.BeforeMethod;
44
45 public abstract class SimpleOneRsrcOneServiceTest extends ComponentBaseTest {
46
47         protected ResourceReqDetails resourceDetails;
48         protected ServiceReqDetails serviceDetails;
49         protected ComponentInstanceReqDetails resourceInstanceReqDetails;
50         protected ArtifactReqDetails heatArtifactDetails1;
51
52         private static final String heatExtension = "yaml";
53         private static final String yangXmlExtension = "xml";
54         private static final String muranoPkgExtension = "zip";
55         private static final String extension = null;
56         private final String folderName = "heatEnv";
57
58         protected User sdncDesignerDetails;
59         protected ArtifactReqDetails defaultArtifactDetails;
60         protected ResourceUtils resourceUtils;
61         protected ArtifactUtils artifactUtils;
62         protected Utils utils;
63
64         private static RestResponse createServiceResponse;
65
66         public SimpleOneRsrcOneServiceTest(TestName testName, String className) {
67                 super(testName, className);
68         }
69
70         @BeforeMethod
71         public void before() throws Exception {
72
73                 initializeMembers();
74                 createComponents();
75
76         }
77
78         public void initializeMembers() throws IOException, Exception {
79                 sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
80                 resourceDetails = ElementFactory.getDefaultResource();
81                 serviceDetails = ElementFactory.getDefaultService();
82                 heatArtifactDetails1 = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
83                 resourceInstanceReqDetails = ElementFactory.getDefaultComponentInstance("resourceInstanceReqDetails");
84         }
85
86         protected void createComponents() throws Exception {
87
88                 RestResponse response = ResourceRestUtils.createResource(resourceDetails, sdncDesignerDetails);
89                 assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
90
91                 response = ServiceRestUtils.createService(serviceDetails, sdncDesignerDetails);
92                 assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
93
94         }
95
96 }