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 java.io.IOException;
24 import java.util.Collections;
25 import java.util.HashMap;
26 import java.util.List;
28 import java.util.Optional;
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.enums.UserRoleEnum;
33 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
34 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
35 import org.openecomp.sdc.ci.tests.utils.Utils;
37 public class CatalogRestUtils extends BaseRestUtils {
39 public static RestResponse getAbstractResources() throws IOException {
41 Config config = Utils.getConfig();
42 String url = String.format(Urls.GET_ALL_ABSTRACT_RESOURCES, config.getCatalogBeHost(),
43 config.getCatalogBePort());
45 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());
48 public static RestResponse getCatalog() throws IOException {
49 return getCatalog(UserRoleEnum.DESIGNER.getUserId());
52 public static RestResponse getCatalog(String userId) throws IOException {
53 Config config = Utils.getConfig();
54 String url = String.format(Urls.GET_CATALOG_DATA, config.getCatalogBeHost(), config.getCatalogBePort());
55 return sendGet(url, userId);
58 public static RestResponse getCatalog(String userId, List<String> excludeList) throws IOException {
59 Config config = Utils.getConfig();
60 String url = String.format(Urls.GET_CATALOG_DATA, config.getCatalogBeHost(), config.getCatalogBePort());
61 StringBuilder sb = new StringBuilder();
62 sb.append(url).append("?");
63 Optional.ofNullable(excludeList).orElse(Collections.emptyList()).forEach(type -> sb.append("excludeTypes="+type+"&"));
64 return sendGet(sb.toString(), userId);
67 public static RestResponse getAllCategoriesTowardsCatalogBe() throws IOException {
69 Config config = Utils.getConfig();
70 String url = String.format(Urls.GET_ALL_CATEGORIES, config.getCatalogBeHost(), config.getCatalogBePort(),
71 BaseRestUtils.RESOURCE_COMPONENT_TYPE);
73 return sendGet(url, UserRoleEnum.DESIGNER.getUserId());
76 public static RestResponse getAllCategoriesTowardsCatalogFeWithUuid(String uuid) throws IOException {
78 Config config = Utils.getConfig();
79 String url = String.format(Urls.GET_ALL_CATEGORIES_FE, config.getCatalogFeHost(), config.getCatalogFePort(),
80 BaseRestUtils.RESOURCE_COMPONENT_TYPE);
82 Map<String, String> additionalHeaders = new HashMap<String, String>();
83 additionalHeaders.put(HttpHeaderEnum.X_ECOMP_REQUEST_ID_HEADER.getValue(), uuid);
85 return sendGet(url, UserRoleEnum.DESIGNER.getUserId(), additionalHeaders);