summaryrefslogtreecommitdiffstats
path: root/integration-test/src
diff options
context:
space:
mode:
Diffstat (limited to 'integration-test/src')
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy18
-rw-r--r--integration-test/src/test/resources/liquibase/test-changelog.yaml34
2 files changed, 52 insertions, 0 deletions
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy
index bd39605de3..38bb4de573 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy
@@ -147,6 +147,22 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
'text condition on key containing /' | '//books/title[text()="Debian GNU/Linux"]' || ["Debian GNU/Linux"]
}
+ def 'Query for attribute by cps path using contains condition #scenario.'() {
+ when: 'a query is executed to get response by the given cps path'
+ def result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, cpsPath, OMIT_DESCENDANTS)
+ then: 'the cps-path of queryDataNodes has expected number of nodes'
+ assert result.size() == expectedResultsize
+ and: 'xpaths of the retrieved data nodes are as expected'
+ def bookTitles = result.collect { it.getLeaves().get('title') }
+ assert bookTitles.sort() == expectedBookTitles.sort()
+ where: 'the following data is used'
+ scenario | cpsPath | expectedResultsize || expectedBookTitles
+ 'contains condition with leaf' | '//books[contains(@title,"Mat")]' | 1 || ["Matilda"]
+ 'contains condition with case-sensitive' | '//books[contains(@title,"Ti")]' | 0 || []
+ 'contains condition with Integer Value' | '//books[contains(@price,"15")]' | 2 || ["Annihilation", "The Gruffalo"]
+ 'contains condition with No-value' | '//books[contains(@title,"")]' | 9 || ["A Book with No Language", "Annihilation", "Debian GNU/Linux", "Good Omens", "Logarithm tables", "Matilda", "The Colour of Magic", "The Gruffalo", "The Light Fantastic"]
+ }
+
def 'Cps Path query using descendant anywhere with #scenario condition for a container element.'() {
when: 'a query is executed to get a data node by the given cps path'
def result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, cpsPath, OMIT_DESCENDANTS)
@@ -164,6 +180,7 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
'more than one leaf has multiple OR' | '//books[ @title="Matilda" or @price=15 or @edition=2006]' || ['Annihilation', 'Matilda', 'The Gruffalo']
'leaves reversed in order' | '//books[@lang="English" and @price=12]' || ['The Colour of Magic']
'leaf and text' | '//books[@price=14]/authors[text()="Terry Pratchett"]' || ['The Light Fantastic']
+ 'leaf and contains' | '//books[contains(@price,"13")]' || ['Good Omens']
}
def 'Cps Path query using descendant anywhere with #scenario condition(s) for a list element.'() {
@@ -195,6 +212,7 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
'ancestor combined with text condition' | '//books/title[text()="Matilda"]/ancestor::bookstore' || ["/bookstore"]
'ancestor with parent that does not exist' | '//books/ancestor::parentDoesNoExist/categories' || []
'ancestor does not exist' | '//books/ancestor::ancestorDoesNotExist' || []
+ 'ancestor combined with contains condition' | '//books[contains(@title,"Mat")]/ancestor::bookstore' || ["/bookstore"]
}
def 'Query for attribute by cps path of type ancestor with #scenario descendants.'() {
diff --git a/integration-test/src/test/resources/liquibase/test-changelog.yaml b/integration-test/src/test/resources/liquibase/test-changelog.yaml
index 8b7422ce54..f53fef70b7 100644
--- a/integration-test/src/test/resources/liquibase/test-changelog.yaml
+++ b/integration-test/src/test/resources/liquibase/test-changelog.yaml
@@ -615,3 +615,37 @@ databaseChangeLog:
- dropIndex:
indexName: FKI_SCHEMA_SET_YANG_RESOURCES_SCHEMA_SET_ID_FK
tableName: schema_set_yang_resources
+
+ - changeSet:
+ author: cps
+ id: 1-42
+ changes:
+ - dropForeignKeyConstraint:
+ baseTableName: fragment
+ constraintName: fragment_parent_id_fkey
+ - addForeignKeyConstraint:
+ baseColumnNames: parent_id
+ baseTableName: fragment
+ constraintName: fragment_parent_id_fkey
+ deferrable: false
+ initiallyDeferred: false
+ onDelete: CASCADE
+ onUpdate: NO ACTION
+ referencedColumnNames: id
+ referencedTableName: fragment
+ validate: true
+ rollback:
+ - dropForeignKeyConstraint:
+ baseTableName: fragment
+ constraintName: fragment_parent_id_fkey
+ - addForeignKeyConstraint:
+ baseColumnNames: parent_id
+ baseTableName: fragment
+ constraintName: fragment_parent_id_fkey
+ deferrable: false
+ initiallyDeferred: false
+ onDelete: NO ACTION
+ onUpdate: NO ACTION
+ referencedColumnNames: id
+ referencedTableName: fragment
+ validate: true