summaryrefslogtreecommitdiffstats
path: root/cps-service
diff options
context:
space:
mode:
authorniamhcore <niamh.core@est.tech>2021-10-28 13:39:24 +0100
committerniamhcore <niamh.core@est.tech>2021-11-02 15:05:39 +0000
commitb0d930752fd6be436061226c7395038f6828438e (patch)
tree206389f51db0ffe46dae7c7c0e5d21c2f880e548 /cps-service
parent6fda688fa63ea7ccd450002fb94a18b07095bea9 (diff)
Add get cm handles by modules names - service layer
Issue-ID: CPS-644 Signed-off-by: niamhcore <niamh.core@est.tech> Change-Id: Ic2a57df02d533a0066382c12c35be8d524b6cdad
Diffstat (limited to 'cps-service')
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/api/CpsAdminService.java11
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java7
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java8
-rwxr-xr-xcps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy8
4 files changed, 31 insertions, 3 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java b/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java
index 5b2e104289..1d08cde7ba 100755
--- a/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java
+++ b/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java
@@ -77,4 +77,15 @@ public interface CpsAdminService {
* @param anchorName anchor name
*/
void deleteAnchor(@NonNull String dataspaceName, @NonNull String anchorName);
+
+ /**
+ * Query anchor names for the given module names in the provided dataspace.
+ *
+ *
+ * @param dataspaceName dataspace name
+ * @param moduleNames a collection of module names
+ * @return a collection of anchor names in the given dataspace. The schema set for each anchor must include all the
+ * given module names
+ */
+ Collection<String> queryAnchorNames(String dataspaceName, Collection<String> moduleNames);
}
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java
index 47da64895e..4640a0fb31 100755
--- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java
+++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java
@@ -23,6 +23,7 @@
package org.onap.cps.api.impl;
import java.util.Collection;
+import java.util.stream.Collectors;
import org.onap.cps.api.CpsAdminService;
import org.onap.cps.spi.CpsAdminPersistenceService;
import org.onap.cps.spi.model.Anchor;
@@ -59,4 +60,10 @@ public class CpsAdminServiceImpl implements CpsAdminService {
public void deleteAnchor(final String dataspaceName, final String anchorName) {
cpsAdminPersistenceService.deleteAnchor(dataspaceName, anchorName);
}
+
+ @Override
+ public Collection<String> queryAnchorNames(final String dataspaceName, final Collection<String> moduleNames) {
+ final Collection<Anchor> anchors = cpsAdminPersistenceService.queryAnchors(dataspaceName, moduleNames);
+ return anchors.stream().map(anchor -> anchor.getName()).collect(Collectors.toList());
+ }
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java
index f29735fa01..104ac4f3f6 100755
--- a/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java
@@ -59,13 +59,15 @@ public interface CpsAdminPersistenceService {
Collection<Anchor> getAnchors(@NonNull String dataspaceName);
/**
- * Get anchors for the given dataspace name and collection of module names.
+ * Query anchor names for the given module names in the provided dataspace.
+ *
*
* @param dataspaceName dataspace name
* @param moduleNames a collection of module names
- * @return a collection of anchors
+ * @return a collection of anchor names in the given dataspace. The schema set for each anchor must include all the
+ * given module names
*/
- Collection<Anchor> getAnchors(String dataspaceName, Collection<String> moduleNames);
+ Collection<Anchor> queryAnchors(String dataspaceName, Collection<String> moduleNames);
/**
* Get an anchor in the given dataspace using the anchor name.
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy
index be213c0fa0..95afeb4172 100755
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy
@@ -70,4 +70,12 @@ class CpsAdminServiceImplSpec extends Specification {
then: 'associated persistence service method is invoked with same parameters'
1 * mockCpsAdminPersistenceService.deleteAnchor('someDataspace','someAnchor')
}
+
+ def 'Query all anchor identifiers for a dataspace and module names.'() {
+ given: 'the persistence service is invoked with the expected parameters and returns a list of anchors'
+ mockCpsAdminPersistenceService.queryAnchors('some-dataspace-name', ['some-module-name']) >> [new Anchor(name:'some-anchor-identifier')]
+ expect: 'get anchor identifiers returns the same anchor identifier returned by the persistence layer'
+ objectUnderTest.queryAnchorNames('some-dataspace-name', ['some-module-name']) == ['some-anchor-identifier']
+
+ }
}