aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-08-16 13:05:51 +0000
committerGerrit Code Review <gerrit@onap.org>2019-08-16 13:05:51 +0000
commit27eb14bb20dddcbb3a1ef6abbc5adedbb628c5bd (patch)
treefbc476a6c2fd8b13536fa8992b951cc54eaa56d6 /asdc-controller/src
parent1dd013480975fdfbae36fe71d37e845679d5690c (diff)
parent185461225e4a1fb6f2ad1624931de3164e834e9c (diff)
Merge "asdc controller treat distributionid as requestid"
Diffstat (limited to 'asdc-controller/src')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java6
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java31
2 files changed, 37 insertions, 0 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
index 3b9406a697..073412133c 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
@@ -37,6 +37,7 @@ import java.nio.file.Paths;
import java.util.List;
import java.util.Optional;
import org.onap.so.logger.LoggingAnchor;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.sdc.api.IDistributionClient;
import org.onap.sdc.api.consumer.IDistributionStatusMessage;
import org.onap.sdc.api.consumer.IFinalDistrStatusMessage;
@@ -71,6 +72,7 @@ import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ObjectOptimisticLockingFailureException;
import org.springframework.stereotype.Component;
@@ -588,6 +590,10 @@ public class ASDCController {
logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_RECEIVE_CALLBACK_NOTIF.toString(),
String.valueOf(noOfArtifacts), iNotif.getServiceUUID(), "ASDC");
try {
+
+ if (iNotif.getDistributionID() != null && !iNotif.getDistributionID().isEmpty()) {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, iNotif.getDistributionID());
+ }
logger.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif));
logger.info(LoggingAnchor.FOUR, MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), iNotif.getServiceUUID(),
"ASDC", "treatNotification");
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
index 0681cd8aed..055968cc95 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
@@ -33,6 +33,7 @@ import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.asdc.BaseTest;
import org.onap.so.asdc.client.exceptions.ASDCControllerException;
import org.onap.so.asdc.client.test.emulators.ArtifactInfoImpl;
@@ -55,6 +56,7 @@ import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@@ -277,6 +279,35 @@ public class ASDCControllerITTest extends BaseTest {
}
}
+ /**
+ * Test to check RequestId is being set using the DistributionID.
+ */
+ @Test
+ public void treatNotification_verifyRequestID() {
+
+ String serviceUuid = "efaea486-561f-4159-9191-a8d3cb346728";
+ String serviceInvariantUuid = "f2edfbf4-bb0a-4fe7-a57a-71362d4b0b23";
+ distributionId = "bb15de12-166d-4e45-9e5f-4b3f25200d7b";
+
+ initMockAaiServer(serviceUuid, serviceInvariantUuid);
+
+ NotificationDataImpl notificationData = new NotificationDataImpl();
+ notificationData.setServiceUUID(serviceUuid);
+ notificationData.setDistributionID(distributionId);
+ notificationData.setServiceInvariantUUID(serviceInvariantUuid);
+ notificationData.setServiceVersion("1.0");
+
+ try {
+ asdcController.treatNotification(notificationData);
+ logger.info("Verify RequestId : {}", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID));
+ assertEquals("bb15de12-166d-4e45-9e5f-4b3f25200d7b", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID));
+
+ } catch (Exception e) {
+ logger.info(e.getMessage(), e);
+ fail(e.getMessage());
+ }
+ }
+
private ArtifactInfoImpl constructPnfServiceArtifact() {
ArtifactInfoImpl artifactInfo = new ArtifactInfoImpl();
artifactInfo.setArtifactType(ASDCConfiguration.TOSCA_CSAR);