summaryrefslogtreecommitdiffstats
path: root/common-app-logging/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-logging/src/test')
-rw-r--r--common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java93
1 files changed, 86 insertions, 7 deletions
diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java
index 334a1edee6..793e156d8b 100644
--- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java
+++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java
@@ -20,17 +20,31 @@
package org.openecomp.sdc.common.log.elements;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.PARTNER_NAME;
import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_CLASS_NAME;
import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_END_TIMESTAMP;
import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_OPT_FIELD1;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_OUTGOING_INVOCATION_ID;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SUPPORTABLITY_ACTION;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SUPPORTABLITY_CSAR_UUID;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SUPPORTABLITY_CSAR_VERSION;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SUPPORTABLITY_STATUS_CODE;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SERVICE_INSTANCE_ID;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_TARGET_VIRTUAL_ENTITY;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
-import org.junit.Before;
-import org.junit.Test;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.MDC;
@@ -38,7 +52,7 @@ public class LogFieldsMdcHandlerTest {
private LogFieldsMdcHandler ecompMdcWrapper;
- @Before
+ @BeforeEach
public void init(){
ecompMdcWrapper = new LogFieldsMdcHandler();
ecompMdcWrapper.clear();
@@ -89,10 +103,12 @@ public class LogFieldsMdcHandlerTest {
ecompMdcWrapper.setClassName("class1");
ecompMdcWrapper.setPartnerName("partner1");
ecompMdcWrapper.setOptCustomField1("of1");
+ ecompMdcWrapper.setOutgoingInvocationId("invocationId");
ecompMdcWrapper.clear();
assertNull(MDC.get(MDC_CLASS_NAME));
- assertNull(MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ assertNull(MDC.get(PARTNER_NAME));
assertNull(MDC.get(MDC_OPT_FIELD1));
+ assertNull(MDC.get(MDC_OUTGOING_INVOCATION_ID));
}
@Test
@@ -111,5 +127,68 @@ public class LogFieldsMdcHandlerTest {
assertNull(exp);
}
+ @Test
+ public void testSetterGetterRemove(){
+ ecompMdcWrapper.setErrorCode(200);
+ ecompMdcWrapper.setErrorCategory("errorCategory");
+ ecompMdcWrapper.setTargetEntity("targetEntity");
+ ecompMdcWrapper.setTargetServiceName("targetServiceName");
+ ecompMdcWrapper.setPartnerName("partnerName");
+ ecompMdcWrapper.setServiceInstanceId("serviceInstanceId");
+ ecompMdcWrapper.setServerIPAddress("serverIpAddress");
+ ecompMdcWrapper.setAuditMessage("auditMsg");
+ ecompMdcWrapper.setTargetVirtualEntity("targetVirtualEntity");
+ ecompMdcWrapper.setSupportablityStatusCode("supportablityStatusCode");
+ ecompMdcWrapper.setSupportablityAction("supportablityAction");
+ ecompMdcWrapper.setRemoteHost("remoteHost");
+ ecompMdcWrapper.setSupportablityCsarUUID("csarUUID");
+ ecompMdcWrapper.setSupportablityCsarVersion("csarVersion");
+ ecompMdcWrapper.setSupportablityComponentName("componentName");
+ ecompMdcWrapper.setSupportablityComponentUUID("componentUUID");
+ ecompMdcWrapper.setSupportablityComponentVersion("componentVersion");
+ ecompMdcWrapper.setKeyInvocationId("keyInvocationId");
+
+ assertEquals("200", ecompMdcWrapper.getErrorCode());
+ assertEquals("errorCategory", ecompMdcWrapper.getErrorCategory());
+ assertNotNull(ecompMdcWrapper.getFqdn());
+ assertNotNull(ecompMdcWrapper.getHostAddress());
+ assertEquals("targetEntity", ecompMdcWrapper.getTargetEntity());
+ assertEquals("targetServiceName", ecompMdcWrapper.getTargetServiceName());
+ assertEquals("partnerName", ecompMdcWrapper.getPartnerName());
+ assertEquals("auditMsg", ecompMdcWrapper.getAuditMessage());
+ assertEquals("supportablityStatusCode", ecompMdcWrapper.getSupportablityStatusCode());
+ assertEquals("supportablityAction", ecompMdcWrapper.getSupportablityAction());
+ assertEquals("remoteHost", ecompMdcWrapper.getRemoteHost());
+ assertEquals("serverIpAddress", ecompMdcWrapper.getServerIpAddress());
+ assertEquals("csarUUID", ecompMdcWrapper.getSupportablityCsarUUID());
+ assertEquals("csarVersion", ecompMdcWrapper.getSupportablityCsarVersion());
+ assertEquals("componentName", ecompMdcWrapper.getSupportablityComponentName());
+ assertEquals("componentUUID", ecompMdcWrapper.getSupportablityComponentUUID());
+ assertEquals("componentVersion", ecompMdcWrapper.getSupportablityComponentVersion());
+ assertEquals("keyInvocationId", ecompMdcWrapper.getKeyInvocationId());
+
+ ecompMdcWrapper.removePartnerName();
+ ecompMdcWrapper.removeSupportablityAction();
+ ecompMdcWrapper.removeSupportablityComponentName();
+ ecompMdcWrapper.removeSupportablityComponentUUID();
+ ecompMdcWrapper.removeSupportablityComponentVersion();
+ ecompMdcWrapper.removeSupportablityCsarUUID();
+ ecompMdcWrapper.removeSupportablityCsarVersion();
+ ecompMdcWrapper.removeSupportablityStatusCode();
+ ecompMdcWrapper.removeServiceInstanceId();
+ ecompMdcWrapper.removeTargetVirtualEntity();
+
+ assertNull(MDC.get(PARTNER_NAME));
+ assertNull(MDC.get(MDC_SUPPORTABLITY_ACTION));
+ assertNull(MDC.get(MDC_SUPPORTABLITY_COMPONENT_NAME));
+ assertNull(MDC.get(MDC_SUPPORTABLITY_COMPONENT_UUID));
+ assertNull(MDC.get(MDC_SUPPORTABLITY_COMPONENT_VERSION));
+ assertNull(MDC.get(MDC_SUPPORTABLITY_CSAR_UUID));
+ assertNull(MDC.get(MDC_SUPPORTABLITY_CSAR_VERSION));
+ assertNull(MDC.get(MDC_SUPPORTABLITY_STATUS_CODE));
+ assertNull(MDC.get(MDC_SERVICE_INSTANCE_ID));
+ assertNull(MDC.get(MDC_TARGET_VIRTUAL_ENTITY));
+
+ }
}