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