aboutsummaryrefslogtreecommitdiffstats
path: root/feature-active-standby-management/src/test/java/org/onap
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 /feature-active-standby-management/src/test/java/org/onap
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 'feature-active-standby-management/src/test/java/org/onap')
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java8
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java6
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java36
3 files changed, 27 insertions, 23 deletions
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java
index 842d6c7f..52000fd5 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java
@@ -87,7 +87,7 @@ public class DroolsPdpObjectTest {
@Test
public void testNullSafeCompare() {
// self, when null
- pdp.setSiteName(null);
+ pdp.setSite(null);
assertEquals(0, pdp.comparePriority(pdp));
// both null
@@ -138,7 +138,7 @@ public class DroolsPdpObjectTest {
};
pdp2.setPdpId(PDP_ID);
- pdp2.setSiteName(SITE2);
+ pdp2.setSite(SITE2);
pdp2.setPriority(PRIORITY);
// should use overridden comparison method
@@ -152,7 +152,7 @@ public class DroolsPdpObjectTest {
private MyPdp makePdp(String id, String site, int priority) {
MyPdp pdp2 = new MyPdp();
- pdp2.setSiteName(site);
+ pdp2.setSite(site);
pdp2.setPdpId(id);
pdp2.setPriority(priority);
@@ -166,7 +166,7 @@ public class DroolsPdpObjectTest {
private boolean designated;
private int priority;
private Date updatedDate;
- private String siteName;
+ private String site;
private Date designatedDate;
}
}
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java
index b5b89941..5e9b360f 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/AllSeemsWellTest.java
@@ -39,6 +39,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.im.StateManagement;
import org.onap.policy.drools.activestandby.ActiveStandbyFeatureApi;
+import org.onap.policy.drools.activestandby.ActiveStandbyFeatureApiConstants;
import org.onap.policy.drools.activestandby.ActiveStandbyProperties;
import org.onap.policy.drools.activestandby.DroolsPdpEntity;
import org.onap.policy.drools.activestandby.DroolsPdpImpl;
@@ -47,6 +48,7 @@ import org.onap.policy.drools.activestandby.DroolsPdpsElectionHandler;
import org.onap.policy.drools.activestandby.JpaDroolsPdpsConnector;
import org.onap.policy.drools.core.PolicySessionFeatureApi;
import org.onap.policy.drools.statemanagement.StateManagementFeatureApi;
+import org.onap.policy.drools.statemanagement.StateManagementFeatureApiConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -235,7 +237,7 @@ public class AllSeemsWellTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi stateManagementFeatureApi = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
stateManagementFeatureApi = feature;
logger.debug("testAllSeemsWell stateManagementFeature.getResourceName(): {}",
@@ -255,7 +257,7 @@ public class AllSeemsWellTest {
// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
// that has been created.
ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApi.impl.getList()) {
+ for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
activeStandbyFeature = feature;
logger.debug("testAllSeemsWell activeStandbyFeature.getResourceName(): {}",
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
index b277850c..8bc8489a 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/controller/test/StandbyStateManagementTest.java
@@ -44,6 +44,7 @@ import org.onap.policy.common.im.IntegrityMonitor;
import org.onap.policy.common.im.StandbyStatusException;
import org.onap.policy.common.im.StateManagement;
import org.onap.policy.drools.activestandby.ActiveStandbyFeatureApi;
+import org.onap.policy.drools.activestandby.ActiveStandbyFeatureApiConstants;
import org.onap.policy.drools.activestandby.ActiveStandbyProperties;
import org.onap.policy.drools.activestandby.DroolsPdp;
import org.onap.policy.drools.activestandby.DroolsPdpEntity;
@@ -54,6 +55,7 @@ import org.onap.policy.drools.activestandby.JpaDroolsPdpsConnector;
import org.onap.policy.drools.activestandby.PmStandbyStateChangeNotifier;
import org.onap.policy.drools.core.PolicySessionFeatureApi;
import org.onap.policy.drools.statemanagement.StateManagementFeatureApi;
+import org.onap.policy.drools.statemanagement.StateManagementFeatureApiConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -352,7 +354,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi stateManagementFeature = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
stateManagementFeature = feature;
logger.debug("testColdStandby stateManagementFeature.getResourceName(): {}",
@@ -471,7 +473,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi stateManagementFeature = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
stateManagementFeature = feature;
logger.debug("testComputeMostRecentPrimary stateManagementFeature.getResourceName(): {}",
@@ -620,21 +622,21 @@ public class StandbyStateManagementTest {
long designatedDateMs = new Date().getTime();
DroolsPdp pdp1 = new DroolsPdpImpl("pdp1", false, 4, new Date());
pdp1.setDesignatedDate(new Date(designatedDateMs - 2));
- pdp1.setSiteName("site1");
+ pdp1.setSite("site1");
DroolsPdp pdp2 = new DroolsPdpImpl("pdp2", false, 4, new Date());
pdp2.setDesignatedDate(new Date(designatedDateMs - 3));
- pdp2.setSiteName("site1");
+ pdp2.setSite("site1");
//oldest
DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, new Date());
pdp3.setDesignatedDate(new Date(designatedDateMs - 4));
- pdp3.setSiteName("site2");
+ pdp3.setSite("site2");
DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, new Date());
//most recent
pdp4.setDesignatedDate(new Date(designatedDateMs));
- pdp4.setSiteName("site2");
+ pdp4.setSite("site2");
ArrayList<DroolsPdp> listOfAllPdps = new ArrayList<DroolsPdp>();
listOfAllPdps.add(pdp1);
@@ -653,7 +655,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi stateManagementFeature = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
stateManagementFeature = feature;
logger.debug("testComputeDesignatedPdp stateManagementFeature.getResourceName(): {}",
@@ -793,7 +795,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi smf = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
smf = feature;
logger.debug("testColdStandby stateManagementFeature.getResourceName(): {}", smf.getResourceName());
@@ -811,7 +813,7 @@ public class StandbyStateManagementTest {
// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
// that has been created.
ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApi.impl.getList()) {
+ for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
activeStandbyFeature = feature;
logger.debug("testColdStandby activeStandbyFeature.getResourceName(): {}",
@@ -924,7 +926,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi smf = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
smf = feature;
logger.debug("testHotStandby1 stateManagementFeature.getResourceName(): {}", smf.getResourceName());
@@ -942,7 +944,7 @@ public class StandbyStateManagementTest {
// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
// that has been created.
ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApi.impl.getList()) {
+ for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
activeStandbyFeature = feature;
logger.debug("testHotStandby1 activeStandbyFeature.getResourceName(): {}",
@@ -1081,7 +1083,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi sm2 = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
sm2 = feature;
logger.debug("testHotStandby2 stateManagementFeature.getResourceName(): {}", sm2.getResourceName());
@@ -1099,7 +1101,7 @@ public class StandbyStateManagementTest {
// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
// that has been created.
ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApi.impl.getList()) {
+ for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
activeStandbyFeature = feature;
logger.debug("testHotStandby2 activeStandbyFeature.getResourceName(): {}",
@@ -1238,7 +1240,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi sm = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
sm = feature;
logger.debug("testLocking1 stateManagementFeature.getResourceName(): {}", sm.getResourceName());
@@ -1256,7 +1258,7 @@ public class StandbyStateManagementTest {
// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
// that has been created.
ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApi.impl.getList()) {
+ for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
activeStandbyFeature = feature;
logger.debug("testLocking1 activeStandbyFeature.getResourceName(): {}",
@@ -1486,7 +1488,7 @@ public class StandbyStateManagementTest {
// discovered by the ActiveStandbyFeature when the election handler initializes.
StateManagementFeatureApi sm = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApi.impl.getList()) {
+ for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
sm = feature;
logger.debug("testLocking2 stateManagementFeature.getResourceName(): {}", sm.getResourceName());
@@ -1504,7 +1506,7 @@ public class StandbyStateManagementTest {
// Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
// that has been created.
ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApi.impl.getList()) {
+ for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
((PolicySessionFeatureApi) feature).globalInit(null, configDir);
activeStandbyFeature = feature;
logger.debug("testLocking2 activeStandbyFeature.getResourceName(): {}",