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