package org.onap.cps.api.impl
import org.onap.cps.spi.CpsDataPersistenceService
+import org.onap.cps.spi.FetchDescendantsOption
import spock.lang.Specification
+import spock.lang.Unroll
+
class CpsQueryServiceImplSpec extends Specification {
def mockCpsDataPersistenceService = Mock(CpsDataPersistenceService)
objectUnderTest.cpsDataPersistenceService = mockCpsDataPersistenceService
}
- def 'Query data nodes by cps path.'() {
+ @Unroll
+ def 'Query data nodes by cps path with #fetchDescendantsOption.'() {
given: 'a dataspace name, an anchor name and a cps path'
def dataspaceName = 'some dataspace'
def anchorName = 'some anchor'
def cpsPath = '/cps-path'
when: 'queryDataNodes is invoked'
- objectUnderTest.queryDataNodes(dataspaceName, anchorName, cpsPath)
+ objectUnderTest.queryDataNodes(dataspaceName, anchorName, cpsPath, fetchDescendantsOption)
then: 'the persistence service is called once with the correct parameters'
- 1 * mockCpsDataPersistenceService.queryDataNodes(dataspaceName, anchorName, cpsPath)
+ 1 * mockCpsDataPersistenceService.queryDataNodes(dataspaceName, anchorName, cpsPath, fetchDescendantsOption)
+ where: 'all fetch descendants options are supported'
+ fetchDescendantsOption << FetchDescendantsOption.values()
}
}
\ No newline at end of file