summaryrefslogtreecommitdiffstats
path: root/cps-service/src
diff options
context:
space:
mode:
authorshivasubedi <shiva.subedi@est.tech>2021-08-04 12:13:36 +0100
committershivasubedi <shiva.subedi@est.tech>2021-08-05 17:19:22 +0100
commitdce1d58005d90950e00b22078d82559748dcb255 (patch)
tree5db973dcd04d1f0d28b6dca3e807affac093c520 /cps-service/src
parent0e210d77ec39915046a95615f5f9d2a2dc65162b (diff)
CPS-506: List all known modules and revision
Issue-ID: CPS-506 Signed-off-by: shivasubedi <shiva.subedi@est.tech> Change-Id: Id76fecc7dd10625cc3ecb940b1181b1e8bf829a1
Diffstat (limited to 'cps-service/src')
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java9
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java8
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java9
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy8
4 files changed, 34 insertions, 0 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
index cd156d6dd9..fee4daa51a 100644
--- a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
+++ b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
@@ -21,10 +21,12 @@
package org.onap.cps.api;
+import java.util.List;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.onap.cps.spi.CascadeDeleteAllowed;
import org.onap.cps.spi.exceptions.DataInUseException;
+import org.onap.cps.spi.model.ModuleReference;
import org.onap.cps.spi.model.SchemaSet;
/**
@@ -63,4 +65,11 @@ public interface CpsModuleService {
*/
void deleteSchemaSet(@NonNull String dataspaceName, @NonNull String schemaSetName,
@NonNull CascadeDeleteAllowed cascadeDeleteAllowed);
+
+ /**
+ * Retrieve all modules and revisions known by CPS for all Yang Resources.
+ *
+ * @return a list of ModuleReference objects
+ */
+ List<ModuleReference> getAllYangResourcesModuleReferences();
}
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
index e4e6d1bef7..34735f8482 100644
--- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
+++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
@@ -21,10 +21,12 @@
package org.onap.cps.api.impl;
+import java.util.List;
import java.util.Map;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.spi.CascadeDeleteAllowed;
import org.onap.cps.spi.CpsModulePersistenceService;
+import org.onap.cps.spi.model.ModuleReference;
import org.onap.cps.spi.model.SchemaSet;
import org.onap.cps.yang.YangTextSchemaSourceSetBuilder;
import org.springframework.beans.factory.annotation.Autowired;
@@ -61,4 +63,10 @@ public class CpsModuleServiceImpl implements CpsModuleService {
final CascadeDeleteAllowed cascadeDeleteAllowed) {
cpsModulePersistenceService.deleteSchemaSet(dataspaceName, schemaSetName, cascadeDeleteAllowed);
}
+
+ @Override
+ public List<ModuleReference> getAllYangResourcesModuleReferences() {
+ return cpsModulePersistenceService.getAllYangResourcesModuleReferences();
+ }
+
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
index ec8a53cd13..bc62a23c52 100755
--- a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
@@ -21,9 +21,11 @@
package org.onap.cps.spi;
+import java.util.List;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.onap.cps.spi.exceptions.DataInUseException;
+import org.onap.cps.spi.model.ModuleReference;
/**
* Service to manage modules.
@@ -73,4 +75,11 @@ public interface CpsModulePersistenceService {
@NonNull
Map<String, String> getYangSchemaSetResources(@NonNull String dataspaceName,
@NonNull String anchorName);
+
+ /**
+ * Returns all YANG resources module references.
+ *
+ * @return List of all YANG resources module information in the database
+ */
+ List<ModuleReference> getAllYangResourcesModuleReferences();
}
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy
index 579415f72e..b8bfd4593e 100644
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy
@@ -103,4 +103,12 @@ class CpsModuleServiceImplSpec extends Specification {
'dataspace-1' | 'schemas-set-1' | CASCADE_DELETE_ALLOWED
'dataspace-2' | 'schemas-set-2' | CASCADE_DELETE_PROHIBITED
}
+
+ def 'Get all yang resources module references.'(){
+ given: 'an already present module reference'
+ def moduleReferences = [new ModuleReference()]
+ mockModuleStoreService.getAllYangResourcesModuleReferences() >> moduleReferences
+ expect: 'the list provided by persistence service is returned as result'
+ objectUnderTest.getAllYangResourcesModuleReferences() == moduleReferences
+ }
}