2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2023 Nordix Foundation
4 * Modifications Copyright (C) 2023 TechMahindra Ltd.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the 'License');
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an 'AS IS' BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.cps.integration.functional
24 import org.onap.cps.api.CpsDataService
25 import org.onap.cps.integration.base.FunctionalSpecBase
26 import org.onap.cps.spi.FetchDescendantsOption
27 import org.onap.cps.spi.exceptions.AlreadyDefinedException
28 import org.onap.cps.spi.exceptions.AnchorNotFoundException
29 import org.onap.cps.spi.exceptions.CpsAdminException
30 import org.onap.cps.spi.exceptions.CpsPathException
31 import org.onap.cps.spi.exceptions.DataNodeNotFoundException
32 import org.onap.cps.spi.exceptions.DataNodeNotFoundExceptionBatch
33 import org.onap.cps.spi.exceptions.DataValidationException
34 import org.onap.cps.spi.exceptions.DataspaceNotFoundException
36 import java.time.OffsetDateTime
38 import static org.onap.cps.spi.FetchDescendantsOption.DIRECT_CHILDREN_ONLY
39 import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
40 import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS
42 class CpsDataServiceIntegrationSpec extends FunctionalSpecBase {
44 CpsDataService objectUnderTest
45 def originalCountBookstoreChildNodes
46 def originalCountBookstoreTopLevelListNodes
47 def now = OffsetDateTime.now()
50 objectUnderTest = cpsDataService
51 originalCountBookstoreChildNodes = countDataNodesInBookstore()
52 originalCountBookstoreTopLevelListNodes = countTopLevelListDataNodesInBookstore()
55 def 'Read bookstore top-level container(s) using #fetchDescendantsOption.'() {
56 when: 'get data nodes for bookstore container'
57 def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', fetchDescendantsOption)
58 then: 'the tree consist ouf of #expectNumberOfDataNodes data nodes'
59 assert countDataNodesInTree(result) == expectNumberOfDataNodes
60 and: 'the top level data node has the expected attribute and value'
61 assert result.leaves['bookstore-name'] == ['Easons']
62 and: 'they are from the correct dataspace'
63 assert result.dataspace == [FUNCTIONAL_TEST_DATASPACE_1]
64 and: 'they are from the correct anchor'
65 assert result.anchorName == [BOOKSTORE_ANCHOR_1]
66 where: 'the following option is used'
67 fetchDescendantsOption || expectNumberOfDataNodes
69 DIRECT_CHILDREN_ONLY || 7
70 INCLUDE_ALL_DESCENDANTS || 28
71 new FetchDescendantsOption(2) || 28
74 def 'Read bookstore top-level container(s) using "root" path variations.'() {
75 when: 'get data nodes for bookstore container'
76 def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, root, OMIT_DESCENDANTS)
77 then: 'the tree consist ouf of one data node'
78 assert countDataNodesInTree(result) == 2
79 and: 'the top level data node has the expected attribute and value'
80 assert result.leaves.size() == 2
81 where: 'the following variations of "root" are used'
85 def 'Read data nodes with error: #cpsPath'() {
86 when: 'attempt to get data nodes using invalid path'
87 objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, cpsPath, DIRECT_CHILDREN_ONLY)
88 then: 'a #expectedException is thrown'
89 thrown(expectedException)
91 cpsPath || expectedException
92 'invalid path' || CpsPathException
93 '/non-existing-path' || DataNodeNotFoundException
96 def 'Read (multiple) data nodes (batch) with #cpsPath'() {
97 when: 'attempt to get data nodes using invalid path'
98 objectUnderTest.getDataNodesForMultipleXpaths(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, [ cpsPath ], DIRECT_CHILDREN_ONLY)
99 then: 'no exception is thrown'
102 cpsPath << [ 'invalid path', '/non-existing-path' ]
105 def 'Delete root data node.'() {
106 when: 'the "root" is deleted'
107 objectUnderTest.deleteDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, [ '/' ], now)
108 and: 'attempt to get the top level data node'
109 objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', DIRECT_CHILDREN_ONLY)
110 then: 'an datanode not found exception is thrown'
111 thrown(DataNodeNotFoundException)
113 restoreBookstoreDataAnchor(1)
116 def 'Add and Delete a (container) data node using #scenario.'() {
117 when: 'the new datanode is saved'
118 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , parentXpath, json, now)
119 then: 'it can be retrieved by its normalized xpath'
120 def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, normalizedXpathToNode, DIRECT_CHILDREN_ONLY)
121 assert result.size() == 1
122 assert result[0].xpath == normalizedXpathToNode
123 and: 'there is now one extra datanode'
124 assert originalCountBookstoreChildNodes + 1 == countDataNodesInBookstore()
125 when: 'the new datanode is deleted'
126 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, normalizedXpathToNode, now)
127 then: 'the original number of data nodes is restored'
128 assert originalCountBookstoreChildNodes == countDataNodesInBookstore()
130 scenario | parentXpath | json || normalizedXpathToNode
131 'normalized parent xpath' | '/bookstore' | '{"webinfo": {"domain-name":"ourbookstore.com", "contact-email":"info@ourbookstore.com" }}' || "/bookstore/webinfo"
132 'non-normalized parent xpath' | '/bookstore/categories[ @code="1"]' | '{"books": {"title":"new" }}' || "/bookstore/categories[@code='1']/books[@title='new']"
135 def 'Attempt to create a top level data node using root.'() {
136 given: 'a new anchor'
137 cpsAdminService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_SCHEMA_SET, 'newAnchor1');
138 when: 'attempt to save new top level datanode'
139 def json = '{"bookstore": {"bookstore-name": "New Store"} }'
140 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, 'newAnchor1' , '/', json, now)
141 then: 'since there is no data a data node not found exception is thrown'
142 thrown(DataNodeNotFoundException)
145 def 'Attempt to save top level data node that already exist'() {
146 when: 'attempt to save already existing top level node'
147 def json = '{"bookstore": {} }'
148 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, json, now)
149 then: 'an exception that (one cps paths is) already defined is thrown '
150 def exceptionThrown = thrown(AlreadyDefinedException)
151 exceptionThrown.alreadyDefinedObjectNames == ['/bookstore' ] as Set
153 restoreBookstoreDataAnchor(1)
156 def 'Delete a single datanode with invalid path.'() {
157 when: 'attempt to delete a single datanode with invalid path'
158 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/invalid path', now)
159 then: 'a cps path parser exception is thrown'
160 thrown(CpsPathException)
163 def 'Delete multiple data nodes with invalid path.'() {
164 when: 'attempt to delete datanode collection with invalid path'
165 objectUnderTest.deleteDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, ['/invalid path'], now)
166 then: 'the error is silently ignored'
170 def 'Delete single data node with non-existing path.'() {
171 when: 'attempt to delete a single datanode non-existing invalid path'
172 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/does/not/exist', now)
173 then: 'a datanode not found exception is thrown'
174 thrown(DataNodeNotFoundException)
177 def 'Delete multiple data nodes with non-existing path(s).'() {
178 when: 'attempt to delete a single datanode non-existing invalid path'
179 objectUnderTest.deleteDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, ['/does/not/exist'], now)
180 then: 'a datanode not found (batch) exception is thrown'
181 thrown(DataNodeNotFoundExceptionBatch)
184 def 'Add and Delete top-level list (element) data nodes with root node.'() {
185 given: 'a new (multiple-data-tree:invoice) datanodes'
186 def json = '{"bookstore-address":[{"bookstore-name":"Scholastic","address":"Bangalore,India","postal-code":"560043"}]}'
187 when: 'the new list elements are saved'
188 objectUnderTest.saveListElements(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/', json, now)
189 then: 'they can be retrieved by their xpaths'
190 objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore-address[@bookstore-name="Easons"]', INCLUDE_ALL_DESCENDANTS)
191 and: 'there is one extra datanode'
192 assert originalCountBookstoreTopLevelListNodes + 1 == countTopLevelListDataNodesInBookstore()
193 when: 'the new elements are deleted'
194 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore-address[@bookstore-name="Easons"]', now)
195 then: 'the original number of datanodes is restored'
196 assert originalCountBookstoreTopLevelListNodes == countTopLevelListDataNodesInBookstore()
199 def 'Add and Delete list (element) data nodes.'() {
200 given: 'two new (categories) data nodes'
201 def json = '{"categories": [ {"code":"new1"}, {"code":"new2" } ] }'
202 when: 'the new list elements are saved'
203 objectUnderTest.saveListElements(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', json, now)
204 then: 'they can be retrieved by their xpaths'
205 objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new1"]', DIRECT_CHILDREN_ONLY).size() == 1
206 objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new2"]', DIRECT_CHILDREN_ONLY).size() == 1
207 and: 'there are now two extra data nodes'
208 assert originalCountBookstoreChildNodes + 2 == countDataNodesInBookstore()
209 when: 'the new elements are deleted'
210 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new1"]', now)
211 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new2"]', now)
212 then: 'the original number of data nodes is restored'
213 assert originalCountBookstoreChildNodes == countDataNodesInBookstore()
216 def 'Add list (element) data nodes that already exist.'() {
217 given: 'two (categories) data nodes, one new and one existing'
218 def json = '{"categories": [ {"code":"1"}, {"code":"new1"} ] }'
219 when: 'attempt to save the list element'
220 objectUnderTest.saveListElements(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', json, now)
221 then: 'an exception that (one cps paths is) already defined is thrown '
222 def exceptionThrown = thrown(AlreadyDefinedException)
223 exceptionThrown.alreadyDefinedObjectNames == ['/bookstore/categories[@code=\'1\']' ] as Set
224 and: 'there is now one extra data nodes'
225 assert originalCountBookstoreChildNodes + 1 == countDataNodesInBookstore()
227 restoreBookstoreDataAnchor(1)
230 def 'Add and Delete list (element) data nodes using lists specific method.'() {
231 given: 'a new (categories) data nodes'
232 def json = '{"categories": [ {"code":"new1"} ] }'
233 and: 'the new list element is saved'
234 objectUnderTest.saveListElements(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', json, now)
235 when: 'the new element is deleted'
236 objectUnderTest.deleteListOrListElement(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new1"]', now)
237 then: 'the original number of data nodes is restored'
238 assert originalCountBookstoreChildNodes == countDataNodesInBookstore()
241 def 'Add and Delete a batch of lists (element) data nodes.'() {
242 given: 'two new (categories) data nodes in two separate batches'
243 def json1 = '{"categories": [ {"code":"new1"} ] }'
244 def json2 = '{"categories": [ {"code":"new2"} ] } '
245 when: 'the batches of new list element(s) are saved'
246 objectUnderTest.saveListElementsBatch(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', [json1, json2], now)
247 then: 'they can be retrieved by their xpaths'
248 assert objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new1"]', DIRECT_CHILDREN_ONLY).size() == 1
249 assert objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new2"]', DIRECT_CHILDREN_ONLY).size() == 1
250 and: 'there are now two extra data nodes'
251 assert originalCountBookstoreChildNodes + 2 == countDataNodesInBookstore()
252 when: 'the new elements are deleted'
253 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new1"]', now)
254 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new2"]', now)
255 then: 'the original number of data nodes is restored'
256 assert originalCountBookstoreChildNodes == countDataNodesInBookstore()
259 def 'Add and Delete a batch of lists (element) data nodes with partial success.'() {
260 given: 'two new (categories) data nodes in two separate batches'
261 def jsonNewElement = '{"categories": [ {"code":"new1"} ] }'
262 def jsonExistingElement = '{"categories": [ {"code":"1"} ] } '
263 when: 'the batches of new list element(s) are saved'
264 objectUnderTest.saveListElementsBatch(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', [jsonNewElement, jsonExistingElement], now)
265 then: 'an already defined (batch) exception is thrown for the existing path'
266 def exceptionThrown = thrown(AlreadyDefinedException)
267 assert exceptionThrown.alreadyDefinedObjectNames == ['/bookstore/categories[@code=\'1\']' ] as Set
268 and: 'there is now one extra data node'
269 assert originalCountBookstoreChildNodes + 1 == countDataNodesInBookstore()
271 restoreBookstoreDataAnchor(1)
274 def 'Attempt to add empty lists.'() {
275 when: 'the batches of new list element(s) are saved'
276 objectUnderTest.replaceListContent(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', [ ], now)
277 then: 'an admin exception is thrown'
278 thrown(CpsAdminException)
281 def 'Add child error scenario: #scenario.'() {
282 when: 'attempt to add a child data node with #scenario'
283 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, parentXpath, json, now)
284 then: 'a #expectedException is thrown'
285 thrown(expectedException)
286 where: 'the following data is used'
287 scenario | parentXpath | json || expectedException
288 'parent does not exist' | '/bookstore/categories[@code="unknown"]' | '{"books": [ {"title":"new"} ] } ' || DataNodeNotFoundException
289 'already existing child' | '/bookstore' | '{"categories": [ {"code":"1"} ] }' || AlreadyDefinedException
292 def 'Add multiple child data nodes with partial success.'() {
293 given: 'one existing and one new list element'
294 def json = '{"categories": [ {"code":"1"}, {"code":"new"} ] }'
295 when: 'attempt to add the elements'
296 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', json, now)
297 then: 'an already defined (batch) exception is thrown for the existing path'
298 def thrown = thrown(AlreadyDefinedException)
299 assert thrown.alreadyDefinedObjectNames == [ "/bookstore/categories[@code='1']" ] as Set
300 and: 'the new data node has been added i.e. can be retrieved'
301 assert objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new"]', DIRECT_CHILDREN_ONLY).size() == 1
304 def 'Replace list content #scenario.'() {
305 given: 'the bookstore categories 1 and 2 exist and have at least 1 child each '
306 assert countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="1"]', DIRECT_CHILDREN_ONLY)) > 1
307 assert countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="2"]', DIRECT_CHILDREN_ONLY)) > 1
308 when: 'the categories list is replaced with just category "1" and without child nodes (books)'
309 def json = '{"categories": [ {"code":"' +categoryCode + '"' + childJson + '} ] }'
310 objectUnderTest.replaceListContent(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', json, now)
311 then: 'the new replaced category can be retrieved but has no children anymore'
312 assert expectedNumberOfDataNodes == countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="' +categoryCode + '"]', DIRECT_CHILDREN_ONLY))
313 when: 'attempt to retrieve a category (code) not in the new list'
314 objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="2"]', DIRECT_CHILDREN_ONLY)
315 then: 'a datanode not found exception occurs'
316 thrown(DataNodeNotFoundException)
318 restoreBookstoreDataAnchor(1)
319 where: 'the following data is used'
320 scenario | categoryCode | childJson || expectedNumberOfDataNodes
321 'existing code, no children' | '1' | '' || 1
322 'existing code, new child' | '1' | ', "books" : [ { "title": "New Book" } ]' || 2
323 'existing code, existing child' | '1' | ', "books" : [ { "title": "Matilda" } ]' || 2
324 'new code, new child' | 'new' | ', "books" : [ { "title": "New Book" } ]' || 2
327 def 'Update multiple data node leaves.'() {
328 given: 'Updated json for bookstore data'
329 def jsonData = "{'book-store:books':{'lang':'English/French','price':100,'title':'Matilda'}}"
330 when: 'update is performed for leaves'
331 objectUnderTest.updateNodeLeaves(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_2, "/bookstore/categories[@code='1']", jsonData, now)
332 then: 'the updated data nodes are retrieved'
333 def result = cpsDataService.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_2, "/bookstore/categories[@code=1]/books[@title='Matilda']", INCLUDE_ALL_DESCENDANTS)
334 and: 'the leaf values are updated as expected'
335 assert result.leaves['lang'] == ['English/French']
336 assert result.leaves['price'] == [100]
338 restoreBookstoreDataAnchor(2)
341 def 'Update data node leaves for node that has no leaves (yet).'() {
342 given: 'new (webinfo) datanode without leaves'
343 def json = '{"webinfo": {} }'
344 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', json, now)
345 when: 'update is performed to add a leaf'
346 def updatedJson = '{"webinfo": {"domain-name":"new leaf data"}}'
347 objectUnderTest.updateNodeLeaves(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, "/bookstore", updatedJson, now)
348 then: 'the updated data nodes are retrieved'
349 def result = cpsDataService.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, "/bookstore/webinfo", INCLUDE_ALL_DESCENDANTS)
350 and: 'the leaf value is updated as expected'
351 assert result.leaves['domain-name'] == ['new leaf data']
353 restoreBookstoreDataAnchor(1)
356 def 'Update multiple data leaves error scenario: #scenario.'() {
357 when: 'attempt to update data node for #scenario'
358 objectUnderTest.updateNodeLeaves(dataspaceName, anchorName, xpath, 'irrelevant json data', now)
359 then: 'a #expectedException is thrown'
360 thrown(expectedException)
361 where: 'the following data is used'
362 scenario | dataspaceName | anchorName | xpath || expectedException
363 'invalid dataspace name' | 'Invalid Dataspace' | 'not-relevant' | '/not relevant' || DataValidationException
364 'invalid anchor name' | FUNCTIONAL_TEST_DATASPACE_1 | 'INVALID ANCHOR' | '/not relevant' || DataValidationException
365 'non-existing dataspace' | 'non-existing-dataspace' | 'not-relevant' | '/not relevant' || DataspaceNotFoundException
366 'non-existing anchor' | FUNCTIONAL_TEST_DATASPACE_1 | 'non-existing-anchor' | '/not relevant' || AnchorNotFoundException
367 'non-existing-xpath' | FUNCTIONAL_TEST_DATASPACE_1 | BOOKSTORE_ANCHOR_1 | '/non-existing' || DataValidationException
370 def 'Update data nodes and descendants.'() {
371 given: 'some web info for the bookstore'
372 def json = '{"webinfo": {"domain-name":"ourbookstore.com" ,"contact-email":"info@ourbookstore.com" }}'
373 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', json, now)
374 when: 'the webinfo (container) is updated'
375 json = '{"webinfo": {"domain-name":"newdomain.com" ,"contact-email":"info@newdomain.com" }}'
376 objectUnderTest.updateDataNodeAndDescendants(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', json, now)
377 then: 'webinfo has been updated with teh new details'
378 def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/webinfo', DIRECT_CHILDREN_ONLY)
379 result.leaves.'domain-name'[0] == 'newdomain.com'
380 result.leaves.'contact-email'[0] == 'info@newdomain.com'
382 restoreBookstoreDataAnchor(1)
385 def countDataNodesInBookstore() {
386 return countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', INCLUDE_ALL_DESCENDANTS))
389 def countTopLevelListDataNodesInBookstore() {
390 return countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/', INCLUDE_ALL_DESCENDANTS))