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;
25 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
26 import org.openecomp.sdc.be.model.CapReqDef;
27 import org.openecomp.sdc.be.model.User;
28 import org.openecomp.sdc.ci.tests.api.Urls;
29 import org.openecomp.sdc.ci.tests.config.Config;
30 import org.openecomp.sdc.ci.tests.datatypes.ComponentReqDetails;
31 import org.openecomp.sdc.ci.tests.datatypes.ProductReqDetails;
32 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
33 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
34 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
35 import org.openecomp.sdc.ci.tests.utils.Utils;
37 public class ComponentRestUtils extends BaseRestUtils {
38 public static RestResponse getComponentRequirmentsCapabilities(User sdncModifierDetails,
39 ComponentReqDetails componentReqDetails) throws IOException {
40 Config config = Utils.getConfig();
41 ComponentTypeEnum componentType = null;
42 if (componentReqDetails instanceof ResourceReqDetails) {
43 componentType = ComponentTypeEnum.RESOURCE;
44 } else if (componentReqDetails instanceof ServiceReqDetails) {
45 componentType = ComponentTypeEnum.SERVICE;
46 } else if (componentReqDetails instanceof ProductReqDetails) {
47 componentType = ComponentTypeEnum.PRODUCT;
49 String url = String.format(Urls.GET_COMPONENT_REQUIRMENTS_CAPABILITIES, config.getCatalogBeHost(),
50 config.getCatalogBePort(), ComponentTypeEnum.findParamByType(componentType),
51 componentReqDetails.getUniqueId());
52 return sendGet(url, sdncModifierDetails.getUserId());
55 public static CapReqDef getAndParseComponentRequirmentsCapabilities(User user, ComponentReqDetails componentDetails)
57 RestResponse getComponentReqCap = getComponentRequirmentsCapabilities(user, componentDetails);
58 ResourceRestUtils.checkSuccess(getComponentReqCap);
59 CapReqDef capReqDef = ResponseParser.parseToObject(getComponentReqCap.getResponse(), CapReqDef.class);