Add contains condition support to cps-path
[cps.git] / cps-path-parser / src / test / groovy / org / onap / cps / cpspath / parser / CpsPathQuerySpec.groovy
index 153dfbe..96fdf88 100644 (file)
@@ -136,6 +136,17 @@ class CpsPathQuerySpec extends Specification {
             'descendant with leaf value and ancestor' | '//child[@other-leaf=1]/leaf-name[text()="search"]/ancestor::parent' || true                 | true
     }
 
+    def 'Parse #scenario cps path with contains function condition'() {
+        when: 'the given cps path is parsed'
+            def result = CpsPathQuery.createFrom('//someContainer[contains(@lang,"en")]')
+        then: 'the query has the right xpath type'
+            result.cpsPathPrefixType == DESCENDANT
+        and: 'the right contains function condition is set'
+            result.hasContainsFunctionCondition()
+            result.containsFunctionConditionLeafName == 'lang'
+            result.containsFunctionConditionValue == 'en'
+    }
+
     def 'Parse cps path with error: #scenario.'() {
         when: 'the given cps path is parsed'
             CpsPathQuery.createFrom(cpsPath)