diff options
author | niamhcore <niamh.core@est.tech> | 2021-09-07 10:27:18 +0100 |
---|---|---|
committer | niamhcore <niamh.core@est.tech> | 2021-09-07 16:39:34 +0100 |
commit | c309f24909510ebd11737efc3eadb055c91e304e (patch) | |
tree | b32da09e7af35aad888da8686660285ab791bc61 /cps-ncmp-rest/src | |
parent | d0422226b45f752086c9920bdead753c644d9289 (diff) |
P2 - Get module names and revisions rest layer
Issue-ID: CPS-485
Signed-off-by: niamhcore <niamh.core@est.tech>
Change-Id: I1bcf45902207d0dba6b5dfe8277cb06571694db3
Diffstat (limited to 'cps-ncmp-rest/src')
2 files changed, 24 insertions, 0 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 f5ffdbeb92..b78241662e 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 @@ -35,6 +35,7 @@ import org.onap.cps.ncmp.rest.api.NetworkCmProxyApi; import org.onap.cps.ncmp.rest.model.RestDmiPluginRegistration; import org.onap.cps.spi.FetchDescendantsOption; import org.onap.cps.spi.model.DataNode; +import org.onap.cps.spi.model.ModuleReference; import org.onap.cps.utils.DataMapUtils; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -220,6 +221,13 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { return new ResponseEntity<>(HttpStatus.CREATED); } + @Override + public ResponseEntity<Object> getModuleReferencesByCmHandle(final String cmHandle) { + final Collection<ModuleReference> + moduleReferences = networkCmProxyDataService.getYangResourcesModuleReferences(cmHandle); + return new ResponseEntity<>(new Gson().toJson(moduleReferences), HttpStatus.OK); + } + 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 73ccd6e3c2..613243e28b 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 @@ -22,6 +22,8 @@ package org.onap.cps.ncmp.rest.controller +import org.onap.cps.spi.model.ModuleReference + import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get @@ -246,5 +248,19 @@ class NetworkCmProxyControllerSpec extends Specification { and: 'resource is created' response.status == HttpStatus.CREATED.value() } + + def 'Get module references for the given dataspace and cm handle.' () { + given: 'get module references url' + def getUrl = "$ncmpBasePathV1/ch/some-cmhandle/modules" + when: 'get module resource request is performed' + def response =mvc.perform(get(getUrl)).andReturn().response + then: 'ncmp service method to get yang resource module references is called' + mockNetworkCmProxyDataService.getYangResourcesModuleReferences('some-cmhandle') + >> [new ModuleReference(moduleName: 'some-name1',revision: 'some-revision1')] + and: 'response contains an array with the module name and revision' + response.getContentAsString() == '[{"moduleName":"some-name1","revision":"some-revision1"}]' + and: 'response returns an OK http code' + response.status == HttpStatus.OK.value() + } } |