Merge "Remove CmHandle in DMI-Registry"
[cps.git] / cps-ncmp-service / src / test / groovy / org / onap / cps / ncmp / api / impl / NetworkCmProxyDataServiceImplSpec.groovy
index c6c955f..0760167 100644 (file)
@@ -136,6 +136,21 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
             'create, update and delete'     | [persistenceCmHandle ] | [persistenceCmHandle ] | cmHandlesArray   || 1                         | 1                         | 1
 
     }
+
+    def 'Register a DMI Plugin for the given cmHandle without additional properties.'() {
+        given: 'a registration without cmHandle properties '
+            def dmiPluginRegistration = new DmiPluginRegistration()
+            dmiPluginRegistration.dmiPlugin = 'my-server'
+            persistenceCmHandle.cmHandleID = '123'
+            persistenceCmHandle.cmHandleProperties = null
+            dmiPluginRegistration.createdCmHandles = [persistenceCmHandle ]
+            def expectedJsonData = '{"cm-handles":[{"id":"123","dmi-service-name":"my-server","additional-properties":[]}]}'
+        when: 'registration is updated'
+            objectUnderTest.updateDmiPluginRegistration(dmiPluginRegistration)
+        then: 'the CPS save list node data is invoked with the expected parameters'
+            1 * mockCpsDataService.saveListNodeData('NCMP-Admin', 'ncmp-dmi-registry', '/dmi-registry', expectedJsonData)
+    }
+
     def 'Get resource data for pass-through operational from dmi.'() {
         given: 'xpath'
             def xpath = "/dmi-registry/cm-handles[@id='testCmHandle']"