summaryrefslogtreecommitdiffstats
path: root/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service
diff options
context:
space:
mode:
Diffstat (limited to 'dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service')
-rw-r--r--dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java21
-rw-r--r--dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml5
2 files changed, 26 insertions, 0 deletions
diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
index a4f7111324..772eb050c6 100644
--- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
+++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
@@ -69,6 +69,15 @@ public class DmiRestStubController {
@Value("${app.ncmp.async-m2m.topic}")
private String ncmpAsyncM2mTopic;
+ @Value("${delay.module-references-delay-ms}")
+ private long moduleReferencesDelayMs;
+
+ @Value("${delay.module-resources-delay-ms}")
+ private long moduleResourcesDelayMs;
+
+ @Value("${delay.data-for-cm-handle-delay-ms}")
+ private long dataForCmHandleDelayMs;
+
private String dataOperationEventType = "org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent";
/**
@@ -82,6 +91,7 @@ public class DmiRestStubController {
@PostMapping("/v1/ch/{cmHandleId}/modules")
public ResponseEntity<String> getModuleReferences(@PathVariable final String cmHandleId,
@RequestBody final Object moduleReferencesRequest) {
+ delay(moduleReferencesDelayMs);
final String moduleResponseContent = getModuleResourceResponse(cmHandleId,
"ModuleResponse.json");
log.info("cm handle: {} requested for modules", cmHandleId);
@@ -100,6 +110,7 @@ public class DmiRestStubController {
public ResponseEntity<String> retrieveModuleResources(
@PathVariable final String cmHandleId,
@RequestBody final Object moduleResourcesReadRequest) {
+ delay(moduleResourcesDelayMs);
final String moduleResourcesResponseContent = getModuleResourceResponse(cmHandleId,
"ModuleResourcesResponse.json");
log.info("cm handle: {} requested for modules resources", cmHandleId);
@@ -121,6 +132,7 @@ public class DmiRestStubController {
final String requestId,
@RequestBody final DmiDataOperationRequest
dmiDataOperationRequest) {
+ delay(dataForCmHandleDelayMs);
try {
log.info("Request received from the NCMP to DMI Plugin: {}",
objectMapper.writeValueAsString(dmiDataOperationRequest));
@@ -199,4 +211,13 @@ public class DmiRestStubController {
return ResourceFileReaderUtil.getResourceFileContent(applicationContext.getResource(
ResourceLoader.CLASSPATH_URL_PREFIX + "module/ietfYang" + moduleResponseType));
}
+
+ private void delay(final long milliseconds) {
+ try {
+ Thread.sleep(milliseconds);
+ } catch (final InterruptedException e) {
+ log.error("Thread sleep interrupted: {}", e.getMessage());
+ Thread.currentThread().interrupt();
+ }
+ }
}
diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml
index 8e39a4e71c..de097a67b4 100644
--- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml
+++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml
@@ -40,3 +40,8 @@ app:
ncmp:
async-m2m:
topic: ${NCMP_ASYNC_M2M_TOPIC:ncmp-async-m2m}
+
+delay:
+ module-references-delay-ms: ${MODULE_REFERENCES_DELAY_MS:100}
+ module-resources-delay-ms: ${MODULE_RESOURCES_DELAY_MS:1000}
+ data-for-cm-handle-delay-ms: ${DATA_FOR_CM_HANDLE_DELAY_MS:2500}