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.utils.rest;
23 import org.openecomp.sdc.ci.tests.api.Urls;
24 import org.openecomp.sdc.ci.tests.config.Config;
25 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
26 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
27 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
28 import org.openecomp.sdc.ci.tests.utils.Utils;
30 import java.io.IOException;
31 import java.util.HashMap;
34 public class CatalogRestUtils extends BaseRestUtils {
36 public static RestResponse getAbstractResources() throws IOException {
38 Config config = Utils.getConfig();
39 String url = String.format(Urls.GET_ALL_ABSTRACT_RESOURCES, config.getCatalogBeHost(),
40 config.getCatalogBePort());
42 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());
45 public static RestResponse getCatalog() throws IOException {
46 return getCatalog(UserRoleEnum.DESIGNER.getUserId());
49 public static RestResponse getCatalog(String userId) throws IOException {
50 Config config = Utils.getConfig();
51 String url = String.format(Urls.GET_CATALOG_DATA, config.getCatalogBeHost(), config.getCatalogBePort());
52 return sendGet(url, userId);
55 public static RestResponse getAllCategoriesTowardsCatalogBe() throws IOException {
57 Config config = Utils.getConfig();
58 String url = String.format(Urls.GET_ALL_CATEGORIES, config.getCatalogBeHost(), config.getCatalogBePort(),
59 BaseRestUtils.RESOURCE_COMPONENT_TYPE);
61 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());
64 public static RestResponse getAllCategoriesTowardsCatalogFeWithUuid(String uuid) throws IOException {
66 Config config = Utils.getConfig();
67 String url = String.format(Urls.GET_ALL_CATEGORIES_FE, config.getCatalogFeHost(), config.getCatalogFePort(),
68 BaseRestUtils.RESOURCE_COMPONENT_TYPE);
70 Map<String, String> additionalHeaders = new HashMap<>();
71 additionalHeaders.put(HttpHeaderEnum.X_ECOMP_REQUEST_ID_HEADER.getValue(), uuid);
73 return sendGet(url, UserRoleEnum.DESIGNER.getUserId(), additionalHeaders);
76 public static RestResponse getOnboardVersion() throws IOException {
78 Config config = Utils.getConfig();
79 String url = String.format(Urls.ONBOARD_VERSION, config.getCatalogBeHost(),
80 config.getCatalogBePort());
82 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());
85 public static RestResponse getOsVersion() throws IOException {
87 Config config = Utils.getConfig();
88 String url = String.format(Urls.OS_VERSION, config.getCatalogBeHost(), config.getCatalogBePort());
90 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());