summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service
diff options
context:
space:
mode:
authorniamhcore <niamh.core@est.tech>2021-09-07 10:27:18 +0100
committerniamhcore <niamh.core@est.tech>2021-09-07 16:39:34 +0100
commitc309f24909510ebd11737efc3eadb055c91e304e (patch)
treeb32da09e7af35aad888da8686660285ab791bc61 /cps-ncmp-service
parentd0422226b45f752086c9920bdead753c644d9289 (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-service')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java9
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java7
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy2
3 files changed, 16 insertions, 2 deletions
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 0693f61e44..60669b9169 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
@@ -28,6 +28,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import org.onap.cps.ncmp.api.models.DmiPluginRegistration;
import org.onap.cps.spi.FetchDescendantsOption;
import org.onap.cps.spi.model.DataNode;
+import org.onap.cps.spi.model.ModuleReference;
/*
* Datastore interface for handling CPS data.
@@ -154,4 +155,12 @@ public interface NetworkCmProxyDataService {
@NotNull String resourceIdentifier,
@NotNull Object requestBody,
String contentType);
+
+ /**
+ * Retrieve module references for the given cm handle.
+ *
+ * @param cmHandle cm handle
+ * @return a collection of modules names and revisions
+ */
+ Collection<ModuleReference> getYangResourcesModuleReferences(@NotNull String cmHandle);
}
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 6e1e7275bb..871d8806bf 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
@@ -223,6 +223,11 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
handleResponseForPost(responseEntity);
}
+ @Override
+ public Collection<ModuleReference> getYangResourcesModuleReferences(final String cmHandle) {
+ return cpsModuleService.getYangResourcesModuleReferences(NF_PROXY_DATASPACE_NAME, cmHandle);
+ }
+
private DataNode fetchDataNodeFromDmiRegistryForCmHandle(final String cmHandle) {
final String xpathForDmiRegistryToFetchCmHandle = "/dmi-registry/cm-handles[@id='" + cmHandle + "']";
return cpsDataService.getDataNode(NCMP_DATASPACE_NAME,
@@ -352,7 +357,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
final List<ModuleReference> moduleReferencesFromDmiForCmHandle =
getModuleReferences(modulesForCmHandle);
final var knownModuleReferencesInCps =
- cpsModuleService.getAllYangResourceModuleReferences(NF_PROXY_DATASPACE_NAME);
+ cpsModuleService.getYangResourceModuleReferences(NF_PROXY_DATASPACE_NAME);
final List<ModuleReference> existingModuleReferences = new ArrayList<>();
for (final ModuleReference moduleReferenceFromDmiForCmHandle :
moduleReferencesFromDmiForCmHandle) {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
index ff3e0cd157..e945442250 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
@@ -360,7 +360,7 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
def knownModule1 = new ModuleReference('module1', '1')
def knownOtherModule = new ModuleReference('some other module', 'some revision')
and: 'CPS-Core returns list of known modules'
- mockCpsModuleService.getAllYangResourceModuleReferences(_) >> [knownModule1, knownOtherModule]
+ mockCpsModuleService.getYangResourceModuleReferences(_) >> [knownModule1, knownOtherModule]
and: 'DMI-Plugin returns resource(s) for "new" module(s)'
def moduleResources = new ResponseEntity<String>(sdncReponseBody, HttpStatus.OK)
mockDmiOperations.getResourceFromDmi(_, cmHandleForModelSync.getId(), 'moduleResources') >> moduleResources