aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2020-01-20 21:46:47 +0200
committerIttay Stern <ittay.stern@att.com>2020-01-23 09:01:17 +0000
commit1420dc4929d35ff6ac3f944b931ad600d061dc4e (patch)
tree8c2d7207a5e131f8c301ffbe18c92aec3b04a13f /vid-app-common/src/test/java
parent65e0c52538423d50b3405daa57ffa6f49c6fa2c3 (diff)
Promise Request-id header: Check MDC value if no header
Issue-ID: VID-647 Change-Id: I9ed97742db1f37de68bfcf1b9cd58afc996da7bf Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/test/java')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/filter/PromiseRequestIdFilterTest.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/filter/PromiseRequestIdFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/filter/PromiseRequestIdFilterTest.java
index d67bd618c..f415bfbcb 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/filter/PromiseRequestIdFilterTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/filter/PromiseRequestIdFilterTest.java
@@ -51,9 +51,12 @@ import javax.servlet.http.HttpServletResponse;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer;
+import org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs;
import org.onap.portalsdk.core.web.support.UserUtils;
import org.onap.vid.logging.RequestIdHeader;
+import org.slf4j.MDC;
import org.springframework.mock.web.MockHttpServletResponse;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -70,10 +73,18 @@ public class PromiseRequestIdFilterTest {
private final PromiseRequestIdFilter promiseRequestIdFilter = new PromiseRequestIdFilter();
+ @AfterMethod
+ public void tearDown() {
+ MDC.remove(MDCs.REQUEST_ID);
+ }
+
@Test
- public void givenRequestIdHeader_headerValueNotChanged() throws IOException, ServletException {
+ public void givenMdcValueAndRequestIdHeader_headerValueNotChanged() throws IOException, ServletException {
final String someTxId = "863850e2-8545-4efd-94b8-afba5f52b3d5";
+ final String mdcTxId = "ed752ff1-3970-4f18-8219-2d821fa4eaea";
+
+ MDC.put(MDCs.REQUEST_ID, mdcTxId);
final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of(
anotherHeader, anotherValue,
@@ -122,6 +133,20 @@ public class PromiseRequestIdFilterTest {
}
@Test
+ public void givenMdcValueAndNoRequestIdHeader_headerValueWasFromMDC() throws IOException, ServletException {
+
+ final String mdcTxId = "ed752ff1-3970-4f18-8219-2d821fa4eaea";
+
+ MDC.put(MDCs.REQUEST_ID, mdcTxId);
+
+ final ImmutableMap<String, String> incomingRequestHeaders = ImmutableMap.of(
+ anotherHeader, anotherValue
+ );
+
+ buildRequestThenRunThroughFilterAndAssertResultRequestHeaders(incomingRequestHeaders, specificTxId(mdcTxId));
+ }
+
+ @Test
public void givenTwoRequestIdHeader_onapHeaderValueIsUsed() throws IOException, ServletException {
final String onapTxId = "863850e2-8545-4efd-94b8-AFBA5F52B3D5"; // note mixed case