summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest/src
diff options
context:
space:
mode:
authorDylanB95EST <dylan.byrne@est.tech>2022-07-19 11:36:10 +0100
committerDylanB95EST <dylan.byrne@est.tech>2022-07-28 15:34:27 +0100
commit6ddbe4af2b73a306dec89e55b8350c09b8c5766b (patch)
tree51532d5e27374191f1389f9da45582eafc82163e /cps-ncmp-rest/src
parentfe835cb6e0030c00d08f9eb84c3f7bb2b3d90c2e (diff)
Enable/Disable Data Sync for Cm Handle
-Create API Which will enable/disable data sync enabled flag -Default functionality of module sync watchdog is to set to false -Remove global config param -Will set initial sync state based on data sync enabled flag -Throws an Exception if the same data sync enabled flag tries to be set -Throws Exception if state is not in READY -Data Sync enabled must be true to complete data sync process - Delete all resource data within fragment table related to synced cm handle when data sync is set to false Issue-ID: CPS-1133 Change-Id: Ib47bbd8293f083c1d705d91bd0def74e6a105c72 Signed-off-by: DylanB95EST <dylan.byrne@est.tech>
Diffstat (limited to 'cps-ncmp-rest/src')
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java14
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy14
2 files changed, 28 insertions, 0 deletions
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index b20487119..d2ed39379 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -320,6 +320,20 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
return new ResponseEntity<>(restModuleReferences, HttpStatus.OK);
}
+ /**
+ * Set the data sync enabled flag, along with the data sync state for the specified cm handle.
+ *
+ * @param cmHandleId cm handle id
+ * @param dataSyncEnabledFlag data sync enabled flag
+ * @return response entity ok if request is successful
+ */
+ @Override
+ public ResponseEntity<Object> setDataSyncEnabledFlagForCmHandle(final String cmHandleId,
+ final Boolean dataSyncEnabledFlag) {
+ networkCmProxyDataService.setDataSyncEnabled(cmHandleId, dataSyncEnabledFlag);
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
private RestOutputCmHandle toRestOutputCmHandle(final NcmpServiceCmHandle ncmpServiceCmHandle) {
final RestOutputCmHandle restOutputCmHandle = new RestOutputCmHandle();
final CmHandlePublicProperties cmHandlePublicProperties = new CmHandlePublicProperties();
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
index 23263c9aa..fde3087be 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
@@ -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()