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.AlreadyDefinedExceptionBatch
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 now = OffsetDateTime.now()
49 objectUnderTest = cpsDataService
50 originalCountBookstoreChildNodes = countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', DIRECT_CHILDREN_ONLY))
53 def 'Read bookstore top-level container(s) using #fetchDescendantsOption.'() {
54 when: 'get data nodes for bookstore container'
55 def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', fetchDescendantsOption)
56 then: 'the tree consist ouf of #expectNumberOfDataNodes data nodes'
57 assert countDataNodesInTree(result) == expectNumberOfDataNodes
58 and: 'the top level data node has the expected attribute and value'
59 assert result.leaves['bookstore-name'] == ['Easons']
60 and: 'they are from the correct dataspace'
61 assert result.dataspace == [FUNCTIONAL_TEST_DATASPACE_1]
62 and: 'they are from the correct anchor'
63 assert result.anchorName == [BOOKSTORE_ANCHOR_1]
64 where: 'the following option is used'
65 fetchDescendantsOption || expectNumberOfDataNodes
67 DIRECT_CHILDREN_ONLY || 6
68 INCLUDE_ALL_DESCENDANTS || 17
69 new FetchDescendantsOption(2) || 17
72 def 'Read bookstore top-level container(s) using "root" path variations.'() {
73 when: 'get data nodes for bookstore container'
74 def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, root, OMIT_DESCENDANTS)
75 then: 'the tree consist ouf of one data node'
76 assert countDataNodesInTree(result) == 1
77 and: 'the top level data node has the expected attribute and value'
78 assert result.leaves['bookstore-name'] == ['Easons']
79 where: 'the following variations of "root" are used'
83 def 'Read data nodes with error: #cpsPath'() {
84 when: 'attempt to get data nodes using invalid path'
85 objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, cpsPath, DIRECT_CHILDREN_ONLY)
86 then: 'a #expectedException is thrown'
87 thrown(expectedException)
89 cpsPath || expectedException
90 'invalid path' || CpsPathException
91 '/non-existing-path' || DataNodeNotFoundException
94 def 'Read (multiple) data nodes (batch) with #cpsPath'() {
95 when: 'attempt to get data nodes using invalid path'
96 objectUnderTest.getDataNodesForMultipleXpaths(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, [ cpsPath ], DIRECT_CHILDREN_ONLY)
97 then: 'no exception is thrown'
100 cpsPath << [ 'invalid path', '/non-existing-path' ]
103 def 'Delete root data node.'() {
104 when: 'the "root" is deleted'
105 objectUnderTest.deleteDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, [ '/' ], now)
106 and: 'attempt to get the top level data node'
107 objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', DIRECT_CHILDREN_ONLY)
108 then: 'an datanode not found exception is thrown'
109 thrown(DataNodeNotFoundException)
111 restoreBookstoreDataAnchor(1)
114 def 'Add and Delete a (container) data node.'() {
115 given: 'new (webinfo) datanode'
116 def json = '{"webinfo": {"domain-name":"ourbookstore.com" ,"contact-email":"info@ourbookstore.com" }}'
117 when: 'the new datanode is saved'
118 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', json, now)
119 then: 'it can be retrieved by its xpath'
120 def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/webinfo', DIRECT_CHILDREN_ONLY)
121 assert result.size() == 1
122 assert result[0].xpath == '/bookstore/webinfo'
123 and: 'there is now one extra datanode'
124 assert originalCountBookstoreChildNodes + 1 == countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', DIRECT_CHILDREN_ONLY))
125 when: 'the new datanode is deleted'
126 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/webinfo', now)
127 then: 'the original number of data nodes is restored'
128 assert originalCountBookstoreChildNodes == countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', DIRECT_CHILDREN_ONLY))
131 def 'Attempt to create a top level data node using root.'() {
132 given: 'a new anchor'
133 cpsAdminService.createAnchor(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_SCHEMA_SET, 'newAnchor1');
134 when: 'attempt to save new top level datanode'
135 def json = '{"bookstore": {"bookstore-name": "New Store"} }'
136 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, 'newAnchor1' , '/', json, now)
137 then: 'since there is no data a data node not found exception is thrown'
138 thrown(DataNodeNotFoundException)
141 def 'Attempt to save top level data node that already exist'() {
142 when: 'attempt to save already existing top level node'
143 def json = '{"bookstore": {} }'
144 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, json, now)
145 then: 'an exception that (one cps paths is) already defined is thrown '
146 def exceptionThrown = thrown(AlreadyDefinedExceptionBatch)
147 exceptionThrown.alreadyDefinedXpaths == [ '/bookstore' ] as Set
149 restoreBookstoreDataAnchor(1)
152 def 'Delete a single datanode with invalid path.'() {
153 when: 'attempt to delete a single datanode with invalid path'
154 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/invalid path', now)
155 then: 'a cps path parser exception is thrown'
156 thrown(CpsPathException)
159 def 'Delete multiple data nodes with invalid path.'() {
160 when: 'attempt to delete datanode collection with invalid path'
161 objectUnderTest.deleteDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, ['/invalid path'], now)
162 then: 'the error is silently ignored'
166 def 'Delete single data node with non-existing path.'() {
167 when: 'attempt to delete a single datanode non-existing invalid path'
168 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/does/not/exist', now)
169 then: 'a datanode not found exception is thrown'
170 thrown(DataNodeNotFoundException)
173 def 'Delete multiple data nodes with non-existing path(s).'() {
174 when: 'attempt to delete a single datanode non-existing invalid path'
175 objectUnderTest.deleteDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, ['/does/not/exist'], now)
176 then: 'a datanode not found (batch) exception is thrown'
177 thrown(DataNodeNotFoundExceptionBatch)
180 def 'Add and Delete list (element) data nodes.'() {
181 given: 'two new (categories) data nodes'
182 def json = '{"categories": [ {"code":"new1"}, {"code":"new2" } ] }'
183 when: 'the new list elements are saved'
184 objectUnderTest.saveListElements(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', json, now)
185 then: 'they can be retrieved by their xpaths'
186 objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new1"]', DIRECT_CHILDREN_ONLY).size() == 1
187 objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new2"]', DIRECT_CHILDREN_ONLY).size() == 1
188 and: 'there are now two extra data nodes'
189 assert originalCountBookstoreChildNodes + 2 == countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', DIRECT_CHILDREN_ONLY))
190 when: 'the new elements are deleted'
191 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new1"]', now)
192 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new2"]', now)
193 then: 'the original number of data nodes is restored'
194 assert originalCountBookstoreChildNodes == countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', DIRECT_CHILDREN_ONLY))
197 def 'Add list (element) data nodes that already exist.'() {
198 given: 'two (categories) data nodes, one new and one existing'
199 def json = '{"categories": [ {"code":"1"}, {"code":"new1"} ] }'
200 when: 'attempt to save the list element'
201 objectUnderTest.saveListElements(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', json, now)
202 then: 'an exception that (one cps paths is) already defined is thrown '
203 def exceptionThrown = thrown(AlreadyDefinedExceptionBatch)
204 exceptionThrown.alreadyDefinedXpaths == [ '/bookstore/categories[@code=\'1\']' ] as Set
205 and: 'there is now one extra data nodes'
206 assert originalCountBookstoreChildNodes + 1 == countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', DIRECT_CHILDREN_ONLY))
208 restoreBookstoreDataAnchor(1)
211 def 'Add and Delete list (element) data nodes using lists specific method.'() {
212 given: 'a new (categories) data nodes'
213 def json = '{"categories": [ {"code":"new1"} ] }'
214 and: 'the new list element is saved'
215 objectUnderTest.saveListElements(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', json, now)
216 when: 'the new element is deleted'
217 objectUnderTest.deleteListOrListElement(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new1"]', now)
218 then: 'the original number of data nodes is restored'
219 assert originalCountBookstoreChildNodes == countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', DIRECT_CHILDREN_ONLY))
222 def 'Add and Delete a batch of lists (element) data nodes.'() {
223 given: 'two new (categories) data nodes in two separate batches'
224 def json1 = '{"categories": [ {"code":"new1"} ] }'
225 def json2 = '{"categories": [ {"code":"new2"} ] } '
226 when: 'the batches of new list element(s) are saved'
227 objectUnderTest.saveListElementsBatch(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', [json1, json2], now)
228 then: 'they can be retrieved by their xpaths'
229 assert objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new1"]', DIRECT_CHILDREN_ONLY).size() == 1
230 assert objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new2"]', DIRECT_CHILDREN_ONLY).size() == 1
231 and: 'there are now two extra data nodes'
232 assert originalCountBookstoreChildNodes + 2 == countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', DIRECT_CHILDREN_ONLY))
233 when: 'the new elements are deleted'
234 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new1"]', now)
235 objectUnderTest.deleteDataNode(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new2"]', now)
236 then: 'the original number of data nodes is restored'
237 assert originalCountBookstoreChildNodes == countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', DIRECT_CHILDREN_ONLY))
240 def 'Add and Delete a batch of lists (element) data nodes with partial success.'() {
241 given: 'two new (categories) data nodes in two separate batches'
242 def jsonNewElement = '{"categories": [ {"code":"new1"} ] }'
243 def jsonExistingElement = '{"categories": [ {"code":"1"} ] } '
244 when: 'the batches of new list element(s) are saved'
245 objectUnderTest.saveListElementsBatch(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', [jsonNewElement, jsonExistingElement], now)
246 then: 'an already defined (batch) exception is thrown for the existing path'
247 def exceptionThrown = thrown(AlreadyDefinedExceptionBatch)
248 assert exceptionThrown.alreadyDefinedXpaths == [ '/bookstore/categories[@code=\'1\']' ] as Set
249 and: 'there is now one extra data node'
250 assert originalCountBookstoreChildNodes + 1 == countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', DIRECT_CHILDREN_ONLY))
252 restoreBookstoreDataAnchor(1)
255 def 'Attempt to add empty lists.'() {
256 when: 'the batches of new list element(s) are saved'
257 objectUnderTest.replaceListContent(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', [ ], now)
258 then: 'an admin exception is thrown'
259 thrown(CpsAdminException)
262 def 'Add child error scenario: #scenario.'() {
263 when: 'attempt to add a child data node with #scenario'
264 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, parentXpath, json, now)
265 then: 'a #expectedException is thrown'
266 thrown(expectedException)
267 where: 'the following data is used'
268 scenario | parentXpath | json || expectedException
269 'parent does not exist' | '/bookstore/categories[@code="unknown"]' | '{"books": [ {"title":"new"} ] } ' || DataNodeNotFoundException
270 'already existing child' | '/bookstore' | '{"categories": [ {"code":"1"} ] }' || AlreadyDefinedExceptionBatch
273 def 'Add multiple child data nodes with partial success.'() {
274 given: 'one existing and one new list element'
275 def json = '{"categories": [ {"code":"1"}, {"code":"new"} ] }'
276 when: 'attempt to add the elements'
277 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', json, now)
278 then: 'an already defined (batch) exception is thrown for the existing path'
279 def thrown = thrown(AlreadyDefinedExceptionBatch)
280 assert thrown.alreadyDefinedXpaths == [ "/bookstore/categories[@code='1']" ] as Set
281 and: 'the new data node has been added i.e. can be retrieved'
282 assert objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="new"]', DIRECT_CHILDREN_ONLY).size() == 1
285 def 'Replace list content #scenario.'() {
286 given: 'the bookstore categories 1 and 2 exist and have at least 1 child each '
287 assert countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="1"]', DIRECT_CHILDREN_ONLY)) > 1
288 assert countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="2"]', DIRECT_CHILDREN_ONLY)) > 1
289 when: 'the categories list is replaced with just category "1" and without child nodes (books)'
290 def json = '{"categories": [ {"code":"' +categoryCode + '"' + childJson + '} ] }'
291 objectUnderTest.replaceListContent(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', json, now)
292 then: 'the new replaced category can be retrieved but has no children anymore'
293 assert expectedNumberOfDataNodes == countDataNodesInTree(objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="' +categoryCode + '"]', DIRECT_CHILDREN_ONLY))
294 when: 'attempt to retrieve a category (code) not in the new list'
295 objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories[@code="2"]', DIRECT_CHILDREN_ONLY)
296 then: 'a datanode not found exception occurs'
297 thrown(DataNodeNotFoundException)
299 restoreBookstoreDataAnchor(1)
300 where: 'the following data is used'
301 scenario | categoryCode | childJson || expectedNumberOfDataNodes
302 'existing code, no children' | '1' | '' || 1
303 'existing code, new child' | '1' | ', "books" : [ { "title": "New Book" } ]' || 2
304 'existing code, existing child' | '1' | ', "books" : [ { "title": "Matilda" } ]' || 2
305 'new code, new child' | 'new' | ', "books" : [ { "title": "New Book" } ]' || 2
308 def 'Update multiple data node leaves.'() {
309 given: 'Updated json for bookstore data'
310 def jsonData = "{'book-store:books':{'lang':'English/French','price':100,'title':'Matilda'}}"
311 when: 'update is performed for leaves'
312 objectUnderTest.updateNodeLeaves(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_2, "/bookstore/categories[@code='1']", jsonData, now)
313 then: 'the updated data nodes are retrieved'
314 def result = cpsDataService.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_2, "/bookstore/categories[@code=1]/books[@title='Matilda']", INCLUDE_ALL_DESCENDANTS)
315 and: 'the leaf values are updated as expected'
316 assert result.leaves['lang'] == ['English/French']
317 assert result.leaves['price'] == [100]
319 restoreBookstoreDataAnchor(2)
322 def 'Update data node leaves for node that has no leaves (yet).'() {
323 given: 'new (webinfo) datanode without leaves'
324 def json = '{"webinfo": {} }'
325 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', json, now)
326 when: 'update is performed to add a leaf'
327 def updatedJson = '{"webinfo": {"domain-name":"new leaf data"}}'
328 objectUnderTest.updateNodeLeaves(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, "/bookstore", updatedJson, now)
329 then: 'the updated data nodes are retrieved'
330 def result = cpsDataService.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, "/bookstore/webinfo", INCLUDE_ALL_DESCENDANTS)
331 and: 'the leaf value is updated as expected'
332 assert result.leaves['domain-name'] == ['new leaf data']
334 restoreBookstoreDataAnchor(1)
337 def 'Update multiple data leaves error scenario: #scenario.'() {
338 when: 'attempt to update data node for #scenario'
339 objectUnderTest.updateNodeLeaves(dataspaceName, anchorName, xpath, 'irrelevant json data', now)
340 then: 'a #expectedException is thrown'
341 thrown(expectedException)
342 where: 'the following data is used'
343 scenario | dataspaceName | anchorName | xpath || expectedException
344 'invalid dataspace name' | 'Invalid Dataspace' | 'not-relevant' | '/not relevant' || DataValidationException
345 'invalid anchor name' | FUNCTIONAL_TEST_DATASPACE_1 | 'INVALID ANCHOR' | '/not relevant' || DataValidationException
346 'non-existing dataspace' | 'non-existing-dataspace' | 'not-relevant' | '/not relevant' || DataspaceNotFoundException
347 'non-existing anchor' | FUNCTIONAL_TEST_DATASPACE_1 | 'non-existing-anchor' | '/not relevant' || AnchorNotFoundException
348 'non-existing-xpath' | FUNCTIONAL_TEST_DATASPACE_1 | BOOKSTORE_ANCHOR_1 | '/non-existing' || DataValidationException
351 def 'Update data nodes and descendants.'() {
352 given: 'some web info for the bookstore'
353 def json = '{"webinfo": {"domain-name":"ourbookstore.com" ,"contact-email":"info@ourbookstore.com" }}'
354 objectUnderTest.saveData(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1 , '/bookstore', json, now)
355 when: 'the webinfo (container) is updated'
356 json = '{"webinfo": {"domain-name":"newdomain.com" ,"contact-email":"info@newdomain.com" }}'
357 objectUnderTest.updateDataNodeAndDescendants(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore', json, now)
358 then: 'webinfo has been updated with teh new details'
359 def result = objectUnderTest.getDataNodes(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/webinfo', DIRECT_CHILDREN_ONLY)
360 result.leaves.'domain-name'[0] == 'newdomain.com'
361 result.leaves.'contact-email'[0] == 'info@newdomain.com'
363 restoreBookstoreDataAnchor(1)