Enable/Disable Data Sync for Cm Handle
[cps.git] / cps-ncmp-rest / src / test / groovy / org / onap / cps / ncmp / rest / controller / NetworkCmProxyControllerSpec.groovy
index 2cb397d..fde3087 100644 (file)
@@ -423,6 +423,20 @@ class NetworkCmProxyControllerSpec extends Specification {
             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()
@@ -432,7 +446,7 @@ class NetworkCmProxyControllerSpec extends Specification {
 
     def compositeStateTestObject() {
         new CompositeState(cmHandleState: CmHandleState.ADVISED,
-            lockReason: CompositeState.LockReason.builder().lockReasonCategory(LockReasonCategory.LOCKED_MISBEHAVING).details("lock misbehaving details").build(),
+            lockReason: CompositeState.LockReason.builder().lockReasonCategory(LockReasonCategory.LOCKED_MODULE_SYNC_FAILED).details("lock details").build(),
             lastUpdateTime: formattedDateAndTime.toString(),
             dataSyncEnabled: false,
             dataStores: dataStores())
@@ -448,7 +462,7 @@ class NetworkCmProxyControllerSpec extends Specification {
             '"state":',
             '"cmHandleState":"ADVISED"',
             '"reason":"LOCKED_MISBEHAVING"',
-            '"details":"lock misbehaving details"',
+            '"details":"lock details"',
             '"lastUpdateTime":"2022-12-31T20:30:40.000+0000"',
             '"dataSyncEnabled":false',
             '"dataSyncState":',