Sync Integ to Master
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / utils / rest / GroupRestUtils.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.utils.rest;
22
23 import java.io.IOException;
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
28 import org.openecomp.sdc.be.model.Component;
29 import org.openecomp.sdc.be.model.User;
30 import org.openecomp.sdc.ci.tests.api.Urls;
31 import org.openecomp.sdc.ci.tests.config.Config;
32 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
33 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
34 import org.openecomp.sdc.ci.tests.utils.Utils;
35
36 import com.google.gson.Gson;
37
38 public class GroupRestUtils extends BaseRestUtils {
39         static Config config = Config.instance();
40         public static Gson gson = new Gson();
41
42         public static RestResponse getGroupById(Component component, String groupId, User user) throws IOException {
43
44                 Config config = Utils.getConfig();
45
46                 Map<String, String> headersMap = new HashMap<>();
47                 headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
48                 headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderData);
49                 headersMap.put(HttpHeaderEnum.USER_ID.getValue(), user.getUserId());
50
51                 String url = String.format(Urls.GET_GROUP_BY_ID, config.getCatalogBeHost(), config.getCatalogBePort(),
52                                 ComponentTypeEnum.findParamByType(component.getComponentType()), component.getUniqueId(), groupId);
53
54                 RestResponse sendGetServerRequest = sendGet(url, user.getUserId(), headersMap);
55
56                 return sendGetServerRequest;
57
58         }
59
60 }