+
+ def 'Cps Path query across anchors using pagination option with #scenario.'() {
+ when: 'a query is executed to get a data nodes across anchors by the given CpsPath and pagination option'
+ def result = objectUnderTest.queryDataNodesAcrossAnchors(FUNCTIONAL_TEST_DATASPACE_1, '/bookstore', OMIT_DESCENDANTS, new PaginationOption(pageIndex, pageSize))
+ then: 'correct bookstore names are queried'
+ def bookstoreNames = result.collect { it.getLeaves().get('bookstore-name') }
+ assert bookstoreNames.toList() == expectedBookstoreNames
+ and: 'the correct number of page size is returned'
+ assert result.size() == expectedPageSize
+ and: 'the queried nodes have expected anchor names'
+ assert result.anchorName.toSet() == expectedAnchors.toSet()
+ where: 'the following data is used'
+ scenario | pageIndex | pageSize || expectedPageSize || expectedAnchors || expectedBookstoreNames
+ '1st page with one anchor' | 1 | 1 || 1 || [BOOKSTORE_ANCHOR_1] || ['Easons-1']
+ '1st page with two anchor' | 1 | 2 || 2 || [BOOKSTORE_ANCHOR_1, BOOKSTORE_ANCHOR_2] || ['Easons-1', 'Easons-2']
+ '2nd page' | 2 | 1 || 1 || [BOOKSTORE_ANCHOR_2] || ['Easons-2']
+ 'no 2nd page due to page size' | 2 | 2 || 0 || [] || []
+ }
+
+ def 'Cps Path query across anchors using pagination option for ancestor axis.'() {
+ when: 'a query is executed to get a data nodes across anchors by the given CpsPath and pagination option'
+ def result = objectUnderTest.queryDataNodesAcrossAnchors(FUNCTIONAL_TEST_DATASPACE_1, '//books/ancestor::categories', INCLUDE_ALL_DESCENDANTS, new PaginationOption(1, 2))
+ then: 'correct category codes are queried'
+ def categoryNames = result.collect { it.getLeaves().get('name') }
+ assert categoryNames.toSet() == ['Discount books', 'Computing', 'Comedy', 'Thriller', 'Children'].toSet()
+ and: 'the queried nodes have expected anchors'
+ assert result.anchorName.toSet() == [BOOKSTORE_ANCHOR_1, BOOKSTORE_ANCHOR_2].toSet()
+ }
+
+ def 'Count number of anchors for given dataspace name and cps path'() {
+ expect: '/bookstore is present in two anchors'
+ assert objectUnderTest.countAnchorsForDataspaceAndCpsPath(FUNCTIONAL_TEST_DATASPACE_1, '/bookstore') == 2
+ }
+
+ def 'Cps Path query across anchors using no pagination'() {
+ when: 'a query is executed to get a data nodes across anchors by the given CpsPath and pagination option'
+ def result = objectUnderTest.queryDataNodesAcrossAnchors(FUNCTIONAL_TEST_DATASPACE_1, '/bookstore', OMIT_DESCENDANTS, NO_PAGINATION)
+ then: 'all bookstore names are queried'
+ def bookstoreNames = result.collect { it.getLeaves().get('bookstore-name') }
+ assert bookstoreNames.toSet() == ['Easons-1', 'Easons-2'].toSet()
+ and: 'the correct number of page size is returned'
+ assert result.size() == 2
+ and: 'the queried nodes have expected bookstore names'
+ assert result.anchorName.toSet() == [BOOKSTORE_ANCHOR_1, BOOKSTORE_ANCHOR_2].toSet()
+ }