Enable/Disable Data Sync for Cm Handle
[cps.git] / cps-ncmp-rest / src / test / groovy / org / onap / cps / ncmp / rest / controller / NetworkCmProxyControllerSpec.groovy
index 7b123e8..fde3087 100644 (file)
@@ -416,13 +416,27 @@ class NetworkCmProxyControllerSpec extends Specification {
         then: 'ncmp service method to get module definitions is called'
             mockNetworkCmProxyDataService.getModuleDefinitionsByCmHandleId('some-cmhandle')
                     >> [new ModuleDefinition('sampleModuleName', '2021-10-03',
-                    String.format('module sampleModuleName{ %n sample module content %n }'))]
-        and: 'response contains an array with the module name, revision and content where content contains \\n for newlines'
-            response.getContentAsString() == '[{"moduleName":"sampleModuleName","revision":"2021-10-03","content":"module sampleModuleName{ \\n sample module content \\n }"}]'
+                    'module sampleModuleName{ sample module content }')]
+        and: 'response contains an array with the module name, revision and content'
+            response.getContentAsString() == '[{"moduleName":"sampleModuleName","revision":"2021-10-03","content":"module sampleModuleName{ sample module content }"}]'
         and: 'response returns an OK http code'
             response.status == HttpStatus.OK.value()
     }
 
+    def 'Set the data sync enabled based on the cm handle id and the data sync flag is #scenario' () {
+        when: 'the set data sync enabled request is invoked'
+            def response = mvc.perform(put("$ncmpBasePathV1/ch/some-cm-handle-id/data-sync?dataSyncEnabled=" + dataSyncEnabledFlag))
+                    .andReturn().response
+        then: 'method to set data sync enabled is called'
+            1 * mockNetworkCmProxyDataService.setDataSyncEnabled('some-cm-handle-id', dataSyncEnabledFlag)
+        and: 'the response returns an OK http code'
+            response.status == HttpStatus.OK.value()
+        where: 'the following parameters are used'
+        scenario     |  dataSyncEnabledFlag
+        'enabled'    |  true
+        'disabled'   |  false
+    }
+
     def dataStores() {
         DataStores.builder()
             .operationalDataStore(Operational.builder()