aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-ncmp-rest/docs/openapi/components.yaml44
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmp.yml4
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java4
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java3
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java4
-rw-r--r--csit/data/bookstorePatchExample.json59
-rw-r--r--csit/tests/ncmp-passthrough/ncmp-passthrough.robot21
7 files changed, 132 insertions, 7 deletions
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml
index d9bd49a097..e63f9c0b84 100644
--- a/cps-ncmp-rest/docs/openapi/components.yaml
+++ b/cps-ncmp-rest/docs/openapi/components.yaml
@@ -151,6 +151,50 @@ components:
- authors:
- Philip Pullman
+ dataSamplePatchRequest:
+ summary: Sample patch request
+ description: Sample patch request body
+ value:
+ ietf-restconf:yang-patch:
+ patch-id: patch-1
+ edit:
+ - edit-id: edit1
+ operation: merge
+ target: /
+ value:
+ test:bookstore:
+ bookstore-name: Chapters
+ categories:
+ - code: '01'
+ name: Science
+ books:
+ - authors:
+ - Author1
+ - Author2
+ - code: '02'
+ name: Arts
+ books:
+ - authors:
+ - Author3
+ - edit-id: edit2
+ operation: merge
+ target: /
+ value:
+ test:bookstore:
+ bookstore-name: Novels
+ categories:
+ - code: '03'
+ name: History
+ books:
+ - authors:
+ - Iain M. Banks
+ - Ursula K. Le Guin
+ - code: '04'
+ name: Fiction
+ books:
+ - authors:
+ - Philip Pullman
+
dataSampleResponse:
summary: Sample response
description: Sample response for selecting 'sample 1'.
diff --git a/cps-ncmp-rest/docs/openapi/ncmp.yml b/cps-ncmp-rest/docs/openapi/ncmp.yml
index 71b4f1c453..d80ec6508e 100755
--- a/cps-ncmp-rest/docs/openapi/ncmp.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmp.yml
@@ -165,12 +165,12 @@ resourceDataForPassthroughRunning:
requestBody:
required: true
content:
- application/json:
+ '*/*':
schema:
type: object
examples:
dataSampleRequest:
- $ref: 'components.yaml#/components/examples/dataSampleRequest'
+ $ref: 'components.yaml#/components/examples/dataSamplePatchRequest'
responses:
200:
$ref: 'components.yaml#/components/responses/Ok'
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index a97852fe2b..f2f43c9897 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -118,9 +118,9 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
public ResponseEntity<Object> patchResourceDataRunningForCmHandle(final String resourceIdentifier,
final String cmHandle,
final Object requestBody, final String contentType) {
- networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
+ final Object responseObject = networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
resourceIdentifier, PATCH, GSON.toJson(requestBody), contentType);
- return new ResponseEntity<>(HttpStatus.OK);
+ return ResponseEntity.ok(responseObject);
}
/**
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
index dddf089107..5d2ab53394 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
@@ -78,8 +78,9 @@ public interface NetworkCmProxyDataService {
* @param operation required operation
* @param requestBody request body to create resource
* @param contentType content type in body
+ * @return {@code Object} return data
*/
- void writeResourceDataPassThroughRunningForCmHandle(String cmHandle,
+ Object writeResourceDataPassThroughRunningForCmHandle(String cmHandle,
String resourceIdentifier,
OperationEnum operation,
String requestBody,
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index eeb004ad51..240d6b5ca9 100755
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
@@ -142,12 +142,12 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
}
@Override
- public void writeResourceDataPassThroughRunningForCmHandle(final String cmHandle,
+ public Object writeResourceDataPassThroughRunningForCmHandle(final String cmHandle,
final String resourceIdentifier,
final OperationEnum operation,
final String requestData,
final String dataType) {
- handleResponse(
+ return handleResponse(
dmiDataOperations.writeResourceDataPassThroughRunningFromDmi(
cmHandle, resourceIdentifier, operation, requestData, dataType),
"Not able to " + operation + " resource data.");
diff --git a/csit/data/bookstorePatchExample.json b/csit/data/bookstorePatchExample.json
new file mode 100644
index 0000000000..039ea4bcdd
--- /dev/null
+++ b/csit/data/bookstorePatchExample.json
@@ -0,0 +1,59 @@
+{
+ "ietf-restconf:yang-patch":{
+ "patch-id":"patch-1",
+ "edit":[
+ {
+ "edit-id":"edit1",
+ "operation":"merge",
+ "target":"/",
+ "value":{
+ "bookstore": {
+ "categories": [
+ {
+ "code": "100",
+ "books": [
+ {
+ "title": "A new book in a new category",
+ "pub_year": "2019",
+ "authors": [
+ "Rahul"
+ ],
+ "lang": "English",
+ "price": "2011"
+ }
+ ],
+ "name": "Category100"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "edit-id":"edit2",
+ "operation":"merge",
+ "target":"/",
+ "value":{
+ "bookstore": {
+ "categories": [
+ {
+ "code": "02",
+ "name": "Horror",
+ "books": [
+ {
+ "title": "A New book in existing category",
+ "lang": "English",
+ "authors": [
+ "Joe & Rahul"
+ ],
+ "pub_year": "2003",
+ "price": "2000"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/csit/tests/ncmp-passthrough/ncmp-passthrough.robot b/csit/tests/ncmp-passthrough/ncmp-passthrough.robot
index 36350ad525..1d977b9d92 100644
--- a/csit/tests/ncmp-passthrough/ncmp-passthrough.robot
+++ b/csit/tests/ncmp-passthrough/ncmp-passthrough.robot
@@ -116,3 +116,24 @@ Verify delete to bookstore using passthrough-running removed only category 01
Should Be Equal As Strings "${item['name']}" "Horror"
END
END
+
+Patch will add new category with new book and add a new book to an existing category
+ ${uri}= Set Variable ${ncmpBasePath}/v1/ch/PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore
+ ${headers}= Create Dictionary Content-Type=application/yang.patch+json Authorization=${auth}
+ ${jsonData}= Get Binary File ${DATADIR}${/}bookstorePatchExample.json
+ ${response}= PATCH On Session CPS_URL ${uri} headers=${headers} data=${jsonData}
+ Should Be Equal As Strings ${response.status_code} 200
+ ${verifyUri}= Set Variable ${ncmpBasePath}/v1/ch/PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=100
+ ${verifyHeaders}= Create Dictionary Authorization=${auth}
+ ${verifyResponse}= Get On Session CPS_URL ${verifyUri} headers=${verifyHeaders}
+ ${responseJson}= Set Variable ${verifyResponse.json()}
+ Should Be Equal As Strings ${verifyResponse.status_code} 200
+ FOR ${item} IN @{responseJson['stores:categories']}
+ IF "${item['code']}" == "100"
+ Should Be Equal As Strings "${item['name']}" "Category100"
+ END
+ END
+ ${verifyUri}= Set Variable ${ncmpBasePath}/v1/ch/PNFDemo/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=stores:bookstore/categories=02/books=A%20New%20book%20in%20existing%20category
+ ${verifyResponse}= Get On Session CPS_URL ${verifyUri} headers=${verifyHeaders}
+ ${responseJson}= Set Variable ${verifyResponse.json()}
+ Should Be Equal As Strings ${verifyResponse.status_code} 200 \ No newline at end of file