aboutsummaryrefslogtreecommitdiffstats
path: root/policy-utils/src/test/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-08-05 15:27:16 -0400
committerJim Hahn <jrh3@att.com>2019-08-13 15:58:15 -0400
commita156cf3cbad6512510ae9a02a13c0408f901c734 (patch)
tree0a69bffb2a6c9f961bda1408153cf44f360c6a17 /policy-utils/src/test/java
parent62d1ff054b0ec6348ab6f7415063fdaa3f425215 (diff)
Fix sonar issues in drools-pdp
Address sonar issue, "Move constants to a class or enum", by moving them from interfaces to classes: ActiveStandbyFeatureApi StateManagementFeatureApi PolicyResourceLockFeatureApi PolicySessionFeatureApi DroolsController DroolsControllerFeatureApi PolicyControllerFeatureApi PolicyEngineFeatureApi HealthCheck SystemPersistence EventProtocolCoder PolicyController PolicyEngine TestTransaction MdcTransaction Address sonar issue, "Move constants to a class or enum", by change the interface to a class: DroolsProperties Address sonar issue, "Override the "equals" method in this class", by adding equals & hashCode to: DroolsPdpEntity DroolsPdpImpl Use lombok for a number of getters & setters. Address sonar issue, "Define a constant instead of duplicating this literal" in: DroolsPdpsElectionHandler JpaDroolsPdpsConnector MavenDroolsController GenericEventProtocolCoder GsonProtocolCoderToolset RestManager Address sonar issue, "Remove the parentheses around the parameter" in: MavenDroolsController Address sonar issue, "Replace this lambda with a method reference" in: LifecycleFsm Address sonar issue, "Move this constructor to comply with Java Code Conventions" in: LifecycleStateRunning Address sonar issue, "Replace this 'switch' statement by 'if' statements to increase readability", as specified in: PolicyEngineManager Address sonar issue, "Rename field to prevent any misunderstanding/clash with field" in: MdcTransactionImpl Address sonar issue, "Either log or rethrow this exception", in: RestManager Address sonar issue, "Rename this constant name to" uppercase, by replacing enums with static lists in: RestManager Addressed review comments: Fixed license dates. Renamed getSiteName/setSiteName methods to getSite/setSite in the interface to match the field names in the implementation classes. Renamed *Instance classes to *Constants. Next round of review comments. Change-Id: I1c26af9f194833dd773f2b25dc5f60cde163201c Issue-ID: POLICY-1968 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-utils/src/test/java')
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java154
1 files changed, 77 insertions, 77 deletions
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());