Move integration test for moduleService
[cps.git] / integration-test / src / test / groovy / org / onap / cps / integration / functional / CpsQueryServiceIntegrationSpec.groovy
index a04302f..d64617c 100644 (file)
@@ -25,7 +25,6 @@ import org.onap.cps.api.CpsQueryService
 import org.onap.cps.integration.base.FunctionalSpecBase
 import org.onap.cps.spi.FetchDescendantsOption
 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
@@ -150,18 +149,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.'() {
@@ -237,7 +234,6 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
             thrown(CpsPathException)
     }
 
-    @Ignore
     def 'Cps Path query across anchors with #scenario.'() {
         when: 'a query is executed to get a data nodes across anchors by the given CpsPath'
             def result = objectUnderTest.queryDataNodesAcrossAnchors(FUNCTIONAL_TEST_DATASPACE_1, cpsPath, OMIT_DESCENDANTS)
@@ -263,7 +259,6 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
             'ancestor combined with text condition'     | '//books/title[text()="Matilda"]/ancestor::bookstore' || ["/bookstore"]
     }
 
-    @Ignore
     def 'Cps Path query across anchors with #scenario descendants.'() {
         when: 'a query is executed to get a data node by the given cps path'
             def result = objectUnderTest.queryDataNodesAcrossAnchors(FUNCTIONAL_TEST_DATASPACE_1, '/bookstore', fetchDescendantsOption)
@@ -278,7 +273,6 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
             'all'    | INCLUDE_ALL_DESCENDANTS || 17
     }
 
-    @Ignore
     def 'Cps Path query across anchors with ancestors and #scenario descendants.'() {
         when: 'a query is executed to get a data node by the given cps path'
             def result = objectUnderTest.queryDataNodesAcrossAnchors(FUNCTIONAL_TEST_DATASPACE_1, '//books/ancestor::bookstore', fetchDescendantsOption)
@@ -300,4 +294,21 @@ class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
             thrown(CpsPathException)
     }
 
+    def 'Cps Path querys with all descendants including descendants that are list entries: #scenario.'() {
+        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, INCLUDE_ALL_DESCENDANTS)
+        then: 'correct number of datanodes are returned'
+            assert countDataNodesInTree(result) == expectedNumberOfDataNodes
+        where:
+            scenario                              | cpsPath                                 || expectedNumberOfDataNodes
+            'absolute path all list entries'      | '/bookstore/categories'                 || 13
+            'absolute path 1 list entry by key'   | '/bookstore/categories[@code="3"]'      || 5
+            'absolute path 1 list entry by name'  | '/bookstore/categories[@name="Comedy"]' || 5
+            'relative path all list entries'      | '//categories'                          || 13
+            'relative path 1 list entry by key'   | '//categories[@code="3"]'               || 5
+            'relative path 1 list entry by leaf'  | '//categories[@name="Comedy"]'          || 5
+            'incomplete absolute path'            | '/categories'                           || 0
+            'incomplete absolute 1 list entry'    | '/categories[@code="3"]'                || 0
+    }
+
 }