411058627f975b24c67c3c6b17237cdef4cdb23c
[sdc.git] /
1 /*
2  * Copyright © 2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.sdc.ci.tests.execute.globaltypes;
18
19 import java.util.HashMap;
20 import java.util.Map;
21 import org.json.simple.JSONObject;
22 import org.json.simple.JSONValue;
23 import org.junit.Rule;
24 import org.junit.rules.TestName;
25 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
26 import org.openecomp.sdc.ci.tests.api.Urls;
27 import org.openecomp.sdc.ci.tests.config.Config;
28 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
29 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
30 import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
31 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
32 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
33 import org.testng.AssertJUnit;
34 import org.testng.annotations.BeforeMethod;
35 import org.testng.annotations.Test;
36
37 public class InterfaceLifecycleTypesTest extends ComponentBaseTest {
38
39   protected Config config = Config.instance();
40   protected HttpRequest httpRequest = new HttpRequest();
41   protected Map<String, String> headersMap = new HashMap<>();
42   @Rule
43   public static final TestName testName = new TestName();
44
45   @BeforeMethod
46   public void init() {
47     headersMap.put(HttpHeaderEnum.USER_ID.getValue(), ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER).getUserId());
48   }
49
50   @Test
51   public void testGetAllInterfaceLifecycleTypes() throws Exception {
52     final String standardType = "tosca.interfaces.node.lifecycle.standard";
53     final String nfvType = "tosca.interfaces.nfv.vnf.lifecycle.nfv";
54     String url = String.format(Urls.GET_All_INTERFACE_LIFECYCLE_TYPES, config.getCatalogBeHost(), config.getCatalogBePort());
55     RestResponse restResponse = httpRequest.httpSendGet(url, headersMap);
56     AssertJUnit.assertTrue(restResponse.getErrorCode() == 200);
57     JSONObject jsonObject = (JSONObject) JSONValue.parse(restResponse.getResponse());
58     AssertJUnit.assertTrue(jsonObject.containsKey(standardType));
59     AssertJUnit.assertTrue(jsonObject.containsKey(nfvType));
60   }
61 }