aboutsummaryrefslogtreecommitdiffstats
path: root/cps-tbdmt-service/src/test/java
diff options
context:
space:
mode:
authorNiranjana <niranjana.y60@wipro.com>2021-08-12 04:16:00 +0000
committerNiranjana Y <niranjana.y60@wipro.com>2021-08-12 04:40:01 +0000
commit433ba106cf99762039b7bd6a430eaf24b45d2271 (patch)
tree7535dbeb9643a4ab61e4387ad2fe2a070f257258 /cps-tbdmt-service/src/test/java
parent3e5957464b6b4fa18bcae18bcfdce5fc9bace787 (diff)
Support edit query
Issue-ID: CPS-511 Signed-off-by: Niranjana <niranjana.y60@wipro.com> Change-Id: Icc22fb6143c01dcc388339ffa57818f41ed50cfd
Diffstat (limited to 'cps-tbdmt-service/src/test/java')
-rw-r--r--cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/client/CpsRestClientTest.java34
-rw-r--r--cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/ExecutionBusinessLogicTest.java3
2 files changed, 36 insertions, 1 deletions
diff --git a/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/client/CpsRestClientTest.java b/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/client/CpsRestClientTest.java
index 6e0ae4b..4697479 100644
--- a/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/client/CpsRestClientTest.java
+++ b/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/client/CpsRestClientTest.java
@@ -22,6 +22,8 @@ package org.onap.cps.tbdmt.client;
import static org.junit.Assert.assertEquals;
+import java.util.HashMap;
+import java.util.Map;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -130,4 +132,36 @@ public class CpsRestClientTest {
cpsRestClient.fetchNode("coverage-area-onap", "sample", "get", true);
}
+ @Test
+ public void testAddDataForPostRequest() throws Exception {
+ final String uri = "http://localhost:8000/anchors/coverage-area-onap/nodes";
+ Mockito.when(restTemplate.postForEntity(ArgumentMatchers.eq(uri), ArgumentMatchers.any(),
+ ArgumentMatchers.<Class<String>>any())).thenReturn(response);
+ final Map<String, Object> payload = new HashMap<String, Object>();
+ payload.put("idNearRTRIC", 11);
+ assertEquals("sample response", cpsRestClient.addData("coverage-area-onap", "NearRTRIC", "post", payload));
+
+ }
+
+ @Test
+ public void testAddDataForPutRequest() throws Exception {
+ final String uri = "http://localhost:8000/anchors/coverage-area-onap/nodes?xpath=NearRTRIC";
+ Mockito.when(restTemplate.exchange(ArgumentMatchers.eq(uri), ArgumentMatchers.any(HttpMethod.class),
+ ArgumentMatchers.any(), ArgumentMatchers.<Class<String>>any())).thenReturn(response);
+ final Map<String, Object> payload = new HashMap<String, Object>();
+ payload.put("idNearRTRIC", 11);
+ assertEquals("sample response", cpsRestClient.addData("coverage-area-onap", "NearRTRIC", "put", payload));
+
+ }
+
+ @Test
+ public void testAddDataForPatchRequest() throws Exception {
+ final String uri = "http://localhost:8000/anchors/coverage-area-onap/nodes?xpath=NearRTRIC";
+ Mockito.when(restTemplate.patchForObject(ArgumentMatchers.eq(uri), ArgumentMatchers.any(),
+ ArgumentMatchers.<Class<String>>any())).thenReturn("sample response");
+ final Map<String, Object> payload = new HashMap<String, Object>();
+ payload.put("idNearRTRIC", 11);
+ assertEquals("sample response", cpsRestClient.addData("coverage-area-onap", "NearRTRIC", "patch", payload));
+
+ }
}
diff --git a/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/ExecutionBusinessLogicTest.java b/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/ExecutionBusinessLogicTest.java
index e8689a9..60f0050 100644
--- a/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/ExecutionBusinessLogicTest.java
+++ b/cps-tbdmt-service/src/test/java/org/onap/cps/tbdmt/service/ExecutionBusinessLogicTest.java
@@ -91,8 +91,9 @@ public class ExecutionBusinessLogicTest {
@Before
public void setup() {
final Map<String, String> input = new HashMap<>();
+ final Map<String, Object> payload = new HashMap<>();
input.put("coverageArea", "Zone 1");
- request = new ExecutionRequest(input);
+ request = new ExecutionRequest(input, payload);
final String xpathTemplate = "/ran-coverage-area/pLMNIdList[@mcc='310' and @mnc='410']"
+ "/coverage-area[@coverageArea='{{coverageArea}}']";
template = new Template("getNbr", "ran-network", xpathTemplate, "get", true, "", "");