summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2023-05-02 18:00:53 +0100
committerDaniel Hanrahan <daniel.hanrahan@est.tech>2023-05-03 09:21:17 +0000
commitd7923e089686848a97b45572772f0093b63789a1 (patch)
tree4fab907f9761593469bd4e9d97218eb25424c959
parent52c5e54bcc48dd8a59b15e395542097b0491b4e9 (diff)
canUseRegexQuickfind does not test for contains-condition
This bug causes queries using contains-condition to return wrong results, when INCLUDE_ALL_DESCENDANTS option is set. Issue-ID: CPS-1663 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: If323e0e3b54d8c9a213dffda46897b2efb01fe2a
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java3
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy16
2 files changed, 9 insertions, 10 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
index 3d9105f680..95270786f9 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
@@ -349,7 +349,8 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
final CpsPathQuery cpsPathQuery) {
return fetchDescendantsOption.equals(FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS)
&& !cpsPathQuery.hasLeafConditions()
- && !cpsPathQuery.hasTextFunctionCondition();
+ && !cpsPathQuery.hasTextFunctionCondition()
+ && !cpsPathQuery.hasContainsFunctionCondition();
}
private List<DataNode> getDataNodesUsingRegexQuickFind(final FetchDescendantsOption fetchDescendantsOption,
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 a04302fa63..b723d7d99a 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
@@ -150,18 +150,16 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
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 result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, cpsPath, INCLUDE_ALL_DESCENDANTS)
+ then: '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"]
+ scenario | cpsPath || expectedBookTitles
+ 'contains condition with leaf' | '//books[contains(@title,"Mat")]' || ["Matilda"]
+ 'contains condition with case-sensitive' | '//books[contains(@title,"Ti")]' || []
+ 'contains condition with Integer Value' | '//books[contains(@price,"15")]' || ["Annihilation", "The Gruffalo"]
+ 'contains condition with No-value' | '//books[contains(@title,"")]' || ["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.'() {