e2261f4b7cdb5dbcda30a07b0490116bc03f20af
[cps.git] /
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2022-2024 Nordix Foundation
4  *  Modifications Copyright (C) 2022 Bell Canada
5  *  Modifications Copyright (C) 2024 TechMahindra Ltd.
6  *  ================================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *  You may obtain a copy of the License at
10  *
11  *        http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  *
19  *  SPDX-License-Identifier: Apache-2.0
20  *  ============LICENSE_END=========================================================
21  */
22
23 package org.onap.cps.ncmp.impl.inventory
24
25 import com.fasterxml.jackson.databind.ObjectMapper
26 import org.onap.cps.api.CpsAnchorService
27 import org.onap.cps.api.CpsDataService
28 import org.onap.cps.api.CpsModuleService
29 import org.onap.cps.impl.utils.CpsValidator
30 import org.onap.cps.ncmp.api.inventory.models.CompositeState
31 import org.onap.cps.ncmp.impl.inventory.models.CmHandleState
32 import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle
33 import org.onap.cps.spi.CascadeDeleteAllowed
34 import org.onap.cps.spi.FetchDescendantsOption
35 import org.onap.cps.spi.exceptions.DataNodeNotFoundException
36 import org.onap.cps.spi.model.DataNode
37 import org.onap.cps.spi.model.ModuleDefinition
38 import org.onap.cps.spi.model.ModuleReference
39 import org.onap.cps.utils.ContentType
40 import org.onap.cps.utils.JsonObjectMapper
41 import org.testcontainers.shaded.com.fasterxml.jackson.databind.introspect.BasicClassIntrospector
42 import spock.lang.Shared
43 import spock.lang.Specification
44
45 import java.time.OffsetDateTime
46 import java.time.ZoneOffset
47 import java.time.format.DateTimeFormatter
48
49 import static org.onap.cps.ncmp.impl.inventory.NcmpPersistence.NCMP_DATASPACE_NAME
50 import static org.onap.cps.ncmp.impl.inventory.NcmpPersistence.NCMP_DMI_REGISTRY_ANCHOR
51 import static org.onap.cps.ncmp.impl.inventory.NcmpPersistence.NCMP_DMI_REGISTRY_PARENT
52 import static org.onap.cps.ncmp.impl.inventory.NcmpPersistence.NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME
53 import static org.onap.cps.ncmp.impl.inventory.NcmpPersistence.NO_TIMESTAMP
54 import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
55 import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS
56
57 class InventoryPersistenceImplSpec extends Specification {
58
59     def spiedJsonObjectMapper = Spy(new JsonObjectMapper(new ObjectMapper()))
60
61     def mockCpsDataService = Mock(CpsDataService)
62
63     def mockCpsModuleService = Mock(CpsModuleService)
64
65     def mockCpsAnchorService = Mock(CpsAnchorService)
66
67     def mockCpsValidator = Mock(CpsValidator)
68
69     def mockCmHandleQueries = Mock(CmHandleQueryService)
70
71     def objectUnderTest = new InventoryPersistenceImpl(spiedJsonObjectMapper, mockCpsDataService, mockCpsModuleService,
72             mockCpsValidator, mockCpsAnchorService, mockCmHandleQueries)
73
74     def formattedDateAndTime = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
75             .format(OffsetDateTime.of(2022, 12, 31, 20, 30, 40, 1, ZoneOffset.UTC))
76
77     def cmHandleId = 'some-cm-handle'
78     def leaves = ["id":cmHandleId,"dmi-service-name":"common service name","dmi-data-service-name":"data service name","dmi-model-service-name":"model service name"]
79     def xpath = "/dmi-registry/cm-handles[@id='some-cm-handle']"
80
81     def cmHandleId2 = 'another-cm-handle'
82     def xpath2 = "/dmi-registry/cm-handles[@id='another-cm-handle']"
83
84     @Shared
85     def childDataNodesForCmHandleWithAllProperties = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='some cm handle']/additional-properties[@name='name1']", leaves: ["name":"name1", "value":"value1"]),
86                                                       new DataNode(xpath: "/dmi-registry/cm-handles[@id='some cm handle']/public-properties[@name='name2']", leaves: ["name":"name2","value":"value2"])]
87
88     @Shared
89     def childDataNodesForCmHandleWithDMIProperties = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='some-cm-handle']/additional-properties[@name='name1']", leaves: ["name":"name1", "value":"value1"])]
90
91     @Shared
92     def childDataNodesForCmHandleWithPublicProperties = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='some-cm-handle']/public-properties[@name='name2']", leaves: ["name":"name2","value":"value2"])]
93
94     @Shared
95     def childDataNodesForCmHandleWithState = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='some-cm-handle']/state", leaves: ['cm-handle-state': 'ADVISED'])]
96
97     def "Retrieve CmHandle using datanode with #scenario."() {
98         given: 'the cps data service returns a data node from the DMI registry'
99             def dataNode = new DataNode(childDataNodes:childDataNodes, leaves: leaves)
100             mockCpsDataService.getDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, xpath, INCLUDE_ALL_DESCENDANTS) >> [dataNode]
101         when: 'retrieving the yang modelled cm handle'
102             def result = objectUnderTest.getYangModelCmHandle(cmHandleId)
103         then: 'the result has the correct id and service names'
104             result.id == cmHandleId
105             result.dmiServiceName == 'common service name'
106             result.dmiDataServiceName == 'data service name'
107             result.dmiModelServiceName == 'model service name'
108         and: 'the expected DMI properties'
109             result.dmiProperties == expectedDmiProperties
110             result.publicProperties == expectedPublicProperties
111         and: 'the state details are returned'
112             result.compositeState.cmHandleState == expectedCompositeState
113         and: 'the CM Handle ID is validated'
114             1 * mockCpsValidator.validateNameCharacters(cmHandleId)
115         where: 'the following parameters are used'
116             scenario                    | childDataNodes                                || expectedDmiProperties                               || expectedPublicProperties                              || expectedCompositeState
117             'no properties'             | []                                            || []                                                  || []                                                    || null
118             'DMI and public properties' | childDataNodesForCmHandleWithAllProperties    || [new YangModelCmHandle.Property("name1", "value1")] || [new YangModelCmHandle.Property("name2", "value2")]   || null
119             'just DMI properties'       | childDataNodesForCmHandleWithDMIProperties    || [new YangModelCmHandle.Property("name1", "value1")] || []                                                    || null
120             'just public properties'    | childDataNodesForCmHandleWithPublicProperties || []                                                  || [new YangModelCmHandle.Property("name2", "value2")]   || null
121             'with state details'        | childDataNodesForCmHandleWithState            || []                                                  || []                                                    || CmHandleState.ADVISED
122     }
123
124     def "Handling missing service names as null."() {
125         given: 'the cps data service returns a data node from the DMI registry with empty child and leaf attributes'
126             def dataNode = new DataNode(childDataNodes:[], leaves: ['id':cmHandleId])
127             mockCpsDataService.getDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, xpath, INCLUDE_ALL_DESCENDANTS) >> [dataNode]
128         when: 'retrieving the yang modelled cm handle'
129             def result = objectUnderTest.getYangModelCmHandle(cmHandleId)
130         then: 'the service names are returned as null'
131             result.dmiServiceName == null
132             result.dmiDataServiceName == null
133             result.dmiModelServiceName == null
134         and: 'the CM Handle ID is validated'
135             1 * mockCpsValidator.validateNameCharacters(cmHandleId)
136     }
137
138     def "Retrieve multiple YangModelCmHandles"() {
139         given: 'the cps data service returns 2 data nodes from the DMI registry'
140             def dataNodes = [new DataNode(xpath: xpath, leaves: ['id': cmHandleId]), new DataNode(xpath: xpath2, leaves: ['id': cmHandleId2])]
141             mockCpsDataService.getDataNodesForMultipleXpaths(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, [xpath, xpath2] , INCLUDE_ALL_DESCENDANTS) >> dataNodes
142         when: 'retrieving the yang modelled cm handle'
143             def results = objectUnderTest.getYangModelCmHandles([cmHandleId, cmHandleId2])
144         then: 'verify both have returned and cmhandleIds are correct'
145             assert results.size() == 2
146             assert results.id.containsAll([cmHandleId, cmHandleId2])
147     }
148
149     def 'Get a Cm Handle Composite State'() {
150         given: 'a valid cm handle id'
151             def cmHandleId = 'Some-Cm-Handle'
152             def dataNode = new DataNode(leaves: ['cm-handle-state': 'ADVISED'])
153         and: 'cps data service returns a valid data node'
154             mockCpsDataService.getDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
155                     '/dmi-registry/cm-handles[@id=\'Some-Cm-Handle\']/state', FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> [dataNode]
156         when: 'get cm handle state is invoked'
157             def result = objectUnderTest.getCmHandleState(cmHandleId)
158         then: 'result has returned the correct cm handle state'
159             result.cmHandleState == CmHandleState.ADVISED
160         and: 'the CM Handle ID is validated'
161             1 * mockCpsValidator.validateNameCharacters(cmHandleId)
162     }
163
164     def 'Update Cm Handle with #scenario State'() {
165         given: 'a cm handle and a composite state'
166             def cmHandleId = 'Some-Cm-Handle'
167             def compositeState = new CompositeState(cmHandleState: cmHandleState, lastUpdateTime: formattedDateAndTime)
168         when: 'update cm handle state is invoked with the #scenario state'
169             objectUnderTest.saveCmHandleState(cmHandleId, compositeState)
170         then: 'update node leaves is invoked with the correct params'
171             1 * mockCpsDataService.updateDataNodeAndDescendants(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, '/dmi-registry/cm-handles[@id=\'Some-Cm-Handle\']', expectedJsonData, _ as OffsetDateTime, ContentType.JSON)
172         where: 'the following states are used'
173             scenario    | cmHandleState          || expectedJsonData
174             'READY'     | CmHandleState.READY    || '{"state":{"cm-handle-state":"READY","last-update-time":"2022-12-31T20:30:40.000+0000"}}'
175             'LOCKED'    | CmHandleState.LOCKED   || '{"state":{"cm-handle-state":"LOCKED","last-update-time":"2022-12-31T20:30:40.000+0000"}}'
176             'DELETING'  | CmHandleState.DELETING || '{"state":{"cm-handle-state":"DELETING","last-update-time":"2022-12-31T20:30:40.000+0000"}}'
177     }
178
179     def 'Update Cm Handles with #scenario States'() {
180         given: 'a map of cm handles composite states'
181             def compositeState1 = new CompositeState(cmHandleState: cmHandleState, lastUpdateTime: formattedDateAndTime)
182             def compositeState2 = new CompositeState(cmHandleState: cmHandleState, lastUpdateTime: formattedDateAndTime)
183         when: 'update cm handle state is invoked with the #scenario state'
184             def cmHandleStateMap = ['Some-Cm-Handle1' : compositeState1, 'Some-Cm-Handle2' : compositeState2]
185             objectUnderTest.saveCmHandleStateBatch(cmHandleStateMap)
186         then: 'update node leaves is invoked with the correct params'
187             1 * mockCpsDataService.updateDataNodesAndDescendants(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, cmHandlesJsonDataMap, _ as OffsetDateTime, ContentType.JSON)
188         where: 'the following states are used'
189             scenario    | cmHandleState          || cmHandlesJsonDataMap
190             'READY'     | CmHandleState.READY    || ['/dmi-registry/cm-handles[@id=\'Some-Cm-Handle1\']':'{"state":{"cm-handle-state":"READY","last-update-time":"2022-12-31T20:30:40.000+0000"}}', '/dmi-registry/cm-handles[@id=\'Some-Cm-Handle2\']':'{"state":{"cm-handle-state":"READY","last-update-time":"2022-12-31T20:30:40.000+0000"}}']
191             'LOCKED'    | CmHandleState.LOCKED   || ['/dmi-registry/cm-handles[@id=\'Some-Cm-Handle1\']':'{"state":{"cm-handle-state":"LOCKED","last-update-time":"2022-12-31T20:30:40.000+0000"}}', '/dmi-registry/cm-handles[@id=\'Some-Cm-Handle2\']':'{"state":{"cm-handle-state":"LOCKED","last-update-time":"2022-12-31T20:30:40.000+0000"}}']
192             'DELETING'  | CmHandleState.DELETING || ['/dmi-registry/cm-handles[@id=\'Some-Cm-Handle1\']':'{"state":{"cm-handle-state":"DELETING","last-update-time":"2022-12-31T20:30:40.000+0000"}}', '/dmi-registry/cm-handles[@id=\'Some-Cm-Handle2\']':'{"state":{"cm-handle-state":"DELETING","last-update-time":"2022-12-31T20:30:40.000+0000"}}']
193     }
194
195     def 'Getting module definitions by module'() {
196         given: 'cps module service returns module definition for module name'
197             def moduleDefinitions = [new ModuleDefinition('moduleName','revision','content')]
198             mockCpsModuleService.getModuleDefinitionsByAnchorAndModule(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME,'some-cmHandle-Id', 'some-module', '2024-01-25') >> moduleDefinitions
199         when: 'get module definitions is invoked with module name'
200             def result = objectUnderTest.getModuleDefinitionsByCmHandleAndModule('some-cmHandle-Id', 'some-module', '2024-01-25')
201         then: 'returned result are the same module definitions as returned from module service'
202             assert result == moduleDefinitions
203         and: 'cm handle id and module name validated'
204             1 * mockCpsValidator.validateNameCharacters('some-cmHandle-Id', 'some-module')
205     }
206
207     def 'Getting module definitions with cm handle id'() {
208         given: 'cps module service returns module definitions for cm handle id'
209             def moduleDefinitions = [new ModuleDefinition('moduleName','revision','content')]
210             mockCpsModuleService.getModuleDefinitionsByAnchorName(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME,'some-cmHandle-Id') >> moduleDefinitions
211         when: 'get module definitions is invoked with cm handle id'
212             def result = objectUnderTest.getModuleDefinitionsByCmHandleId('some-cmHandle-Id')
213         then: 'the returned result are the same module definitions as returned from the module service'
214             assert result == moduleDefinitions
215     }
216
217     def 'Get module references'() {
218         given: 'cps module service returns a collection of module references'
219             def moduleReferences = [new ModuleReference('moduleName','revision','namespace')]
220             mockCpsModuleService.getYangResourcesModuleReferences(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME,'some-cmHandle-Id') >> moduleReferences
221         when: 'get yang resources module references by cmHandle is invoked'
222             def result = objectUnderTest.getYangResourcesModuleReferences('some-cmHandle-Id')
223         then: 'the returned result is a collection of module definitions'
224             assert result == moduleReferences
225         and: 'the CM Handle ID is validated'
226             1 * mockCpsValidator.validateNameCharacters('some-cmHandle-Id')
227     }
228
229     def 'Save Cmhandle'() {
230         given: 'cmHandle represented as Yang Model'
231             def yangModelCmHandle = new YangModelCmHandle(id: 'cmhandle', dmiProperties: [], publicProperties: [])
232         when: 'the method to save cmhandle is called'
233             objectUnderTest.saveCmHandle(yangModelCmHandle)
234         then: 'the data service method to save list elements is called once'
235             1 * mockCpsDataService.saveListElements(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, NCMP_DMI_REGISTRY_PARENT,
236                     _,null, ContentType.JSON) >> {
237                 args -> {
238                     assert args[3].startsWith('{"cm-handles":[{"id":"cmhandle","additional-properties":[],"public-properties":[]}]}')
239                 }
240             }
241     }
242
243     def 'Save Multiple Cmhandles'() {
244         given: 'cm handles represented as Yang Model'
245             def yangModelCmHandle1 = new YangModelCmHandle(id: 'cmhandle1')
246             def yangModelCmHandle2 = new YangModelCmHandle(id: 'cmhandle2')
247         when: 'the cm handles are saved'
248             objectUnderTest.saveCmHandleBatch([yangModelCmHandle1, yangModelCmHandle2])
249         then: 'CPS Data Service persists both cm handles as a batch'
250             1 * mockCpsDataService.saveListElements(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
251                     NCMP_DMI_REGISTRY_PARENT, _,null, ContentType.JSON) >> {
252                 args -> {
253                     def jsonData = (args[3] as String)
254                     jsonData.contains('cmhandle1')
255                     jsonData.contains('cmhandle2')
256                 }
257             }
258     }
259
260     def 'Delete list or list elements'() {
261         when: 'the method to delete list or list elements is called'
262             objectUnderTest.deleteListOrListElement('sample xPath')
263         then: 'the data service method to save list elements is called once'
264             1 * mockCpsDataService.deleteListOrListElement(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,'sample xPath',null)
265     }
266
267     def 'Delete schema set with a valid schema set name'() {
268         when: 'the method to delete schema set is called with valid schema set name'
269             objectUnderTest.deleteSchemaSetWithCascade('validSchemaSetName')
270         then: 'the module service to delete schemaSet is invoked once'
271             1 * mockCpsModuleService.deleteSchemaSet(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'validSchemaSetName', CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED)
272         and: 'the schema set name is validated'
273             1 * mockCpsValidator.validateNameCharacters('validSchemaSetName')
274     }
275
276     def 'Delete multiple schema sets with valid schema set names'() {
277         when: 'the method to delete schema sets is called with valid schema set names'
278             objectUnderTest.deleteSchemaSetsWithCascade(['validSchemaSetName1', 'validSchemaSetName2'])
279         then: 'the module service to delete schema sets is invoked once'
280             1 * mockCpsModuleService.deleteSchemaSetsWithCascade(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, ['validSchemaSetName1', 'validSchemaSetName2'])
281         and: 'the schema set names are validated'
282             1 * mockCpsValidator.validateNameCharacters(['validSchemaSetName1', 'validSchemaSetName2'])
283     }
284
285     def 'Get data node via xPath'() {
286         when: 'the method to get data nodes is called'
287             objectUnderTest.getDataNode('sample xPath')
288         then: 'the data persistence service method to get data node is invoked once'
289             1 * mockCpsDataService.getDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,'sample xPath', INCLUDE_ALL_DESCENDANTS)
290     }
291
292     def 'Get cmHandle data node'() {
293         given: 'expected xPath to get cmHandle data node'
294             def expectedXPath = '/dmi-registry/cm-handles[@id=\'sample cmHandleId\']'
295         when: 'the method to get data nodes is called'
296             objectUnderTest.getCmHandleDataNodeByCmHandleId('sample cmHandleId')
297         then: 'the data persistence service method to get cmHandle data node is invoked once with expected xPath'
298             1 * mockCpsDataService.getDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, expectedXPath, INCLUDE_ALL_DESCENDANTS)
299     }
300
301     def 'Get cm handle data node by alternate id'() {
302         given: 'expected xPath to get cmHandle data node'
303             def expectedXPath = '/dmi-registry/cm-handles[@alternate-id=\'alternate id\']'
304         and: 'query service is invoked with expected xpath'
305             mockCmHandleQueries.queryNcmpRegistryByCpsPath(expectedXPath, OMIT_DESCENDANTS) >> [new DataNode()]
306         expect: 'getting the cm handle data node'
307             assert objectUnderTest.getCmHandleDataNodeByAlternateId('alternate id') == new DataNode()
308     }
309
310     def 'Attempt to get non existing cm handle data node by alternate id'() {
311         given: 'query service is invoked and returns empty collection of data nodes'
312             mockCmHandleQueries.queryNcmpRegistryByCpsPath(*_) >> []
313         when: 'getting the cm handle data node'
314             objectUnderTest.getCmHandleDataNodeByAlternateId('alternate id')
315         then: 'no data found exception thrown'
316             def thrownException = thrown(DataNodeNotFoundException)
317             assert thrownException.getMessage().contains('DataNode not found')
318     }
319
320     def 'Get multiple cm handle data nodes by alternate ids'() {
321         given: 'expected xPath to get cmHandle data node'
322             def expectedXPath = "/dmi-registry/cm-handles[@alternate-id='A' or @alternate-id='B']"
323         when: 'getting the cm handle data node'
324             objectUnderTest.getCmHandleDataNodesByAlternateIds(['A', 'B'])
325         then: 'query service is invoked with expected xpath'
326             1 * mockCmHandleQueries.queryNcmpRegistryByCpsPath(expectedXPath, OMIT_DESCENDANTS)
327     }
328
329     def 'Get multiple cm handle data nodes by alternate ids, passing empty collection'() {
330         when: 'getting the cm handle data node for no alternate ids'
331             objectUnderTest.getCmHandleDataNodesByAlternateIds([])
332         then: 'query service is not invoked'
333             0 * mockCmHandleQueries.queryNcmpRegistryByCpsPath(_, _)
334     }
335
336     def 'Get CM handle ids for CM Handles that has given module names'() {
337         when: 'the method to get cm handles is called'
338             objectUnderTest.getCmHandleReferencesWithGivenModules(['sample-module-name'], false)
339         then: 'the admin persistence service method to query anchors is invoked once with the same parameter'
340             1 * mockCpsAnchorService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, ['sample-module-name'])
341     }
342
343     def 'Get Alternate Ids for CM Handles that has given module names'() {
344         given: 'A Collection of data nodes'
345             def dataNodes = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='ch-1']", leaves: ['id': 'ch-1', 'alternate-id': 'alt-1'])]
346         when: 'the methods to get dataNodes is called and returns correct values'
347             mockCpsAnchorService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, ['sample-module-name']) >> ['ch-1']
348             mockCpsDataService.getDataNodesForMultipleXpaths(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, ["/dmi-registry/cm-handles[@id='ch-1']"], INCLUDE_ALL_DESCENDANTS) >> dataNodes
349         and: 'the method returns a result'
350             def result = objectUnderTest.getCmHandleReferencesWithGivenModules(['sample-module-name'], true)
351         then: 'the result contains the correct alternate Id'
352             assert result == ['alt-1'] as HashSet
353     }
354
355     def 'Replace list content'() {
356         when: 'replace list content method is called with xpath and data nodes collection'
357             objectUnderTest.replaceListContent('sample xpath', [new DataNode()])
358         then: 'the cps data service method to replace list content is invoked once with same parameters'
359             1 * mockCpsDataService.replaceListContent(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,'sample xpath', [new DataNode()], NO_TIMESTAMP);
360     }
361
362     def 'Delete data node via xPath'() {
363         when: 'Delete data node method is called with xpath as parameter'
364             objectUnderTest.deleteDataNode('sample dataNode xpath')
365         then: 'the cps data service method to delete data node is invoked once with the same xPath'
366             1 * mockCpsDataService.deleteDataNode(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, 'sample dataNode xpath', NO_TIMESTAMP);
367     }
368
369     def 'Delete multiple data nodes via xPath'() {
370         when: 'Delete data nodes method is called with multiple xpaths as parameters'
371             objectUnderTest.deleteDataNodes(['xpath1', 'xpath2'])
372         then: 'the cps data service method to delete data nodes is invoked once with the same xPaths'
373             1 * mockCpsDataService.deleteDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, ['xpath1', 'xpath2'], NO_TIMESTAMP);
374     }
375 }