From 32446dce35b5bf9d2c84751718cb4ece7f96fa72 Mon Sep 17 00:00:00 2001 From: niamhcore Date: Mon, 1 Mar 2021 13:25:13 +0000 Subject: CPS-265 - updating cps path to support include-descendants option. Issue-ID: CPS-265 Signed-off-by: niamhcore Change-Id: I9e9b84760dbc8b5eb4b31ab972fdb2d186c6bb48 --- .../java/org/onap/cps/nfproxy/api/NfProxyDataService.java | 11 +++++++---- .../org/onap/cps/nfproxy/api/impl/NfProxyDataServiceImpl.java | 5 +++-- .../org/onap/cps/api/impl/NfProxyDataServiceImplSpec.groovy | 9 ++++++--- 3 files changed, 16 insertions(+), 9 deletions(-) (limited to 'cps-nf-proxy-service') diff --git a/cps-nf-proxy-service/src/main/java/org/onap/cps/nfproxy/api/NfProxyDataService.java b/cps-nf-proxy-service/src/main/java/org/onap/cps/nfproxy/api/NfProxyDataService.java index ce47d7001..cde1801da 100644 --- a/cps-nf-proxy-service/src/main/java/org/onap/cps/nfproxy/api/NfProxyDataService.java +++ b/cps-nf-proxy-service/src/main/java/org/onap/cps/nfproxy/api/NfProxyDataService.java @@ -46,12 +46,15 @@ public interface NfProxyDataService { /** * Get datanodes for the given cm handle by cps path. * - * @param cmHandle The identifier for a network function, network element, subnetwork or any other cm object by - * managed NF-Proxy - * @param cpsPath cps path + * @param cmHandle The identifier for a network function, network element, subnetwork or any other cm + * object by managed NF-Proxy + * @param cpsPath cps path + * @param fetchDescendantsOption defines whether the descendants of the node(s) found by the query should be + * included in the output * @return a collection of datanodes */ - Collection queryDataNodes(@NonNull String cmHandle, @NonNull String cpsPath); + Collection queryDataNodes(@NonNull String cmHandle, @NonNull String cpsPath, + @NonNull FetchDescendantsOption fetchDescendantsOption); /** * Updates data node for given cm handle using xpath to parent node. diff --git a/cps-nf-proxy-service/src/main/java/org/onap/cps/nfproxy/api/impl/NfProxyDataServiceImpl.java b/cps-nf-proxy-service/src/main/java/org/onap/cps/nfproxy/api/impl/NfProxyDataServiceImpl.java index bb15591a9..cff92fea6 100755 --- a/cps-nf-proxy-service/src/main/java/org/onap/cps/nfproxy/api/impl/NfProxyDataServiceImpl.java +++ b/cps-nf-proxy-service/src/main/java/org/onap/cps/nfproxy/api/impl/NfProxyDataServiceImpl.java @@ -47,8 +47,9 @@ public class NfProxyDataServiceImpl implements NfProxyDataService { } @Override - public Collection queryDataNodes(final String cmHandle, final String cpsPath) { - return cpsQueryService.queryDataNodes(NF_PROXY_DATASPACE_NAME, cmHandle, cpsPath); + public Collection queryDataNodes(final String cmHandle, final String cpsPath, + final FetchDescendantsOption fetchDescendantsOption) { + return cpsQueryService.queryDataNodes(NF_PROXY_DATASPACE_NAME, cmHandle, cpsPath, fetchDescendantsOption); } @Override diff --git a/cps-nf-proxy-service/src/test/groovy/org/onap/cps/api/impl/NfProxyDataServiceImplSpec.groovy b/cps-nf-proxy-service/src/test/groovy/org/onap/cps/api/impl/NfProxyDataServiceImplSpec.groovy index f89f80e30..24549aec8 100644 --- a/cps-nf-proxy-service/src/test/groovy/org/onap/cps/api/impl/NfProxyDataServiceImplSpec.groovy +++ b/cps-nf-proxy-service/src/test/groovy/org/onap/cps/api/impl/NfProxyDataServiceImplSpec.groovy @@ -22,6 +22,7 @@ package org.onap.cps.api.impl import org.onap.cps.api.CpsDataService import org.onap.cps.api.CpsQueryService import org.onap.cps.nfproxy.api.impl.NfProxyDataServiceImpl +import org.onap.cps.spi.FetchDescendantsOption import spock.lang.Specification class NfProxyDataServiceImplSpec extends Specification { @@ -37,13 +38,15 @@ class NfProxyDataServiceImplSpec extends Specification { def cmHandle = 'some handle' def expectedDataspaceName = 'NFP-Operational' - def 'Query data nodes by cps path.'() { + def 'Query data nodes by cps path with #fetchDescendantsOption.'() { given: 'a cm Handle and a cps path' def cpsPath = '/cps-path' when: 'queryDataNodes is invoked' - objectUnderTest.queryDataNodes(cmHandle, cpsPath) + objectUnderTest.queryDataNodes(cmHandle, cpsPath, fetchDescendantsOption) then: 'the persistence service is called once with the correct parameters' - 1 * mockcpsQueryService.queryDataNodes(expectedDataspaceName, cmHandle, cpsPath) + 1 * mockcpsQueryService.queryDataNodes(expectedDataspaceName, cmHandle, cpsPath, fetchDescendantsOption) + where: 'all fetch descendants options are supported' + fetchDescendantsOption << FetchDescendantsOption.values() } def 'Update data node leaves.'() { -- cgit 1.2.3-korg