summaryrefslogtreecommitdiffstats
path: root/cps-service
diff options
context:
space:
mode:
Diffstat (limited to 'cps-service')
-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
+ }
}