diff options
author | niamhcore <niamh.core@est.tech> | 2021-09-29 16:43:35 +0100 |
---|---|---|
committer | niamhcore <niamh.core@est.tech> | 2021-10-06 10:03:15 +0100 |
commit | fd2e6ddde2c2260951e2dfd5e3fd7f4bd04976e1 (patch) | |
tree | 1ba737d69631d3ab620c90e99964b68d72fd1317 /cps-ncmp-rest/src | |
parent | fdcb36fa9db642df3c47637d32f4e7ac5dd347e8 (diff) |
Changing resource identifier to a query param
*Update dmi operations to build dmi url using query param
Issue-ID: CPS-679
Signed-off-by: niamhcore <niamh.core@est.tech>
Change-Id: I2292507c5057837932f8e21f1a8e80721066b336
Diffstat (limited to 'cps-ncmp-rest/src')
2 files changed, 25 insertions, 18 deletions
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 a4d94cebfd..0a1a6419e7 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 @@ -27,7 +27,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.util.Collection; import javax.validation.Valid; -import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import org.onap.cps.ncmp.api.NetworkCmProxyDataService; import org.onap.cps.ncmp.api.models.DmiPluginRegistration; @@ -167,8 +166,8 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { public ResponseEntity<Object> getResourceDataOperationalForCmHandle(final String cmHandle, final String resourceIdentifier, final String accept, - final @Valid String fields, - final @Min(1) @Valid Integer depth) { + final String fields, + final Integer depth) { final Object responseObject = networkCmProxyDataService.getResourceDataOperationalForCmHandle(cmHandle, resourceIdentifier, accept, @@ -191,8 +190,8 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { public ResponseEntity<Object> getResourceDataRunningForCmHandle(final String cmHandle, final String resourceIdentifier, final String accept, - final @Valid String fields, - final @Min(1) @Valid Integer depth) { + final String fields, + final Integer depth) { final Object responseObject = networkCmProxyDataService.getResourceDataPassThroughRunningForCmHandle(cmHandle, resourceIdentifier, accept, @@ -205,15 +204,15 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { * Create resource data in datastore pass through running * for given cm-handle. * - * @param cmHandle cm handle identifier * @param resourceIdentifier resource identifier + * @param cmHandle cm handle identifier * @param requestBody requestBody * @param contentType content type of body * @return {@code ResponseEntity} response from dmi plugi */ @Override - public ResponseEntity<Void> createResourceDataRunningForCmHandle(final String cmHandle, - final String resourceIdentifier, + public ResponseEntity<Void> createResourceDataRunningForCmHandle(final String resourceIdentifier, + final String cmHandle, final String requestBody, final String contentType) { networkCmProxyDataService.createResourceDataPassThroughRunningForCmHandle(cmHandle, 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 9f2b4e19a3..d62ae93b09 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 @@ -193,7 +193,7 @@ class NetworkCmProxyControllerSpec extends Specification { def 'Get Resource Data from pass-through operational.' () { given: 'resource data url' def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-operational" + - "/testResourceIdentifier?fields=testFields&depth=5" + "?resourceIdentifier=parent/child&fields=testFields&depth=5" when: 'get data resource request is performed' def response = mvc.perform( get(getUrl) @@ -202,7 +202,7 @@ class NetworkCmProxyControllerSpec extends Specification { ).andReturn().response then: 'the NCMP data service is called with getResourceDataOperationalForCmHandle' 1 * mockNetworkCmProxyDataService.getResourceDataOperationalForCmHandle('testCmHandle', - 'testResourceIdentifier', + 'parent/child', 'application/json', 'testFields', 5) @@ -210,16 +210,16 @@ class NetworkCmProxyControllerSpec extends Specification { response.status == HttpStatus.OK.value() } - def 'Get Resource Data from pass-through running.' () { + def 'Get Resource Data from pass-through running with #scenario value in resource identifier param.' () { given: 'resource data url' def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" + - "/testResourceIdentifier?fields=testFields&depth=5" + "?resourceIdentifier=" + resourceIdentifier + "&fields=testFields&depth=5" and: 'ncmp service returns json object' mockNetworkCmProxyDataService.getResourceDataPassThroughRunningForCmHandle('testCmHandle', - 'testResourceIdentifier', - 'application/json', - 'testFields', - 5) >> '{valid-json}' + resourceIdentifier, + 'application/json', + 'testFields', + 5) >> '{valid-json}' when: 'get data resource request is performed' def response = mvc.perform( get(getUrl) @@ -230,12 +230,20 @@ class NetworkCmProxyControllerSpec extends Specification { response.status == HttpStatus.OK.value() and: 'response contains valid object body' response.getContentAsString() == '{valid-json}' + where: 'tokens are used in the resource identifier parameter' + scenario | resourceIdentifier + '/' | 'id/with/slashes' + '?' | 'idWith?' + ',' | 'idWith,' + '=' | 'idWith=' + '[]' | 'idWith[]' + '? needs to be encoded as %3F' | 'idWith%3F' } def 'Create Resource Data from pass-through running with #scenario.' () { given: 'resource data url' def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" + - "/testResourceIdentifier" + "?resourceIdentifier=parent/child" when: 'get data resource request is performed' def response = mvc.perform( post(getUrl) @@ -244,7 +252,7 @@ class NetworkCmProxyControllerSpec extends Specification { ).andReturn().response then: 'ncmp service method to create resource called' 1 * mockNetworkCmProxyDataService.createResourceDataPassThroughRunningForCmHandle('testCmHandle', - 'testResourceIdentifier', requestBody, 'application/json;charset=UTF-8') + 'parent/child', requestBody, 'application/json;charset=UTF-8') and: 'resource is created' response.status == HttpStatus.CREATED.value() where: 'given request body' |