aboutsummaryrefslogtreecommitdiffstats
path: root/integration-test/src
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2024-12-02 14:49:10 +0000
committerdanielhanrahan <daniel.hanrahan@est.tech>2024-12-03 15:49:03 +0000
commitcca2dc7d661fa6fbad66bfdde2638b7bfd6b9bcd (patch)
tree5dc4327ea1008a881bb059769537cf256a57e107 /integration-test/src
parent902d17332d3e5cebe545991e01a5e55f739f0f80 (diff)
Add tests of attribute-axis feature
Following TDD, functional acceptance tests are added for attribute-axis feature. This covers xpaths such as '//books/@title' - Add stub to CpsQueryService throwing UnsupportedOperationException - Add tests showing expected behaviour (tests currently ignored) - Implementation will be provided in following commmit for CPS-2416 Issue-ID: CPS-2416 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: I71817e66b28dfc21e7b75243fd0135f3cceddb8e
Diffstat (limited to 'integration-test/src')
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/QueryServiceIntegrationSpec.groovy39
1 files changed, 39 insertions, 0 deletions
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/QueryServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/QueryServiceIntegrationSpec.groovy
index 3b49cfc415..23e41c4178 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/QueryServiceIntegrationSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/cps/QueryServiceIntegrationSpec.groovy
@@ -27,6 +27,7 @@ import org.onap.cps.integration.base.FunctionalSpecBase
import org.onap.cps.spi.FetchDescendantsOption
import org.onap.cps.spi.PaginationOption
import org.onap.cps.spi.exceptions.CpsPathException
+import spock.lang.Ignore
import static org.onap.cps.spi.FetchDescendantsOption.DIRECT_CHILDREN_ONLY
import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
@@ -56,6 +57,44 @@ class QueryServiceIntegrationSpec extends FunctionalSpecBase {
'the AND is used where result does not exist' | '//books[@lang="English" and @price=1000]' || 0 | []
}
+ @Ignore // TODO will be implemented in CPS-2416
+ def 'Query data leaf using CPS path for #scenario.'() {
+ when: 'query data leaf for bookstore container'
+ def result = objectUnderTest.queryDataLeaf(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, cpsPath, Object.class)
+ then: 'the result contains the expected number of leaf values'
+ assert result.size() == expectedUniqueBooksTitles
+ where:
+ scenario | cpsPath || expectedUniqueBooksTitles
+ 'all books' | '//books/@title' || 19
+ 'all books in a category' | '/bookstore/categories[@code=5]/books/@title' || 10
+ 'non-existing path' | '/non-existing/@title' || 0
+ }
+
+ @Ignore
+ def 'Query data leaf with type #leafType using CPS path.'() {
+ given: 'a cps path query for two books, returning only #leafName'
+ def cpsPath = '//books[@title="Matilda" or @title="Good Omens"]/@' + leafName
+ when: 'query data leaf for bookstore container'
+ def results = objectUnderTest.queryDataLeaf(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, cpsPath, leafType)
+ then: 'the result contains the expected leaf values'
+ assert results == expectedResults as Set
+ where:
+ leafName | leafType || expectedResults
+ 'lang' | String.class || ['English']
+ 'price' | Number.class || [13, 20]
+ 'editions' | List.class || [[1988, 2000], [2006]]
+ }
+
+ @Ignore
+ def 'Query data leaf using CPS path with ancestor axis.'() {
+ given: 'a cps path query that will return the names of the categories of two books'
+ def cpsPath = '//books[@title="Matilda" or @title="Good Omens"]/ancestor::categories/@name'
+ when: 'query data leaf for bookstore container'
+ def result = objectUnderTest.queryDataLeaf(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, cpsPath, String.class)
+ then: 'the result contains the expected leaf values'
+ assert result == ['Children', 'Comedy'] as Set
+ }
+
def 'Cps Path query using comparative and boolean operators.'() {
given: 'a cps path query in the discount category'
def cpsPath = "/bookstore/categories[@code='5']/books" + leafCondition