summaryrefslogtreecommitdiffstats
path: root/policy-utils
diff options
context:
space:
mode:
Diffstat (limited to 'policy-utils')
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java151
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java180
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java58
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java154
4 files changed, 301 insertions, 242 deletions
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java
index e3b2f8a8..d56e63e6 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java
@@ -20,7 +20,6 @@
package org.onap.policy.drools.utils.logging;
import java.time.Instant;
-import org.onap.policy.common.utils.network.NetworkUtil;
/**
* MDC Transaction Utility Class.
@@ -49,156 +48,6 @@ import org.onap.policy.common.utils.network.NetworkUtil;
* <p>https://wiki.onap.org/pages/viewpage.action?pageId=20087036
*/
public interface MdcTransaction {
- /*
- * The fields must match the naming given at
- * https://wiki.onap.org/pages/viewpage.action?pageId=20087036
- */
-
- /**
- * End to end transaction ID. Subtransactions will inherit this value from the transaction.
- */
- String REQUEST_ID = "RequestID";
-
- /**
- * Invocation ID, ie. SubTransaction ID.
- */
- String INVOCATION_ID = "InvocationID";
-
- /**
- * Service Name. Both transactions and subtransactions will have its own copy.
- */
- String SERVICE_NAME = "ServiceName";
-
- /**
- * Partner Name Subtransactions will inherit this value from the transaction.
- */
- String PARTNER_NAME = "PartnerName";
-
- /**
- * Start Timestamp. Both transactions and subtransactions will have its own copy.
- */
- String BEGIN_TIMESTAMP = "BeginTimestamp";
-
- /**
- * End Timestamp. Both transactions and subtransactions will have its own copy.
- */
- String END_TIMESTAMP = "EndTimestamp";
-
- /**
- * Elapsed Time. Both transactions and subtransactions will have its own copy.
- */
- String ELAPSED_TIME = "ElapsedTime";
-
- /**
- * Elapsed Time. Both transactions and subtransactions will have its own copy.
- */
- String SERVICE_INSTANCE_ID = "ServiceInstanceID";
-
- /**
- * Virtual Server Name. Subtransactions will inherit this value from the transaction.
- */
- String VIRTUAL_SERVER_NAME = "VirtualServerName";
-
- /**
- * Status Code Both transactions and subtransactions will have its own copy.
- */
- String STATUS_CODE = "StatusCode";
-
- /**
- * Response Code Both transactions and subtransactions will have its own copy.
- */
- String RESPONSE_CODE = "ResponseCode";
-
- /**
- * Response Description Both transactions and subtransactions will have its own copy.
- */
- String RESPONSE_DESCRIPTION = "ResponseDescription";
-
- /**
- * Instance UUID Both transactions and subtransactions will have its own copy.
- */
- String INSTANCE_UUID = "InstanceUUID";
-
- /**
- * Severity Both transactions and subtransactions will have its own copy.
- */
- String SEVERITY = "Severity";
-
- /**
- * Target Entity Both transactions and subtransactions will have its own copy.
- */
- String TARGET_ENTITY = "TargetEntity";
-
- /**
- * Target Service Name Both transactions and subtransactions will have its own copy.
- */
- String TARGET_SERVICE_NAME = "TargetServiceName";
-
- /**
- * Server Subtransactions inherit this value. if (this.getSources().size() == 1)
- * this.getSources().get(0).getTopic();
- */
- String SERVER = "Server";
-
- /**
- * Server IP Address Subtransactions inherit this value.
- */
- String SERVER_IP_ADDRESS = "ServerIpAddress";
-
- /**
- * Server FQDN Subtransactions inherit this value.
- */
- String SERVER_FQDN = "ServerFQDN";
-
- /**
- * Client IP Address Both transactions and subtransactions will have its own copy.
- */
- String CLIENT_IP_ADDRESS = "ClientIPAddress";
-
- /**
- * Process Key Both transactions and subtransactions will have its own copy.
- */
- String PROCESS_KEY = "ProcessKey";
-
- /**
- * Remote Host Both transactions and subtransactions will have its own copy.
- */
- String REMOTE_HOST = "RemoteHost";
-
- /**
- * Alert Severity Both transactions and subtransactions will have its own copy.
- */
- String ALERT_SEVERITY = "AlertSeverity";
-
- /**
- * Target Virtual Entity Both transactions and subtransactions will have its own copy.
- */
- String TARGET_VIRTUAL_ENTITY = "TargetVirtualEntity";
-
- /**
- * Default Service Name.
- */
- String DEFAULT_SERVICE_NAME = "PDP-D";
-
- /**
- * Default Host Name.
- */
- String DEFAULT_HOSTNAME = NetworkUtil.getHostname();
-
- /**
- * Default Host IP.
- */
- String DEFAULT_HOSTIP = NetworkUtil.getHostIp();
-
- /**
- * Status Code Complete.
- */
- String STATUS_CODE_COMPLETE = "COMPLETE";
-
- /**
- * Status Code Error.
- */
- String STATUS_CODE_FAILURE = "ERROR";
/**
* reset subtransaction data.
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java
new file mode 100644
index 00000000..ba335958
--- /dev/null
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java
@@ -0,0 +1,180 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * policy-utils
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.policy.drools.utils.logging;
+
+import org.onap.policy.common.utils.network.NetworkUtil;
+
+public class MdcTransactionConstants {
+ /*
+ * The fields must match the naming given at
+ * https://wiki.onap.org/pages/viewpage.action?pageId=20087036
+ */
+
+ /**
+ * End to end transaction ID. Subtransactions will inherit this value from the transaction.
+ */
+ public static final String REQUEST_ID = "RequestID";
+
+ /**
+ * Invocation ID, ie. SubTransaction ID.
+ */
+ public static final String INVOCATION_ID = "InvocationID";
+
+ /**
+ * Service Name. Both transactions and subtransactions will have its own copy.
+ */
+ public static final String SERVICE_NAME = "ServiceName";
+
+ /**
+ * Partner Name Subtransactions will inherit this value from the transaction.
+ */
+ public static final String PARTNER_NAME = "PartnerName";
+
+ /**
+ * Start Timestamp. Both transactions and subtransactions will have its own copy.
+ */
+ public static final String BEGIN_TIMESTAMP = "BeginTimestamp";
+
+ /**
+ * End Timestamp. Both transactions and subtransactions will have its own copy.
+ */
+ public static final String END_TIMESTAMP = "EndTimestamp";
+
+ /**
+ * Elapsed Time. Both transactions and subtransactions will have its own copy.
+ */
+ public static final String ELAPSED_TIME = "ElapsedTime";
+
+ /**
+ * Elapsed Time. Both transactions and subtransactions will have its own copy.
+ */
+ public static final String SERVICE_INSTANCE_ID = "ServiceInstanceID";
+
+ /**
+ * Virtual Server Name. Subtransactions will inherit this value from the transaction.
+ */
+ public static final String VIRTUAL_SERVER_NAME = "VirtualServerName";
+
+ /**
+ * Status Code Both transactions and subtransactions will have its own copy.
+ */
+ public static final String STATUS_CODE = "StatusCode";
+
+ /**
+ * Response Code Both transactions and subtransactions will have its own copy.
+ */
+ public static final String RESPONSE_CODE = "ResponseCode";
+
+ /**
+ * Response Description Both transactions and subtransactions will have its own copy.
+ */
+ public static final String RESPONSE_DESCRIPTION = "ResponseDescription";
+
+ /**
+ * Instance UUID Both transactions and subtransactions will have its own copy.
+ */
+ public static final String INSTANCE_UUID = "InstanceUUID";
+
+ /**
+ * Severity Both transactions and subtransactions will have its own copy.
+ */
+ public static final String SEVERITY = "Severity";
+
+ /**
+ * Target Entity Both transactions and subtransactions will have its own copy.
+ */
+ public static final String TARGET_ENTITY = "TargetEntity";
+
+ /**
+ * Target Service Name Both transactions and subtransactions will have its own copy.
+ */
+ public static final String TARGET_SERVICE_NAME = "TargetServiceName";
+
+ /**
+ * Server Subtransactions inherit this value. if (this.getSources().size() == 1)
+ * this.getSources().get(0).getTopic();
+ */
+ public static final String SERVER = "Server";
+
+ /**
+ * Server IP Address Subtransactions inherit this value.
+ */
+ public static final String SERVER_IP_ADDRESS = "ServerIpAddress";
+
+ /**
+ * Server FQDN Subtransactions inherit this value.
+ */
+ public static final String SERVER_FQDN = "ServerFQDN";
+
+ /**
+ * Client IP Address Both transactions and subtransactions will have its own copy.
+ */
+ public static final String CLIENT_IP_ADDRESS = "ClientIPAddress";
+
+ /**
+ * Process Key Both transactions and subtransactions will have its own copy.
+ */
+ public static final String PROCESS_KEY = "ProcessKey";
+
+ /**
+ * Remote Host Both transactions and subtransactions will have its own copy.
+ */
+ public static final String REMOTE_HOST = "RemoteHost";
+
+ /**
+ * Alert Severity Both transactions and subtransactions will have its own copy.
+ */
+ public static final String ALERT_SEVERITY = "AlertSeverity";
+
+ /**
+ * Target Virtual Entity Both transactions and subtransactions will have its own copy.
+ */
+ public static final String TARGET_VIRTUAL_ENTITY = "TargetVirtualEntity";
+
+ /**
+ * Default Service Name.
+ */
+ public static final String DEFAULT_SERVICE_NAME = "PDP-D";
+
+ /**
+ * Default Host Name.
+ */
+ public static final String DEFAULT_HOSTNAME = NetworkUtil.getHostname();
+
+ /**
+ * Default Host IP.
+ */
+ public static final String DEFAULT_HOSTIP = NetworkUtil.getHostIp();
+
+ /**
+ * Status Code Complete.
+ */
+ public static final String STATUS_CODE_COMPLETE = "COMPLETE";
+
+ /**
+ * Status Code Error.
+ */
+ public static final String STATUS_CODE_FAILURE = "ERROR";
+
+
+ private MdcTransactionConstants() {
+ // do nothing
+ }
+}
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
index 7289cd7a..f10343e2 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
@@ -20,6 +20,36 @@
package org.onap.policy.drools.utils.logging;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.ALERT_SEVERITY;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.BEGIN_TIMESTAMP;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.CLIENT_IP_ADDRESS;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.DEFAULT_HOSTIP;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.DEFAULT_HOSTNAME;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.DEFAULT_SERVICE_NAME;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.ELAPSED_TIME;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.END_TIMESTAMP;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.INSTANCE_UUID;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.INVOCATION_ID;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.PARTNER_NAME;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.PROCESS_KEY;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.REMOTE_HOST;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.REQUEST_ID;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.RESPONSE_CODE;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.RESPONSE_DESCRIPTION;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.SERVER;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.SERVER_FQDN;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.SERVER_IP_ADDRESS;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.SERVICE_INSTANCE_ID;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.SERVICE_NAME;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.SEVERITY;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.STATUS_CODE;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.STATUS_CODE_COMPLETE;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.STATUS_CODE_FAILURE;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.TARGET_ENTITY;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.TARGET_SERVICE_NAME;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.TARGET_VIRTUAL_ENTITY;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.VIRTUAL_SERVER_NAME;
+
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.Instant;
@@ -46,7 +76,7 @@ class MdcTransactionImpl implements MdcTransaction {
private String invocationId;
private String virtualServerName;
- private String server;
+ private String serverName;
private String serverIpAddress;
private String serverFqdn;
@@ -63,7 +93,7 @@ class MdcTransactionImpl implements MdcTransaction {
private String statusCode;
private String responseCode;
private String responseDescription;
- private String severity;
+ private String theSeverity;
private String alertSeverity;
private String targetEntity;
@@ -207,8 +237,8 @@ class MdcTransactionImpl implements MdcTransaction {
MDC.put(VIRTUAL_SERVER_NAME, this.virtualServerName);
}
- if (this.server != null) {
- MDC.put(SERVER, this.server);
+ if (this.serverName != null) {
+ MDC.put(SERVER, this.serverName);
}
if (this.serverIpAddress != null) {
@@ -267,8 +297,8 @@ class MdcTransactionImpl implements MdcTransaction {
MDC.put(RESPONSE_DESCRIPTION, this.responseDescription);
}
- if (this.severity != null) {
- MDC.put(SEVERITY, this.severity);
+ if (this.theSeverity != null) {
+ MDC.put(SEVERITY, this.theSeverity);
}
if (this.alertSeverity != null) {
@@ -365,7 +395,7 @@ class MdcTransactionImpl implements MdcTransaction {
@Override
public String getServer() {
- return this.server;
+ return this.serverName;
}
@Override
@@ -486,7 +516,7 @@ class MdcTransactionImpl implements MdcTransaction {
@Override
public MdcTransaction setSeverity(String severity) {
- this.severity = severity;
+ this.theSeverity = severity;
return this;
}
@@ -535,7 +565,7 @@ class MdcTransactionImpl implements MdcTransaction {
@Override
public String getSeverity() {
- return severity;
+ return theSeverity;
}
@Override
@@ -587,12 +617,12 @@ class MdcTransactionImpl implements MdcTransaction {
@Override
public MdcTransaction setServer(String server) {
if (server == null || server.isEmpty()) {
- this.server = DEFAULT_HOSTNAME;
+ this.serverName = DEFAULT_HOSTNAME;
} else {
- this.server = server;
+ this.serverName = server;
}
- MDC.put(SERVER, this.server);
+ MDC.put(SERVER, this.serverName);
return this;
}
@@ -669,7 +699,7 @@ class MdcTransactionImpl implements MdcTransaction {
sb.append(", partner='").append(partner).append('\'');
sb.append(", invocationId='").append(invocationId).append('\'');
sb.append(", virtualServerName='").append(virtualServerName).append('\'');
- sb.append(", server='").append(server).append('\'');
+ sb.append(", server='").append(serverName).append('\'');
sb.append(", serverIpAddress='").append(serverIpAddress).append('\'');
sb.append(", serverFqdn='").append(serverFqdn).append('\'');
sb.append(", serviceName='").append(serviceName).append('\'');
@@ -682,7 +712,7 @@ class MdcTransactionImpl implements MdcTransaction {
sb.append(", statusCode='").append(statusCode).append('\'');
sb.append(", responseCode='").append(responseCode).append('\'');
sb.append(", responseDescription='").append(responseDescription).append('\'');
- sb.append(", severity='").append(severity).append('\'');
+ sb.append(", severity='").append(theSeverity).append('\'');
sb.append(", alertSeverity='").append(alertSeverity).append('\'');
sb.append(", targetEntity='").append(targetEntity).append('\'');
sb.append(", targetServiceName='").append(targetServiceName).append('\'');
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java b/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java
index a552be46..9c0cf968 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java
@@ -47,39 +47,39 @@ public class MdcTransactionTest {
assertNullSubTransactionFields(trans);
- assertNotNull(MDC.get(MdcTransaction.REQUEST_ID));
- assertNotNull(MDC.get(MdcTransaction.PARTNER_NAME));
- assertNotNull(MDC.get(MdcTransaction.VIRTUAL_SERVER_NAME));
- assertNotNull(MDC.get(MdcTransaction.SERVER));
- assertNotNull(MDC.get(MdcTransaction.SERVER_IP_ADDRESS));
- assertNotNull(MDC.get(MdcTransaction.SERVER_FQDN));
- assertNotNull(MDC.get(MdcTransaction.SERVICE_NAME));
-
- assertNull(MDC.get(MdcTransaction.INVOCATION_ID));
- assertNull(MDC.get(MdcTransaction.BEGIN_TIMESTAMP));
- assertNull(MDC.get(MdcTransaction.END_TIMESTAMP));
- assertNull(MDC.get(MdcTransaction.ELAPSED_TIME));
- assertNull(MDC.get(MdcTransaction.SERVICE_INSTANCE_ID));
- assertNull(MDC.get(MdcTransaction.INSTANCE_UUID));
- assertNull(MDC.get(MdcTransaction.PROCESS_KEY));
- assertNull(MDC.get(MdcTransaction.STATUS_CODE));
- assertNull(MDC.get(MdcTransaction.RESPONSE_CODE));
- assertNull(MDC.get(MdcTransaction.RESPONSE_DESCRIPTION));
- assertNull(MDC.get(MdcTransaction.SEVERITY));
- assertNull(MDC.get(MdcTransaction.ALERT_SEVERITY));
- assertNull(MDC.get(MdcTransaction.TARGET_ENTITY));
- assertNull(MDC.get(MdcTransaction.TARGET_SERVICE_NAME));
- assertNull(MDC.get(MdcTransaction.TARGET_VIRTUAL_ENTITY));
- assertNull(MDC.get(MdcTransaction.CLIENT_IP_ADDRESS));
- assertNull(MDC.get(MdcTransaction.REMOTE_HOST));
-
- assertEquals(trans.getRequestId(), MDC.get(MdcTransaction.REQUEST_ID));
- assertEquals(trans.getPartner(), MDC.get(MdcTransaction.PARTNER_NAME));
- assertEquals(trans.getVirtualServerName(), MDC.get(MdcTransaction.VIRTUAL_SERVER_NAME));
- assertEquals(trans.getServer(), MDC.get(MdcTransaction.SERVER));
- assertEquals(trans.getServerIpAddress(), MDC.get(MdcTransaction.SERVER_IP_ADDRESS));
- assertEquals(trans.getServerFqdn(), MDC.get(MdcTransaction.SERVER_FQDN));
- assertEquals(trans.getServiceName(), MDC.get(MdcTransaction.SERVICE_NAME));
+ assertNotNull(MDC.get(MdcTransactionConstants.REQUEST_ID));
+ assertNotNull(MDC.get(MdcTransactionConstants.PARTNER_NAME));
+ assertNotNull(MDC.get(MdcTransactionConstants.VIRTUAL_SERVER_NAME));
+ assertNotNull(MDC.get(MdcTransactionConstants.SERVER));
+ assertNotNull(MDC.get(MdcTransactionConstants.SERVER_IP_ADDRESS));
+ assertNotNull(MDC.get(MdcTransactionConstants.SERVER_FQDN));
+ assertNotNull(MDC.get(MdcTransactionConstants.SERVICE_NAME));
+
+ assertNull(MDC.get(MdcTransactionConstants.INVOCATION_ID));
+ assertNull(MDC.get(MdcTransactionConstants.BEGIN_TIMESTAMP));
+ assertNull(MDC.get(MdcTransactionConstants.END_TIMESTAMP));
+ assertNull(MDC.get(MdcTransactionConstants.ELAPSED_TIME));
+ assertNull(MDC.get(MdcTransactionConstants.SERVICE_INSTANCE_ID));
+ assertNull(MDC.get(MdcTransactionConstants.INSTANCE_UUID));
+ assertNull(MDC.get(MdcTransactionConstants.PROCESS_KEY));
+ assertNull(MDC.get(MdcTransactionConstants.STATUS_CODE));
+ assertNull(MDC.get(MdcTransactionConstants.RESPONSE_CODE));
+ assertNull(MDC.get(MdcTransactionConstants.RESPONSE_DESCRIPTION));
+ assertNull(MDC.get(MdcTransactionConstants.SEVERITY));
+ assertNull(MDC.get(MdcTransactionConstants.ALERT_SEVERITY));
+ assertNull(MDC.get(MdcTransactionConstants.TARGET_ENTITY));
+ assertNull(MDC.get(MdcTransactionConstants.TARGET_SERVICE_NAME));
+ assertNull(MDC.get(MdcTransactionConstants.TARGET_VIRTUAL_ENTITY));
+ assertNull(MDC.get(MdcTransactionConstants.CLIENT_IP_ADDRESS));
+ assertNull(MDC.get(MdcTransactionConstants.REMOTE_HOST));
+
+ assertEquals(trans.getRequestId(), MDC.get(MdcTransactionConstants.REQUEST_ID));
+ assertEquals(trans.getPartner(), MDC.get(MdcTransactionConstants.PARTNER_NAME));
+ assertEquals(trans.getVirtualServerName(), MDC.get(MdcTransactionConstants.VIRTUAL_SERVER_NAME));
+ assertEquals(trans.getServer(), MDC.get(MdcTransactionConstants.SERVER));
+ assertEquals(trans.getServerIpAddress(), MDC.get(MdcTransactionConstants.SERVER_IP_ADDRESS));
+ assertEquals(trans.getServerFqdn(), MDC.get(MdcTransactionConstants.SERVER_FQDN));
+ assertEquals(trans.getServiceName(), MDC.get(MdcTransactionConstants.SERVICE_NAME));
}
private void assertNullSubTransactionFields(MdcTransaction trans) {
@@ -105,20 +105,20 @@ public class MdcTransactionTest {
}
protected void assertTransactionFields(MdcTransaction trans) {
- assertEquals(trans.getRequestId(), MDC.get(MdcTransaction.REQUEST_ID));
- assertEquals(trans.getPartner(), MDC.get(MdcTransaction.PARTNER_NAME));
- assertEquals(trans.getVirtualServerName(), MDC.get(MdcTransaction.VIRTUAL_SERVER_NAME));
- assertEquals(trans.getServer(), MDC.get(MdcTransaction.SERVER));
- assertEquals(trans.getServerIpAddress(), MDC.get(MdcTransaction.SERVER_IP_ADDRESS));
- assertEquals(trans.getServerFqdn(), MDC.get(MdcTransaction.SERVER_FQDN));
- assertEquals(trans.getServiceName(), MDC.get(MdcTransaction.SERVICE_NAME));
+ assertEquals(trans.getRequestId(), MDC.get(MdcTransactionConstants.REQUEST_ID));
+ assertEquals(trans.getPartner(), MDC.get(MdcTransactionConstants.PARTNER_NAME));
+ assertEquals(trans.getVirtualServerName(), MDC.get(MdcTransactionConstants.VIRTUAL_SERVER_NAME));
+ assertEquals(trans.getServer(), MDC.get(MdcTransactionConstants.SERVER));
+ assertEquals(trans.getServerIpAddress(), MDC.get(MdcTransactionConstants.SERVER_IP_ADDRESS));
+ assertEquals(trans.getServerFqdn(), MDC.get(MdcTransactionConstants.SERVER_FQDN));
+ assertEquals(trans.getServiceName(), MDC.get(MdcTransactionConstants.SERVICE_NAME));
}
@Test
public void flush() {
MdcTransaction trans =
- MdcTransaction.newTransaction()
+ MdcTransaction.newTransaction()
.setRequestId(null)
.setInvocationId(null)
.setPartner(null)
@@ -146,43 +146,43 @@ public class MdcTransactionTest {
assertTransactionFields(trans);
- assertNotNull(MDC.get(MdcTransaction.INVOCATION_ID));
- assertNotNull(MDC.get(MdcTransaction.BEGIN_TIMESTAMP));
- assertNotNull(MDC.get(MdcTransaction.END_TIMESTAMP));
- assertNotNull(MDC.get(MdcTransaction.ELAPSED_TIME));
- assertNotNull(MDC.get(MdcTransaction.SERVICE_INSTANCE_ID));
- assertNotNull(MDC.get(MdcTransaction.INSTANCE_UUID));
- assertNotNull(MDC.get(MdcTransaction.PROCESS_KEY));
- assertNotNull(MDC.get(MdcTransaction.STATUS_CODE));
- assertNotNull(MDC.get(MdcTransaction.RESPONSE_CODE));
- assertNotNull(MDC.get(MdcTransaction.RESPONSE_DESCRIPTION));
- assertNotNull(MDC.get(MdcTransaction.SEVERITY));
- assertNotNull(MDC.get(MdcTransaction.ALERT_SEVERITY));
- assertNotNull(MDC.get(MdcTransaction.TARGET_ENTITY));
- assertNotNull(MDC.get(MdcTransaction.TARGET_SERVICE_NAME));
- assertNotNull(MDC.get(MdcTransaction.TARGET_VIRTUAL_ENTITY));
- assertNotNull(MDC.get(MdcTransaction.CLIENT_IP_ADDRESS));
- assertNotNull(MDC.get(MdcTransaction.REMOTE_HOST));
-
- assertEquals(trans.getInvocationId(), MDC.get(MdcTransaction.INVOCATION_ID));
- assertEquals(trans.timestamp(trans.getStartTime()), MDC.get(MdcTransaction.BEGIN_TIMESTAMP));
- assertEquals(trans.timestamp(trans.getEndTime()), MDC.get(MdcTransaction.END_TIMESTAMP));
- assertNotEquals(trans.getElapsedTime(), MDC.get(MdcTransaction.ELAPSED_TIME));
+ assertNotNull(MDC.get(MdcTransactionConstants.INVOCATION_ID));
+ assertNotNull(MDC.get(MdcTransactionConstants.BEGIN_TIMESTAMP));
+ assertNotNull(MDC.get(MdcTransactionConstants.END_TIMESTAMP));
+ assertNotNull(MDC.get(MdcTransactionConstants.ELAPSED_TIME));
+ assertNotNull(MDC.get(MdcTransactionConstants.SERVICE_INSTANCE_ID));
+ assertNotNull(MDC.get(MdcTransactionConstants.INSTANCE_UUID));
+ assertNotNull(MDC.get(MdcTransactionConstants.PROCESS_KEY));
+ assertNotNull(MDC.get(MdcTransactionConstants.STATUS_CODE));
+ assertNotNull(MDC.get(MdcTransactionConstants.RESPONSE_CODE));
+ assertNotNull(MDC.get(MdcTransactionConstants.RESPONSE_DESCRIPTION));
+ assertNotNull(MDC.get(MdcTransactionConstants.SEVERITY));
+ assertNotNull(MDC.get(MdcTransactionConstants.ALERT_SEVERITY));
+ assertNotNull(MDC.get(MdcTransactionConstants.TARGET_ENTITY));
+ assertNotNull(MDC.get(MdcTransactionConstants.TARGET_SERVICE_NAME));
+ assertNotNull(MDC.get(MdcTransactionConstants.TARGET_VIRTUAL_ENTITY));
+ assertNotNull(MDC.get(MdcTransactionConstants.CLIENT_IP_ADDRESS));
+ assertNotNull(MDC.get(MdcTransactionConstants.REMOTE_HOST));
+
+ assertEquals(trans.getInvocationId(), MDC.get(MdcTransactionConstants.INVOCATION_ID));
+ assertEquals(trans.timestamp(trans.getStartTime()), MDC.get(MdcTransactionConstants.BEGIN_TIMESTAMP));
+ assertEquals(trans.timestamp(trans.getEndTime()), MDC.get(MdcTransactionConstants.END_TIMESTAMP));
+ assertNotEquals(trans.getElapsedTime(), MDC.get(MdcTransactionConstants.ELAPSED_TIME));
assertEquals(String.valueOf(Duration.between(trans.getStartTime(), trans.getEndTime()).toMillis()),
- MDC.get(MdcTransaction.ELAPSED_TIME));
- assertEquals(trans.getServiceInstanceId(), MDC.get(MdcTransaction.SERVICE_INSTANCE_ID));
- assertEquals(trans.getInstanceUuid(), MDC.get(MdcTransaction.INSTANCE_UUID));
- assertEquals(trans.getProcessKey(),MDC.get(MdcTransaction.PROCESS_KEY));
- assertEquals(trans.getStatusCode(), MDC.get(MdcTransaction.STATUS_CODE));
- assertEquals(trans.getResponseCode(), MDC.get(MdcTransaction.RESPONSE_CODE));
- assertEquals(trans.getResponseDescription(), MDC.get(MdcTransaction.RESPONSE_DESCRIPTION));
- assertEquals(trans.getSeverity(), MDC.get(MdcTransaction.SEVERITY));
- assertEquals(trans.getAlertSeverity(), MDC.get(MdcTransaction.ALERT_SEVERITY));
- assertEquals(trans.getTargetEntity(), MDC.get(MdcTransaction.TARGET_ENTITY));
- assertEquals(trans.getTargetServiceName(), MDC.get(MdcTransaction.TARGET_SERVICE_NAME));
- assertEquals(trans.getTargetVirtualEntity(), MDC.get(MdcTransaction.TARGET_VIRTUAL_ENTITY));
- assertEquals(trans.getClientIpAddress(), MDC.get(MdcTransaction.CLIENT_IP_ADDRESS));
- assertEquals(trans.getRemoteHost(), MDC.get(MdcTransaction.REMOTE_HOST));
+ MDC.get(MdcTransactionConstants.ELAPSED_TIME));
+ assertEquals(trans.getServiceInstanceId(), MDC.get(MdcTransactionConstants.SERVICE_INSTANCE_ID));
+ assertEquals(trans.getInstanceUuid(), MDC.get(MdcTransactionConstants.INSTANCE_UUID));
+ assertEquals(trans.getProcessKey(),MDC.get(MdcTransactionConstants.PROCESS_KEY));
+ assertEquals(trans.getStatusCode(), MDC.get(MdcTransactionConstants.STATUS_CODE));
+ assertEquals(trans.getResponseCode(), MDC.get(MdcTransactionConstants.RESPONSE_CODE));
+ assertEquals(trans.getResponseDescription(), MDC.get(MdcTransactionConstants.RESPONSE_DESCRIPTION));
+ assertEquals(trans.getSeverity(), MDC.get(MdcTransactionConstants.SEVERITY));
+ assertEquals(trans.getAlertSeverity(), MDC.get(MdcTransactionConstants.ALERT_SEVERITY));
+ assertEquals(trans.getTargetEntity(), MDC.get(MdcTransactionConstants.TARGET_ENTITY));
+ assertEquals(trans.getTargetServiceName(), MDC.get(MdcTransactionConstants.TARGET_SERVICE_NAME));
+ assertEquals(trans.getTargetVirtualEntity(), MDC.get(MdcTransactionConstants.TARGET_VIRTUAL_ENTITY));
+ assertEquals(trans.getClientIpAddress(), MDC.get(MdcTransactionConstants.CLIENT_IP_ADDRESS));
+ assertEquals(trans.getRemoteHost(), MDC.get(MdcTransactionConstants.REMOTE_HOST));
assertEquals("service-instance-id", trans.getServiceInstanceId());
assertEquals("process-key", trans.getProcessKey());