aboutsummaryrefslogtreecommitdiffstats
path: root/test-apis-ci/src/main
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2019-03-01 17:50:15 +0530
committerOren Kleks <orenkle@amdocs.com>2019-03-04 10:57:03 +0000
commit1f7c57414533b9886962ede7b19a29669fe7a59a (patch)
tree77bbf8f4f339a8f6a61f96e70ca701e2007a6ee3 /test-apis-ci/src/main
parente0c98681f9fcbae59eab32822784ae95c4768d40 (diff)
Requirement and capabilities feature
1. Enhance Service/VF/PNF to support Req & Cap 2. Added Type fetch APIs to fetch types from global types Change-Id: I2b749ec9da34e488421b8ebe311ccf03c4b7c0fd Issue-ID: SDC-2142 Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
Diffstat (limited to 'test-apis-ci/src/main')
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java12
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/capability/CapabilitiesTest.java119
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CapabilityDetails.java56
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/RequirementDetails.java74
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/requirements/RequirementsTest.java118
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CapabilityRestUtils.java76
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/RequirementsUtils.java75
-rw-r--r--test-apis-ci/src/main/resources/ci/testSuites/cap_req.xml10
8 files changed, 540 insertions, 0 deletions
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java
index ba35ac3d33..1f1c90764b 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/api/Urls.java
@@ -408,4 +408,16 @@ public interface Urls {
final String UPDATE_INTERFACE_OPERATIONS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/interfaceOperations";
final String GET_INTERFACE_OPERATIONS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/interfaces/%s/operations/%s";
final String DELETE_INTERFACE_OPERATIONS = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/interfaces/%s/operations/%s";
+
+ //Requirements
+ String CREATE_REQUIREMENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/requirements";
+ String UPDATE_REQUIREMENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/requirements";
+ String DELETE_REQUIREMENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/requirements/%s";
+ String GET_REQUIREMENT = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/requirements/%s";
+ //Capabilities
+ String CREATE_CAPABILITY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/capabilities";
+ String UPDATE_CAPABILITY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/capabilities";
+ String DELETE_CAPABILITY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/capabilities/%s";
+ String GET_CAPABILITY = SDC_HTTP_METHOD + "://%s:%s/sdc2/rest/v1/catalog/%s/%s/capabilities/%s";
+
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/capability/CapabilitiesTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/capability/CapabilitiesTest.java
new file mode 100644
index 0000000000..ecdb48619b
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/capability/CapabilitiesTest.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.ci.tests.capability;
+
+import org.junit.Rule;
+import org.junit.rules.TestName;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
+import org.openecomp.sdc.ci.tests.datatypes.CapabilityDetails;
+import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
+import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.CapabilityRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.testng.Assert;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils.getServiceObject;
+
+public class CapabilitiesTest extends ComponentBaseTest {
+ @Rule
+ public static final TestName name = new TestName();
+
+ private ServiceReqDetails component;
+ private User user = null;
+
+ public CapabilitiesTest() {
+ super(name, CapabilitiesTest.class.getName());
+ }
+
+ @BeforeTest
+ public void init() throws Exception {
+ user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
+ component = ElementFactory.getDefaultService();
+ component.setName("comp_cap" + Math.random());
+ ServiceRestUtils.createService(component, user);
+ }
+
+ @Test
+ public void createCapabilityTest() throws Exception {
+
+ CapabilityDetails capability = createCapability();
+ RestResponse restResponse = CapabilityRestUtils.createCapability(component.getUniqueId(),
+ Collections.singletonList(capability), user);
+ logger.info("createCapability Response Code:" + restResponse.getErrorCode());
+ Assert.assertEquals((int) restResponse.getErrorCode(), BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+
+
+ @Test(dependsOnMethods = "createCapabilityTest")
+ public void updateCapabilityTest() throws Exception {
+
+ CapabilityDetails capability = createCapability();
+ capability.setMaxOccurrences("10");
+ capability.setMinOccurrences("4");
+ RestResponse restResponse = CapabilityRestUtils.updateCapability(component.getUniqueId(),
+ Collections.singletonList(capability), user);
+ logger.info("updateCapability Response Code:" + restResponse.getErrorCode());
+ Assert.assertEquals((int) restResponse.getErrorCode(), BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ @Test(dependsOnMethods = "updateCapabilityTest")
+ public void getCapabilityTest() throws Exception {
+ Service service = getServiceObject(component.getUniqueId());
+
+ List<org.openecomp.sdc.be.model.CapabilityDefinition> capabilityDefinitionList = service.getCapabilities().values()
+ .stream().flatMap(Collection::stream).collect(Collectors.toList());
+
+ RestResponse restResponse = CapabilityRestUtils.getCapability(component.getUniqueId(),
+ capabilityDefinitionList.get(0).getUniqueId(), user);
+ logger.info("getCapabilityTest Response Code:" + restResponse.getErrorCode());
+ Assert.assertEquals((int) restResponse.getErrorCode(), BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ @Test(dependsOnMethods = "getCapabilityTest")
+ public void deleteCapabilityTest() throws Exception {
+ Service service = getServiceObject(component.getUniqueId());
+
+ List<org.openecomp.sdc.be.model.CapabilityDefinition> capabilityDefinitionList = service.getCapabilities().values()
+ .stream().flatMap(Collection::stream).collect(Collectors.toList());
+
+ RestResponse restResponse = CapabilityRestUtils.deleteCapability(component.getUniqueId(),
+ capabilityDefinitionList.get(0).getUniqueId(), user);
+ logger.info("deleteCapabilityTest Response Code:" + restResponse.getErrorCode());
+ Assert.assertEquals((int) restResponse.getErrorCode(), BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ private CapabilityDetails createCapability() {
+ CapabilityDetails capabilityDetails = new CapabilityDetails();
+ capabilityDetails.setName("cap" + Math.random());
+ capabilityDetails.setType("tosca.capabilities.network.Bindable");
+
+ return capabilityDetails;
+ }
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CapabilityDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CapabilityDetails.java
new file mode 100644
index 0000000000..954a16a63d
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/CapabilityDetails.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.ci.tests.datatypes;
+
+public class CapabilityDetails {
+ private String name;
+ private String type;
+ private String maxOccurrences;
+ private String minOccurrences;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getMaxOccurrences() {
+ return maxOccurrences;
+ }
+
+ public void setMaxOccurrences(String maxOccurrences) {
+ this.maxOccurrences = maxOccurrences;
+ }
+
+ public String getMinOccurrences() {
+ return minOccurrences;
+ }
+
+ public void setMinOccurrences(String minOccurrences) {
+ this.minOccurrences = minOccurrences;
+ }
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/RequirementDetails.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/RequirementDetails.java
new file mode 100644
index 0000000000..a720786d83
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/RequirementDetails.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.ci.tests.datatypes;
+
+public class RequirementDetails {
+ private String capability;
+ private String name;
+ private String node;
+ private String relationship;
+ private String maxOccurrences;
+ private String minOccurrences;
+
+ public String getCapability() {
+ return capability;
+ }
+
+ public void setCapability(String capability) {
+ this.capability = capability;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getNode() {
+ return node;
+ }
+
+ public void setNode(String node) {
+ this.node = node;
+ }
+
+ public String getRelationship() {
+ return relationship;
+ }
+
+ public void setRelationship(String relationship) {
+ this.relationship = relationship;
+ }
+
+ public String getMaxOccurrences() {
+ return maxOccurrences;
+ }
+
+ public void setMaxOccurrences(String maxOccurrences) {
+ this.maxOccurrences = maxOccurrences;
+ }
+
+ public String getMinOccurrences() {
+ return minOccurrences;
+ }
+
+ public void setMinOccurrences(String minOccurrences) {
+ this.minOccurrences = minOccurrences;
+ }
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/requirements/RequirementsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/requirements/RequirementsTest.java
new file mode 100644
index 0000000000..51894e7ec1
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/requirements/RequirementsTest.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.ci.tests.requirements;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+import org.openecomp.sdc.be.model.RequirementDefinition;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
+import org.openecomp.sdc.ci.tests.datatypes.RequirementDetails;
+import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
+import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.RequirementsUtils;
+import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils.getServiceObject;
+
+public class RequirementsTest extends ComponentBaseTest {
+ @Rule
+ public static final TestName name = new TestName();
+
+ private ServiceReqDetails component;
+ private User user = null;
+
+ public RequirementsTest() {
+ super(name, RequirementsTest.class.getName());
+ }
+
+ @BeforeTest
+ public void init() throws Exception {
+ user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
+ component = ElementFactory.getDefaultService();
+ component.setName("comp_req" + Math.random());
+ ServiceRestUtils.createService(component, user);
+ }
+
+ @Test
+ public void createRequirementTest() throws Exception {
+
+ RequirementDetails requirement = createRequirement();
+ RestResponse restResponse = RequirementsUtils.createRequirement(component.getUniqueId(),
+ Collections.singletonList(requirement), user);
+ logger.info("createRequirement Response Code:" + restResponse.getErrorCode());
+ Assert.assertEquals((int) restResponse.getErrorCode(), BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ @Test(dependsOnMethods = "createRequirementTest")
+ public void updateRequirementTest() throws Exception {
+
+ RequirementDetails requirement = createRequirement();
+ requirement.setMaxOccurrences("10");
+ requirement.setMinOccurrences("4");
+ RestResponse restResponse = RequirementsUtils.updateRequirement(component.getUniqueId(),
+ Collections.singletonList(requirement), user);
+ logger.info("updateRequirement Response Code:" + restResponse.getErrorCode());
+ Assert.assertEquals((int) restResponse.getErrorCode(), BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ @Test(dependsOnMethods = "updateRequirementTest")
+ public void getRequirementTest() throws Exception {
+ Service service = getServiceObject(component.getUniqueId());
+
+ List<RequirementDefinition> requirementDefinitionList = service.getRequirements().values()
+ .stream().flatMap(Collection::stream).collect(Collectors.toList());
+
+ RestResponse restResponse = RequirementsUtils.getRequirement(component.getUniqueId(),
+ requirementDefinitionList.get(0).getUniqueId(), user);
+ logger.info("getRequirementTest Response Code:" + restResponse.getErrorCode());
+ Assert.assertEquals((int) restResponse.getErrorCode(), BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ @Test(dependsOnMethods = "getRequirementTest")
+ public void deleteRequirementTest() throws Exception {
+ Service service = getServiceObject(component.getUniqueId());
+
+ List<RequirementDefinition> requirementDefinitionList = service.getRequirements().values()
+ .stream().flatMap(Collection::stream).collect(Collectors.toList());
+
+ RestResponse restResponse = RequirementsUtils.deleteRequirement(component.getUniqueId(),
+ requirementDefinitionList.get(0).getUniqueId(), user);
+ logger.info("deleteRequirementTest Response Code:" + restResponse.getErrorCode());
+ Assert.assertEquals((int) restResponse.getErrorCode(), BaseRestUtils.STATUS_CODE_SUCCESS);
+ }
+
+ private RequirementDetails createRequirement() {
+ RequirementDetails requirementDetails = new RequirementDetails();
+ requirementDetails.setName("req" + Math.random());
+ requirementDetails.setCapability("tosca.capabilities.network.Bindable");
+
+ return requirementDetails;
+ }
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CapabilityRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CapabilityRestUtils.java
new file mode 100644
index 0000000000..1959aa8b9a
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CapabilityRestUtils.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.ci.tests.utils.rest;
+
+import com.google.gson.Gson;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.ci.tests.api.Urls;
+import org.openecomp.sdc.ci.tests.config.Config;
+import org.openecomp.sdc.ci.tests.datatypes.CapabilityDetails;
+import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+
+import java.util.List;
+
+public class CapabilityRestUtils extends BaseRestUtils {
+ private static Gson gson = new Gson();
+ private static final String COMPONENT_TYPE = "services";
+
+ public static RestResponse createCapability(String componentId,
+ List<CapabilityDetails> capabilityDetailsList,
+ User user) throws Exception{
+ Config config = Config.instance();
+ String url = String.format(Urls.CREATE_CAPABILITY, config.getCatalogBeHost(), config.getCatalogBePort(),
+ COMPONENT_TYPE, componentId);
+
+ String data = "{ \"capabilities\" : {" + "\"" +capabilityDetailsList.get(0).getType()+ "\"" +" : "
+ + gson.toJson(capabilityDetailsList) + " } }";
+
+ return sendPost(url, data , user.getUserId(), acceptHeaderData);
+ }
+
+ public static RestResponse updateCapability(String componentId,
+ List<CapabilityDetails> capabilityDetailsList,
+ User user) throws Exception{
+ Config config = Config.instance();
+ String url = String.format(Urls.UPDATE_CAPABILITY, config.getCatalogBeHost(), config.getCatalogBePort(),
+ COMPONENT_TYPE, componentId);
+
+ String data = "{ \"capabilities\" : {" + "\"" +capabilityDetailsList.get(0).getType()+ "\"" +" : "
+ + gson.toJson(capabilityDetailsList) + " } }";
+
+ return sendPost(url, data , user.getUserId(), acceptHeaderData);
+ }
+
+ public static RestResponse deleteCapability(String componentId,
+ String requirementId,
+ User user) throws Exception{
+ Config config = Config.instance();
+ String url = String.format(Urls.DELETE_CAPABILITY, config.getCatalogBeHost(), config.getCatalogBePort(),
+ COMPONENT_TYPE, componentId, requirementId);
+ return sendDelete(url, user.getUserId());
+ }
+
+ public static RestResponse getCapability(String componentId,
+ String requirementId,
+ User user) throws Exception{
+ Config config = Config.instance();
+ String url = String.format(Urls.GET_CAPABILITY, config.getCatalogBeHost(), config.getCatalogBePort(),
+ COMPONENT_TYPE, componentId, requirementId);
+ return sendDelete(url, user.getUserId());
+ }
+
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/RequirementsUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/RequirementsUtils.java
new file mode 100644
index 0000000000..4be1d941ce
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/RequirementsUtils.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.ci.tests.utils.rest;
+
+import com.google.gson.Gson;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.ci.tests.api.Urls;
+import org.openecomp.sdc.ci.tests.config.Config;
+import org.openecomp.sdc.ci.tests.datatypes.RequirementDetails;
+import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+
+import java.util.List;
+
+public class RequirementsUtils extends BaseRestUtils {
+ private static Gson gson = new Gson();
+ private static final String COMPONENT_TYPE = "services";
+
+ public static RestResponse createRequirement(String componentId,
+ List<RequirementDetails> requirementDefinitionList,
+ User user) throws Exception{
+ Config config = Config.instance();
+ String url = String.format(Urls.CREATE_REQUIREMENT, config.getCatalogBeHost(), config.getCatalogBePort(),
+ COMPONENT_TYPE, componentId);
+
+ String data = "{ \"requirements\" : {" + "\"" +requirementDefinitionList.get(0).getCapability()+ "\"" +" : "
+ + gson.toJson(requirementDefinitionList) + " } }";
+
+ return sendPost(url, data , user.getUserId(), acceptHeaderData);
+ }
+
+ public static RestResponse updateRequirement(String componentId,
+ List<RequirementDetails> requirementDefinitionList,
+ User user) throws Exception{
+ Config config = Config.instance();
+ String url = String.format(Urls.UPDATE_REQUIREMENT, config.getCatalogBeHost(), config.getCatalogBePort(),
+ COMPONENT_TYPE, componentId);
+
+ String data = "{ \"requirements\" : {" + "\"" +requirementDefinitionList.get(0).getCapability()+ "\"" +" : "
+ + gson.toJson(requirementDefinitionList) + " } }";
+
+ return sendPost(url, data , user.getUserId(), acceptHeaderData);
+ }
+
+ public static RestResponse deleteRequirement(String componentId,
+ String requirementId,
+ User user) throws Exception{
+ Config config = Config.instance();
+ String url = String.format(Urls.DELETE_REQUIREMENT, config.getCatalogBeHost(), config.getCatalogBePort(),
+ COMPONENT_TYPE, componentId, requirementId);
+ return sendDelete(url, user.getUserId());
+ }
+
+ public static RestResponse getRequirement(String componentId,
+ String requirementId,
+ User user) throws Exception{
+ Config config = Config.instance();
+ String url = String.format(Urls.GET_REQUIREMENT, config.getCatalogBeHost(), config.getCatalogBePort(),
+ COMPONENT_TYPE, componentId, requirementId);
+ return sendDelete(url, user.getUserId());
+ }
+}
diff --git a/test-apis-ci/src/main/resources/ci/testSuites/cap_req.xml b/test-apis-ci/src/main/resources/ci/testSuites/cap_req.xml
new file mode 100644
index 0000000000..8298af2da5
--- /dev/null
+++ b/test-apis-ci/src/main/resources/ci/testSuites/cap_req.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="Cap_Req" >
+ <test name="Cap_Req">
+ <classes>
+ <class name="org.openecomp.sdc.ci.tests.requirements.RequirementsTest"/>
+ <class name="org.openecomp.sdc.ci.tests.capability.CapabilitiesTest"/>
+ </classes>
+ </test>
+</suite> <!-- Artifacts -->