From c584bf2729bb6eb9229aad9dbacc65beaa5dbc2f Mon Sep 17 00:00:00 2001 From: tragait Date: Fri, 20 Aug 2021 15:45:58 +0100 Subject: Post impl for passthrough running (Ncmp impl.) Issue-ID: CPS-577 Signed-off-by: tragait Change-Id: Ic8983349cf88fb123feb95ce01ec6fdf670469f4 --- .../rest/controller/NetworkCmProxyController.java | 20 ++++++++++++++++++++ .../controller/NetworkCmProxyControllerSpec.groovy | 17 +++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'cps-ncmp-rest/src') 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 587787e2d..d4e842a35 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 @@ -200,6 +200,26 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { return ResponseEntity.ok(responseObject); } + /** + * Create resource data in datastore pass through running + * for given cm-handle. + * + * @param cmHandle cm handle identifier + * @param resourceIdentifier resource identifier + * @param requestBody requestBody + * @param contentType content type of body + * @return {@code ResponseEntity} response from dmi plugi + */ + @Override + public ResponseEntity createResourceDataRunningForCmHandle(final String cmHandle, + final String resourceIdentifier, + final Object requestBody, + final String contentType) { + networkCmProxyDataService.createResourceDataPassThroughRunningForCmHandle(cmHandle, + resourceIdentifier, requestBody, contentType); + return new ResponseEntity<>(HttpStatus.CREATED); + } + private DmiPluginRegistration convertRestObjectToJavaApiObject( final RestDmiPluginRegistration restDmiPluginRegistration) { return objectMapper.convertValue(restDmiPluginRegistration, DmiPluginRegistration.class); diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy index a7fa30901..1a2d3a204 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy @@ -237,5 +237,22 @@ class NetworkCmProxyControllerSpec extends Specification { and: 'response contains valid object body' response.getContentAsString() == '{valid-json}' } + + def 'Create Resource Data from pass-through running using POST.' () { + given: 'resource data url' + def getUrl = "$basePath/v1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" + + "/testResourceIdentifier" + when: 'get data resource request is performed' + def response = mvc.perform( + post(getUrl) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .accept(MediaType.APPLICATION_JSON_VALUE).content('{"some-json":"value"}') + ).andReturn().response + then: 'ncmp service method to create resource called' + 1 * mockNetworkCmProxyDataService.createResourceDataPassThroughRunningForCmHandle('testCmHandle', + 'testResourceIdentifier', ['some-json':'value'], 'application/json;charset=UTF-8') + and: 'resource is created' + response.status == HttpStatus.CREATED.value() + } } -- cgit 1.2.3-korg