654377c7c5d59d43304127b118a46f89d0f28ee6
[cps.git] / cps-ncmp-service / src / test / groovy / org / onap / cps / ncmp / api / impl / NetworkCmProxyDataServiceImplRegistrationSpec.groovy
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2021-2023 Nordix Foundation
4  *  Modifications Copyright (C) 2022 Bell Canada
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
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  *  SPDX-License-Identifier: Apache-2.0
19  *  ============LICENSE_END=========================================================
20  */
21
22 package org.onap.cps.ncmp.api.impl
23
24 import com.fasterxml.jackson.databind.ObjectMapper
25 import com.hazelcast.map.IMap
26 import org.onap.cps.api.CpsDataService
27 import org.onap.cps.api.CpsModuleService
28 import org.onap.cps.ncmp.api.NetworkCmProxyCmHandleQueryService
29 import org.onap.cps.ncmp.api.impl.events.lcm.LcmEventsCmHandleStateHandler
30 import org.onap.cps.ncmp.api.impl.exception.DmiRequestException
31 import org.onap.cps.ncmp.api.impl.operations.DmiDataOperations
32 import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel
33 import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
34 import org.onap.cps.ncmp.api.inventory.CmHandleQueries
35 import org.onap.cps.ncmp.api.inventory.CmHandleState
36 import org.onap.cps.ncmp.api.inventory.InventoryPersistence
37 import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse
38 import org.onap.cps.ncmp.api.models.DmiPluginRegistration
39 import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle
40 import org.onap.cps.spi.exceptions.AlreadyDefinedException
41 import org.onap.cps.spi.exceptions.DataNodeNotFoundException
42 import org.onap.cps.spi.exceptions.DataValidationException
43 import org.onap.cps.spi.exceptions.SchemaSetNotFoundException
44 import org.onap.cps.utils.JsonObjectMapper
45 import spock.lang.Shared
46 import spock.lang.Specification
47
48 import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.CM_HANDLE_DOES_NOT_EXIST
49 import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.CM_HANDLE_ALREADY_EXIST
50 import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.CM_HANDLE_INVALID_ID
51 import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.UNKNOWN_ERROR
52 import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.Status
53
54 class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
55
56     @Shared
57     def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: 'some-cm-handle-id')
58
59     def mockCpsModuleService = Mock(CpsModuleService)
60     def spiedJsonObjectMapper = Spy(new JsonObjectMapper(new ObjectMapper()))
61     def mockDmiDataOperations = Mock(DmiDataOperations)
62     def mockNetworkCmProxyDataServicePropertyHandler = Mock(NetworkCmProxyDataServicePropertyHandler)
63     def mockInventoryPersistence = Mock(InventoryPersistence)
64     def mockCmhandleQueries = Mock(CmHandleQueries)
65     def stubbedNetworkCmProxyCmHandlerQueryService = Stub(NetworkCmProxyCmHandleQueryService)
66     def mockLcmEventsCmHandleStateHandler = Mock(LcmEventsCmHandleStateHandler)
67     def mockCpsDataService = Mock(CpsDataService)
68     def mockModuleSyncStartedOnCmHandles = Mock(IMap<String, Object>)
69     def mockTrustLevelPerDmiPlugin = Mock(IMap<String, TrustLevel>)
70     def objectUnderTest = getObjectUnderTest()
71
72     def 'DMI Registration: Create, Update & Delete operations are processed in the right order'() {
73         given: 'a registration with operations of all three types'
74             def dmiRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server')
75             dmiRegistration.setCreatedCmHandles([new NcmpServiceCmHandle(cmHandleId: 'cmhandle-1', publicProperties: ['publicProp1': 'value'], dmiProperties: [:])])
76             dmiRegistration.setUpdatedCmHandles([new NcmpServiceCmHandle(cmHandleId: 'cmhandle-2', publicProperties: ['publicProp1': 'value'], dmiProperties: [:])])
77             dmiRegistration.setRemovedCmHandles(['cmhandle-2'])
78         and: 'cm handles are persisted'
79             mockInventoryPersistence.getYangModelCmHandles(['cmhandle-2']) >> [new YangModelCmHandle()]
80         when: 'registration is processed'
81             objectUnderTest.updateDmiRegistrationAndSyncModule(dmiRegistration)
82         then: 'cm-handles are removed first'
83             1 * objectUnderTest.parseAndRemoveCmHandlesInDmiRegistration(*_)
84         and: 'de-registered cm handle entry is removed from in progress map'
85             1 * mockModuleSyncStartedOnCmHandles.remove('cmhandle-2')
86         then: 'cm-handles are created'
87             1 * objectUnderTest.parseAndCreateCmHandlesInDmiRegistrationAndSyncModules(*_)
88         then: 'cm-handles are updated'
89             1 * mockNetworkCmProxyDataServicePropertyHandler.updateCmHandleProperties(*_)
90     }
91
92     def 'DMI Registration: Response from all operations types are in response'() {
93         given: 'a registration with operations of all three types'
94             def dmiRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server')
95             dmiRegistration.setCreatedCmHandles([new NcmpServiceCmHandle(cmHandleId: 'cmhandle-1', publicProperties: ['publicProp1': 'value'], dmiProperties: [:])])
96             dmiRegistration.setUpdatedCmHandles([new NcmpServiceCmHandle(cmHandleId: 'cmhandle-2', publicProperties: ['publicProp1': 'value'], dmiProperties: [:])])
97             dmiRegistration.setRemovedCmHandles(['cmhandle-2'])
98         and: 'update cm-handles can be processed successfully'
99             def updateResponses = [CmHandleRegistrationResponse.createSuccessResponse('cmhandle-2')]
100             mockNetworkCmProxyDataServicePropertyHandler.updateCmHandleProperties(*_) >> updateResponses
101         and: 'create cm-handles can be processed successfully'
102             def createdResponses = [CmHandleRegistrationResponse.createSuccessResponse('cmhandle-1')]
103             objectUnderTest.parseAndCreateCmHandlesInDmiRegistrationAndSyncModules(*_) >> createdResponses
104         and: 'delete cm-handles can be processed successfully'
105             def removeResponses = [CmHandleRegistrationResponse.createSuccessResponse('cmhandle-3')]
106             objectUnderTest.parseAndRemoveCmHandlesInDmiRegistration(*_) >> removeResponses
107         when: 'registration is processed'
108             def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiRegistration)
109         then: 'response has values from all operations'
110             response.removedCmHandles == removeResponses
111             response.createdCmHandles == createdResponses
112             response.updatedCmHandles == updateResponses
113     }
114
115     def 'Create CM-handle Validation: Registration with valid Service names: #scenario'() {
116         given: 'a registration '
117             def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: dmiPlugin, dmiModelPlugin: dmiModelPlugin,
118                 dmiDataPlugin: dmiDataPlugin)
119             dmiPluginRegistration.createdCmHandles = [ncmpServiceCmHandle]
120         when: 'update registration and sync module is called with correct DMI plugin information'
121             objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
122         then: 'create cm handles registration and sync modules is called with the correct plugin information'
123             1 * objectUnderTest.parseAndCreateCmHandlesInDmiRegistrationAndSyncModules(dmiPluginRegistration)
124         and: 'dmi is added to the trustLevel map'
125             1 * mockTrustLevelPerDmiPlugin.put(dmiPluginRegisteredName, TrustLevel.COMPLETE)
126         where:
127             scenario                          | dmiPlugin  | dmiModelPlugin | dmiDataPlugin | dmiPluginRegisteredName
128             'combined DMI plugin'             | 'service1' | ''             | ''            | 'service1'
129             'data & model DMI plugins'        | ''         | 'service1'     | 'service2'    | 'service2'
130             'data & model using same service' | ''         | 'service1'     | 'service1'    | 'service1'
131     }
132
133     def 'Create CM-handle Validation: Invalid DMI plugin service name with #scenario'() {
134         given: 'a registration '
135             def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: dmiPlugin, dmiModelPlugin: dmiModelPlugin,
136                 dmiDataPlugin: dmiDataPlugin)
137             dmiPluginRegistration.createdCmHandles = [ncmpServiceCmHandle]
138         when: 'registration is called with incorrect DMI plugin information'
139             objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
140         then: 'a DMI Request Exception is thrown with correct message details'
141             def exceptionThrown = thrown(DmiRequestException.class)
142             assert exceptionThrown.getMessage().contains(expectedMessageDetails)
143         and: 'registration is not called'
144             0 * objectUnderTest.parseAndCreateCmHandlesInDmiRegistrationAndSyncModules(dmiPluginRegistration)
145         where:
146             scenario                         | dmiPlugin  | dmiModelPlugin | dmiDataPlugin || expectedMessageDetails
147             'empty DMI plugins'              | ''         | ''             | ''            || 'No DMI plugin service names'
148             'blank DMI plugins'              | ' '        | ' '            | ' '           || 'No DMI plugin service names'
149             'null DMI plugins'               | null       | null           | null          || 'No DMI plugin service names'
150             'all DMI plugins'                | 'service1' | 'service2'     | 'service3'    || 'Cannot register combined plugin service name and other service names'
151             '(combined)DMI and Data Plugin'  | 'service1' | ''             | 'service2'    || 'Cannot register combined plugin service name and other service names'
152             '(combined)DMI and model Plugin' | 'service1' | 'service2'     | ''            || 'Cannot register combined plugin service name and other service names'
153             'only model DMI plugin'          | ''         | 'service1'     | ''            || 'Cannot register just a Data or Model plugin service name'
154             'only data DMI plugin'           | ''         | ''             | 'service1'    || 'Cannot register just a Data or Model plugin service name'
155     }
156
157     def 'Create CM-Handle Successfully: #scenario.'() {
158         given: 'a registration without cm-handle properties'
159             def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server')
160             dmiPluginRegistration.createdCmHandles = [new NcmpServiceCmHandle(cmHandleId: 'cmhandle', dmiProperties: dmiProperties, publicProperties: publicProperties)]
161         when: 'registration is updated'
162             def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
163         then: 'a successful response is received'
164             response.createdCmHandles.size() == 1
165             with(response.createdCmHandles[0]) {
166                 assert it.status == Status.SUCCESS
167                 assert it.cmHandle == 'cmhandle'
168             }
169         and: 'state handler is invoked with the expected parameters'
170             1 * mockLcmEventsCmHandleStateHandler.updateCmHandleStateBatch(_) >> {
171                 args ->
172                     {
173                         def cmHandleStatePerCmHandle = (args[0] as Map)
174                         cmHandleStatePerCmHandle.each {
175                             assert (it.key.id == 'cmhandle'
176                                     && it.key.dmiServiceName == 'my-server'
177                                     && it.value == CmHandleState.ADVISED)
178                         }
179                     }
180             }
181         where:
182             scenario                          | dmiProperties            | publicProperties               || expectedDmiProperties                      | expectedPublicProperties
183             'with dmi & public properties'    | ['dmi-key': 'dmi-value'] | ['public-key': 'public-value'] || '[{"name":"dmi-key","value":"dmi-value"}]' | '[{"name":"public-key","value":"public-value"}]'
184             'with only public properties'     | [:]                      | ['public-key': 'public-value'] || '[]'                                       | '[{"name":"public-key","value":"public-value"}]'
185             'with only dmi properties'        | ['dmi-key': 'dmi-value'] | [:]                            || '[{"name":"dmi-key","value":"dmi-value"}]' | '[]'
186             'without dmi & public properties' | [:]                      | [:]                            || '[]'                                       | '[]'
187     }
188
189     def 'Create CM-Handle Multiple Requests: All cm-handles creation requests are processed with some failures'() {
190         given: 'a registration with three cm-handles to be created'
191             def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server',
192                     createdCmHandles: [new NcmpServiceCmHandle(cmHandleId: 'cmhandle1'),
193                                        new NcmpServiceCmHandle(cmHandleId: 'cmhandle2'),
194                                        new NcmpServiceCmHandle(cmHandleId: 'cmhandle3')])
195         and: 'cm-handle creation is successful for 1st and 3rd; failed for 2nd'
196             def xpath = "somePathWithId[@id='cmhandle2']"
197             mockLcmEventsCmHandleStateHandler.updateCmHandleStateBatch(*_) >> { throw AlreadyDefinedException.forDataNodes([xpath], 'some-context') }
198         when: 'registration is updated to create cm-handles'
199             def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
200         then: 'a response is received for all cm-handles'
201             response.createdCmHandles.size() == 1
202         and: 'all cm-handles creation fails'
203             response.createdCmHandles.each {
204                 assert it.cmHandle == 'cmhandle2'
205                 assert it.status == Status.FAILURE
206                 assert it.registrationError == CM_HANDLE_ALREADY_EXIST
207                 assert it.errorText == 'cm-handle already exists'
208             }
209     }
210
211     def 'Create CM-Handle Error Handling: Registration fails: #scenario'() {
212         given: 'a registration without cm-handle properties'
213             def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server')
214             dmiPluginRegistration.createdCmHandles = [new NcmpServiceCmHandle(cmHandleId: 'cmhandle')]
215         and: 'cm-handler registration fails: #scenario'
216             mockLcmEventsCmHandleStateHandler.updateCmHandleStateBatch(*_) >> { throw exception }
217         when: 'registration is updated'
218             def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
219         then: 'a failure response is received'
220             response.createdCmHandles.size() == 1
221             with(response.createdCmHandles[0]) {
222                 assert it.status == Status.FAILURE
223                 assert it.cmHandle ==  'cmhandle'
224                 assert it.registrationError == expectedError
225                 assert it.errorText == expectedErrorText
226             }
227         where:
228             scenario                                        | exception                                                                      || expectedError           | expectedErrorText
229             'cm-handle already exist'                       | AlreadyDefinedException.forDataNodes(["path[@id='cmhandle']"], 'some-context') || CM_HANDLE_ALREADY_EXIST | 'cm-handle already exists'
230             'unknown exception while registering cm-handle' | new RuntimeException('Failed')                                                 || UNKNOWN_ERROR           | 'Failed'
231     }
232
233     def 'Update CM-Handle: Update Operation Response is added to the response'() {
234         given: 'a registration to update CmHandles'
235             def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server', updatedCmHandles: [{}])
236         and: 'cm-handle updates can be processed successfully'
237             def updateOperationResponse = [CmHandleRegistrationResponse.createSuccessResponse('cm-handle-1'),
238                                            CmHandleRegistrationResponse.createFailureResponse('cm-handle-2', new Exception("Failed")),
239                                            CmHandleRegistrationResponse.createFailureResponse('cm-handle-3', CM_HANDLE_DOES_NOT_EXIST),
240                                            CmHandleRegistrationResponse.createFailureResponse('cm handle 4', CM_HANDLE_INVALID_ID)]
241             mockNetworkCmProxyDataServicePropertyHandler.updateCmHandleProperties(_) >> updateOperationResponse
242         when: 'registration is updated'
243             def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
244         then: 'the response contains updateOperationResponse'
245             assert response.updatedCmHandles.size() == 4
246             assert response.updatedCmHandles.containsAll(updateOperationResponse)
247     }
248
249     def 'Remove CmHandle Successfully: #scenario'() {
250         given: 'a registration'
251             addPersistedYangModelCmHandles(['cmhandle'])
252             def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server',
253                 removedCmHandles: ['cmhandle'])
254         and: '#scenario'
255             mockCpsModuleService.deleteSchemaSetsWithCascade(_, ['cmhandle']) >>
256                 { if (!schemaSetExist) { throw new SchemaSetNotFoundException("", "") } }
257         when: 'registration is updated to delete cmhandle'
258             def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
259         then: 'the cmHandle state is updated to "DELETING"'
260             1 * mockLcmEventsCmHandleStateHandler.updateCmHandleStateBatch(_)
261         and: 'method to delete relevant schema set is called once'
262             1 * mockInventoryPersistence.deleteSchemaSetsWithCascade(_)
263         and: 'method to delete relevant list/list element is called once'
264             1 * mockInventoryPersistence.deleteDataNodes(_)
265         and: 'successful response is received'
266             assert response.removedCmHandles.size() == 1
267             with(response.removedCmHandles[0]) {
268                 assert it.status == Status.SUCCESS
269                 assert it.cmHandle == 'cmhandle'
270             }
271         and: 'the cmHandle state is updated to "DELETED"'
272             1 * mockLcmEventsCmHandleStateHandler.updateCmHandleStateBatch(_)
273         where:
274             scenario                                            | schemaSetExist
275             'schema-set exists and can be deleted successfully' | true
276             'schema-set does not exist'                         | false
277     }
278
279     def 'Remove CmHandle: Partial Success'() {
280         given: 'some unique yang model cm handles'
281             addPersistedYangModelCmHandles(['cmhandle1', 'cmhandle2', 'cmhandle3'])
282         and: 'a registration with three cm-handles to be deleted'
283             def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server',
284                 removedCmHandles: ['cmhandle1', 'cmhandle2', 'cmhandle3'])
285         and: 'cm-handle deletion fails on batch'
286             mockInventoryPersistence.deleteDataNodes(_) >> { throw new RuntimeException("Failed") }
287         and: 'cm-handle deletion is successful for 1st and 3rd; failed for 2nd'
288             mockInventoryPersistence.deleteDataNode("/dmi-registry/cm-handles[@id='cmhandle2']") >> { throw new RuntimeException("Failed") }
289         when: 'registration is updated to delete cmhandles'
290             def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
291         then: 'the cmHandle states are all updated to "DELETING"'
292             1 * mockLcmEventsCmHandleStateHandler.updateCmHandleStateBatch({ assert it.every { entry -> entry.value == CmHandleState.DELETING } })
293         and: 'a response is received for all cm-handles'
294             response.removedCmHandles.size() == 3
295         and: 'successfully de-registered cm handle 1 is removed from in progress map'
296             1 * mockModuleSyncStartedOnCmHandles.remove('cmhandle1')
297         and: 'successfully de-registered cm handle 3 is removed from in progress map even though it was already being removed'
298             1 * mockModuleSyncStartedOnCmHandles.remove('cmhandle3') >> 'already in progress'
299         and: 'failed de-registered cm handle entries should not be removed from in progress map'
300             0 * mockModuleSyncStartedOnCmHandles.remove('cmhandle2')
301         and: '1st and 3rd cm-handle deletes successfully'
302             with(response.removedCmHandles[0]) {
303                 assert it.status == Status.SUCCESS
304                 assert it.cmHandle == 'cmhandle1'
305             }
306             with(response.removedCmHandles[2]) {
307                 assert it.status == Status.SUCCESS
308                 assert it.cmHandle == 'cmhandle3'
309             }
310         and: '2nd cm-handle deletion fails'
311             with(response.removedCmHandles[1]) {
312                 assert it.status == Status.FAILURE
313                 assert it.registrationError == UNKNOWN_ERROR
314                 assert it.errorText == 'Failed'
315                 assert it.cmHandle == 'cmhandle2'
316             }
317         and: 'the cmHandle state is updated to DELETED for 1st and 3rd'
318             1 * mockLcmEventsCmHandleStateHandler.updateCmHandleStateBatch({
319                 assert it.size() == 2
320                 assert it.every { entry -> entry.value == CmHandleState.DELETED }
321             })
322     }
323
324     def 'Remove CmHandle Error Handling: Schema Set Deletion failed'() {
325         given: 'a registration'
326             addPersistedYangModelCmHandles(['cmhandle'])
327             def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server',
328                 removedCmHandles: ['cmhandle'])
329         and: 'schema set batch deletion failed with unknown error'
330             mockInventoryPersistence.deleteSchemaSetsWithCascade(_) >> { throw new RuntimeException('Failed') }
331         and: 'schema set single deletion failed with unknown error'
332             mockInventoryPersistence.deleteSchemaSetWithCascade(_) >> { throw new RuntimeException('Failed') }
333         when: 'registration is updated to delete cmhandle'
334             def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
335         then: 'no exception is thrown'
336             noExceptionThrown()
337         and: 'cm-handle is not deleted'
338             0 * mockInventoryPersistence.deleteDataNodes(_)
339         and: 'the cmHandle state is not updated to "DELETED"'
340             0 * mockLcmEventsCmHandleStateHandler.updateCmHandleStateBatch([yangModelCmHandle: CmHandleState.DELETED])
341         and: 'a failure response is received'
342             assert response.removedCmHandles.size() == 1
343             with(response.removedCmHandles[0]) {
344                 assert it.status == Status.FAILURE
345                 assert it.cmHandle == 'cmhandle'
346                 assert it.errorText == 'Failed'
347                 assert it.registrationError == UNKNOWN_ERROR
348             }
349     }
350
351     def 'Remove CmHandle Error Handling: #scenario'() {
352         given: 'a registration'
353             addPersistedYangModelCmHandles(['cmhandle'])
354             def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server',
355                 removedCmHandles: ['cmhandle'])
356         and: 'cm-handle deletion fails on batch'
357             mockInventoryPersistence.deleteDataNodes(_) >> { throw deleteListElementException }
358         and: 'cm-handle deletion fails on individual delete'
359             mockInventoryPersistence.deleteDataNode(_) >> { throw deleteListElementException }
360         when: 'registration is updated to delete cmhandle'
361             def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration)
362         then: 'a failure response is received'
363             assert response.removedCmHandles.size() == 1
364             with(response.removedCmHandles[0]) {
365                 assert it.status == Status.FAILURE
366                 assert it.cmHandle == 'cmhandle'
367                 assert it.registrationError == expectedError
368                 assert it.errorText == expectedErrorText
369             }
370         and: 'the cm handle state is not updated to "DELETED"'
371             0 * mockLcmEventsCmHandleStateHandler.updateCmHandleStateBatch(_, CmHandleState.DELETED)
372         where:
373             scenario                     | cmHandleId             | deleteListElementException                ||  expectedError           | expectedErrorText
374             'cm-handle does not exist'   | 'cmhandle'             | new DataNodeNotFoundException('', '', '') || CM_HANDLE_DOES_NOT_EXIST | 'cm-handle does not exist'
375             'cm-handle has invalid name' | 'cm handle with space' | new DataValidationException('', '')       || CM_HANDLE_INVALID_ID     | 'cm-handle has an invalid character(s) in id'
376             'an unexpected exception'    | 'cmhandle'             | new RuntimeException('Failed')            || UNKNOWN_ERROR            | 'Failed'
377     }
378
379     def getObjectUnderTest() {
380         return Spy(new NetworkCmProxyDataServiceImpl(spiedJsonObjectMapper, mockDmiDataOperations,
381                 mockNetworkCmProxyDataServicePropertyHandler, mockInventoryPersistence, mockCmhandleQueries,
382                 stubbedNetworkCmProxyCmHandlerQueryService, mockLcmEventsCmHandleStateHandler, mockCpsDataService,
383                 mockModuleSyncStartedOnCmHandles, mockTrustLevelPerDmiPlugin))
384     }
385
386     def addPersistedYangModelCmHandles(ids) {
387         def yangModelCmHandles = ids.collect { new YangModelCmHandle(id:it) }
388         mockInventoryPersistence.getYangModelCmHandles(ids) >> yangModelCmHandles
389     }
390 }