+ assert result[0].leaves['lang'] == 'English/French'
+ assert result[0].leaves['price'] == 100
+ cleanup:
+ restoreBookstoreDataAnchor(2)
+ }
+
+ def 'Order of leaf-list elements is preserved when "ordered-by user" is set in the YANG model.'() {
+ given: 'Updated json for bookstore data'
+ def jsonData = "{'book-store:books':{'title':'Matilda', 'authors': ['beta', 'alpha', 'gamma', 'delta']}}"
+ when: 'update is performed for leaves'
+ objectUnderTest.updateNodeLeaves(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_2, "/bookstore/categories[@code='1']", jsonData, now)
+ and: 'the updated data nodes are retrieved'
+ def result = cpsDataService.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_2, "/bookstore/categories[@code=1]/books[@title='Matilda']", INCLUDE_ALL_DESCENDANTS)
+ then: 'the leaf-list values have expected order'
+ assert result[0].leaves['authors'] == ['beta', 'alpha', 'gamma', 'delta']
+ cleanup:
+ restoreBookstoreDataAnchor(2)
+ }
+
+ def 'Leaf-list elements are sorted when "ordered-by user" is not set in the YANG model.'() {
+ given: 'Updated json for bookstore data'
+ def jsonData = "{'book-store:books':{'title':'Matilda', 'editions': [2011, 1988, 2001, 2022, 2025]}}"
+ when: 'update is performed for leaves'
+ objectUnderTest.updateNodeLeaves(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_2, "/bookstore/categories[@code='1']", jsonData, now)
+ and: 'the updated data nodes are retrieved'
+ def result = cpsDataService.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_2, "/bookstore/categories[@code=1]/books[@title='Matilda']", INCLUDE_ALL_DESCENDANTS)
+ then: 'the leaf-list values have natural order'
+ assert result[0].leaves['editions'] == [1988, 2001, 2011, 2022, 2025]