diff options
author | 2021-03-01 13:25:13 +0000 | |
---|---|---|
committer | 2021-03-02 11:13:25 +0000 | |
commit | 32446dce35b5bf9d2c84751718cb4ece7f96fa72 (patch) | |
tree | 03a0fb6b16c6c6e692bc54db74440d005c501573 /cps-nf-proxy-rest/src/test/groovy | |
parent | 7c981df521c9d8eb6f340b2b118491eeeb21ae59 (diff) |
CPS-265 - updating cps path to support include-descendants option.
Issue-ID: CPS-265
Signed-off-by: niamhcore <niamh.core@est.tech>
Change-Id: I9e9b84760dbc8b5eb4b31ab972fdb2d186c6bb48
Diffstat (limited to 'cps-nf-proxy-rest/src/test/groovy')
-rw-r--r-- | cps-nf-proxy-rest/src/test/groovy/org/onap/cps/nfproxy/rest/controller/NfProxyControllerSpec.groovy | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/cps-nf-proxy-rest/src/test/groovy/org/onap/cps/nfproxy/rest/controller/NfProxyControllerSpec.groovy b/cps-nf-proxy-rest/src/test/groovy/org/onap/cps/nfproxy/rest/controller/NfProxyControllerSpec.groovy index 742a643fa..a81411caf 100644 --- a/cps-nf-proxy-rest/src/test/groovy/org/onap/cps/nfproxy/rest/controller/NfProxyControllerSpec.groovy +++ b/cps-nf-proxy-rest/src/test/groovy/org/onap/cps/nfproxy/rest/controller/NfProxyControllerSpec.groovy @@ -21,10 +21,9 @@ package org.onap.cps.nfproxy.rest.controller -import com.google.common.collect.ImmutableMap + import com.google.gson.Gson import org.onap.cps.nfproxy.api.NfProxyDataService -import org.onap.cps.spi.model.DataNode import org.onap.cps.spi.model.DataNodeBuilder import org.spockframework.spring.SpringBean import org.springframework.beans.factory.annotation.Autowired @@ -34,7 +33,9 @@ import org.springframework.http.HttpStatus import org.springframework.http.MediaType import org.springframework.test.web.servlet.MockMvc import spock.lang.Specification +import spock.lang.Unroll +import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.* @@ -59,22 +60,28 @@ class NfProxyControllerSpec extends Specification { def cmHandle = 'some handle' def xpath = 'some xpath' - def 'Query data node by cps path for the given cm handle.'() { + @Unroll + def 'Query data node by cps path for the given cm handle with #scenario.'() { given: 'service method returns a list containing a data node' - def cpsPath = '/xpath/leaves[@leaf=\'value\']' - def dataNode = new DataNodeBuilder().withXpath("/xpath") - .withLeaves(ImmutableMap.of("leaf", "value")).build() - ArrayList<DataNode> dataNodeList = new ArrayList(); - dataNodeList.add(dataNode) - mockNfProxyDataService.queryDataNodes(cmHandle, cpsPath) >> dataNodeList + def dataNode = new DataNodeBuilder().withXpath('/xpath').build() + def cpsPath = 'some cps-path' + mockNfProxyDataService.queryDataNodes(cmHandle, cpsPath, expectedCpsDataServiceOption) >> [dataNode] and: 'the query endpoint' def dataNodeEndpoint = "$dataNodeBaseEndpoint/cm-handles/$cmHandle/nodes/query" when: 'query data nodes API is invoked' - def response = mvc.perform(get(dataNodeEndpoint).param('cps-path', cpsPath)).andReturn().response + def response = mvc.perform(get(dataNodeEndpoint) + .param('cps-path', cpsPath) + .param('include-descendants', includeDescendantsOption)) + .andReturn().response then: 'the response contains the the datanode in json format' response.status == HttpStatus.OK.value() def expectedJsonContent = new Gson().toJson(dataNode) response.getContentAsString().contains(expectedJsonContent) + where: 'the following options for include descendants are provided in the request' + scenario | includeDescendantsOption || expectedCpsDataServiceOption + 'no descendants by default'| '' || OMIT_DESCENDANTS + 'no descendant explicitly' | 'false' || OMIT_DESCENDANTS + 'descendants' | 'true' || INCLUDE_ALL_DESCENDANTS } def 'Update data node leaves.'() { |