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-service/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-service/src')
4 files changed, 34 insertions, 11 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 218a236f1b..1dccf49c9b 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 @@ -81,10 +81,19 @@ public interface CpsModuleService { @NonNull CascadeDeleteAllowed cascadeDeleteAllowed); /** - * Retrieve all modules and revisions known by CPS for all Yang Resources. + * Retrieve module references for the given dataspace name. * * @param dataspaceName dataspace name * @return a list of ModuleReference objects */ - Collection<ModuleReference> getAllYangResourceModuleReferences(final String dataspaceName); + Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName); + + /** + * Retrieve module references for the given dataspace name and anchor name. + * + * @param dataspaceName dataspace name + * @param anchorName anchor name + * @return a list of ModuleReference objects + */ + Collection<ModuleReference> getYangResourcesModuleReferences(String dataspaceName, String anchorName); } 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 17ad78cbe8..10326413c3 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 @@ -75,8 +75,13 @@ public class CpsModuleServiceImpl implements CpsModuleService { } @Override - public Collection<ModuleReference> getAllYangResourceModuleReferences(final String dataspaceName) { - return cpsModulePersistenceService.getAllYangResourceModuleReferences(dataspaceName); + public Collection<ModuleReference> getYangResourceModuleReferences(final String dataspaceName) { + return cpsModulePersistenceService.getYangResourceModuleReferences(dataspaceName); } + @Override + public Collection<ModuleReference> getYangResourcesModuleReferences(final String dataspaceName, + final String anchorName) { + return cpsModulePersistenceService.getYangResourceModuleReferences(dataspaceName, anchorName); + } } 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 4f46c0dacb..9b50f9e917 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 @@ -90,20 +90,19 @@ public interface CpsModulePersistenceService { @NonNull String anchorName); /** - * Returns all YANG resources module references for the given dataspace name. + * Returns YANG resources module references for the given dataspace name. * * @param dataspaceName dataspace name * @return Collection of all YANG resources module information in the database */ - Collection<ModuleReference> getAllYangResourceModuleReferences(final String dataspaceName); + Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName); /** - * Get all YANG resource module references for the given anchor name and dataspace name. + * Get YANG resource module references for the given anchor name and dataspace name. * * @param dataspaceName dataspace name * @param anchorName anchor name * @return a collection of module names and revisions */ - Collection<ModuleReference> getAllYangResourceModuleReferences(final String dataspaceName, - final String anchorName); + Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName, String anchorName); } 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 31df479e42..2c23aa1bc8 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 @@ -26,6 +26,7 @@ import org.onap.cps.TestUtils import org.onap.cps.spi.CpsModulePersistenceService import org.onap.cps.spi.exceptions.ModelValidationException import org.onap.cps.spi.model.ExtendedModuleReference +import org.onap.cps.spi.model.ModuleReference import org.spockframework.spring.SpringBean import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest @@ -118,8 +119,17 @@ class CpsModuleServiceImplSpec extends Specification { def 'Get all yang resources module references.'(){ given: 'an already present module reference' def moduleReferences = [new ExtendedModuleReference()] - mockModuleStoreService.getAllYangResourceModuleReferences('someDataspaceName') >> moduleReferences + mockModuleStoreService.getYangResourceModuleReferences('someDataspaceName') >> moduleReferences expect: 'the list provided by persistence service is returned as result' - objectUnderTest.getAllYangResourceModuleReferences('someDataspaceName') == moduleReferences + objectUnderTest.getYangResourceModuleReferences('someDataspaceName') == moduleReferences + } + + + def 'Get all yang resources module references for the given dataspace name and anchor name.'(){ + given: 'the module store service service returns a list module references' + def moduleReferences = [new ModuleReference()] + mockModuleStoreService.getYangResourceModuleReferences('someDataspaceName', 'someAnchorName') >> moduleReferences + expect: 'the list provided by persistence service is returned as result' + objectUnderTest.getYangResourcesModuleReferences('someDataspaceName', 'someAnchorName') == moduleReferences } } |