9363b8c4fe7d958d1934a976b3e966cca223a8f8
[sdc.git] /
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
24 import org.junit.rules.TestName;
25 import org.openecomp.sdc.be.model.User;
26 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
27 import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
28 import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
29 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
30 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
31 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
32 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
33 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
34 import org.openecomp.sdc.ci.tests.utils.ArtifactUtils;
35 import org.openecomp.sdc.ci.tests.utils.Utils;
36 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
37 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
38 import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
39 import org.testng.annotations.BeforeMethod;
40
41 import java.io.IOException;
42
43 import static org.testng.AssertJUnit.assertTrue;
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
61         protected ArtifactUtils artifactUtils;
62         protected Utils utils;
63
64         private static RestResponse createServiceResponse;
65
66         @BeforeMethod
67         public void before() throws Exception {
68
69                 initializeMembers();
70                 createComponents();
71
72         }
73
74         public void initializeMembers() throws IOException, Exception {
75                 sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
76                 resourceDetails = ElementFactory.getDefaultResource();
77                 serviceDetails = ElementFactory.getDefaultService();
78                 heatArtifactDetails1 = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
79                 resourceInstanceReqDetails = ElementFactory.getDefaultComponentInstance("resourceInstanceReqDetails");
80         }
81
82         protected void createComponents() throws Exception {
83
84                 RestResponse response = ResourceRestUtils.createResource(resourceDetails, sdncDesignerDetails);
85                 assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
86
87                 response = ServiceRestUtils.createService(serviceDetails, sdncDesignerDetails);
88                 assertTrue("create request returned status:" + response.getErrorCode(), response.getErrorCode() == 201);
89
90         }
91
92 }