summaryrefslogtreecommitdiffstats
path: root/feature-active-standby-management
diff options
context:
space:
mode:
Diffstat (limited to 'feature-active-standby-management')
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java6
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java12
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java64
3 files changed, 42 insertions, 40 deletions
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java
index 2616ac34..9457ce18 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java
@@ -20,6 +20,7 @@
package org.onap.policy.drools.activestandby;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -337,8 +338,7 @@ public class AllSeemsWellTest {
logger.debug("testAllSeemsWell: After isStalled=true, PDP= {} "
+ "has standbyStatus= {}", thisPdpId, smf.getStandbyStatus(thisPdpId));
-
- assertTrue(smf.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
+ assertEquals(StateManagement.COLD_STANDBY, smf.getStandbyStatus());
//Now lets resume the election handler
DroolsPdpsElectionHandler.setIsStalled(false);
@@ -349,7 +349,7 @@ public class AllSeemsWellTest {
logger.debug("testAllSeemsWell: After isStalled=false, PDP= {} "
+ "has standbyStatus= {}", thisPdpId, smf.getStandbyStatus(thisPdpId));
- assertTrue(smf.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+ assertEquals(StateManagement.PROVIDING_SERVICE, smf.getStandbyStatus());
//resumedElectionHandlerSleepTime = 5000;
logger.debug("\n\ntestAllSeemsWell: Exiting\n\n");
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 52000fd5..3f4a31b2 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
@@ -22,7 +22,7 @@ package org.onap.policy.drools.activestandby;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotEquals;
import java.util.Date;
import lombok.Getter;
@@ -50,19 +50,19 @@ public class DroolsPdpObjectTest {
@Test
public void testEqualsObject() {
// self
- assertTrue(pdp.equals(pdp));
+ assertEquals(pdp,pdp);
// same id
MyPdp pdp2 = new MyPdp();
pdp2.setPdpId(PDP_ID);
- assertTrue(pdp.equals(pdp2));
+ assertEquals(pdp,pdp2);
// different id
pdp2.setPdpId(PDP_ID2);
- assertFalse(pdp.equals(pdp2));
+ assertNotEquals(pdp,pdp2);
// different type of object
- assertFalse(pdp.equals(""));
+ assertNotEquals(pdp,"");
}
@Test
@@ -74,7 +74,7 @@ public class DroolsPdpObjectTest {
assertEquals(hc, makePdp(PDP_ID, SITE, PRIORITY).hashCode());
// different data should yield different hash code
- assertTrue(makePdp(PDP_ID2, SITE, PRIORITY).hashCode() != hc);
+ assertNotEquals(hc, makePdp(PDP_ID2, SITE, PRIORITY).hashCode());
// these fields have no impact on hash code
assertEquals(hc, makePdp(PDP_ID, SITE, PRIORITY2).hashCode());
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java
index f51d620f..866ad5ef 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java
@@ -20,8 +20,10 @@
package org.onap.policy.drools.activestandby;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -261,55 +263,55 @@ public class StandbyStateManagementTest {
//At this point the standbystatus = 'null'
sm.lock();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.NULL_VALUE));
+ assertEquals(StateManagement.NULL_VALUE, pmNotifier.getPreviousStandbyStatus());
sm.unlock();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.NULL_VALUE));
+ assertEquals(StateManagement.NULL_VALUE, pmNotifier.getPreviousStandbyStatus());
//Adding standbystatus=hotstandby
sm.demote();
System.out.println(pmNotifier.getPreviousStandbyStatus());
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
//Now making standbystatus=coldstandby
sm.lock();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
//standbystatus = hotstandby
sm.unlock();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
//standbystatus = providingservice
sm.promote();
//The previousStandbyStatus is not updated until after the delay activation expires
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
//Sleep long enough for the delayActivationTimer to run
sleep(5000);
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+ assertEquals(StateManagement.PROVIDING_SERVICE, pmNotifier.getPreviousStandbyStatus());
//standbystatus = providingservice
sm.promote();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+ assertEquals(StateManagement.PROVIDING_SERVICE, pmNotifier.getPreviousStandbyStatus());
//standbystatus = coldstandby
sm.lock();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
//standbystatus = hotstandby
sm.unlock();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
//standbystatus = hotstandby
sm.demote();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
}
/**
@@ -359,7 +361,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size = {}\n\n",listOfDesignated.size());
- assertTrue(listOfDesignated.size() == 4);
+ assertEquals(4, listOfDesignated.size());
// Now make 2 designated
@@ -371,7 +373,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size after 2 designated = {}\n\n",
listOfDesignated.size());
- assertTrue(listOfDesignated.size() == 2);
+ assertEquals(2, listOfDesignated.size());
assertTrue(listOfDesignated.contains(pdp1));
assertTrue(listOfDesignated.contains(pdp2));
@@ -388,7 +390,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size after all designated = {}\n\n",
listOfDesignated.size());
- assertTrue(listOfDesignated.size() == 4);
+ assertEquals(4, listOfDesignated.size());
}
@@ -465,7 +467,7 @@ public class StandbyStateManagementTest {
// the one which has the most recent designated date.
- assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+ assertEquals("pdp4", mostRecentPrimary.getPdpId());
// Now let's designate all of those on the listOfDesignated. It will choose the first one designated
@@ -487,7 +489,7 @@ public class StandbyStateManagementTest {
// the one which was designated first
- assertTrue(mostRecentPrimary.getPdpId().equals("pdp2"));
+ assertEquals("pdp2", mostRecentPrimary.getPdpId());
// Now we will designate only 2 and put just them in the listOfDesignated. The algorithm will now
@@ -505,7 +507,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestComputeMostRecentPrimary: mostRecentPrimary.getPdpId() = {}\n\n",
mostRecentPrimary.getPdpId());
- assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+ assertEquals("pdp4", mostRecentPrimary.getPdpId());
@@ -521,7 +523,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestComputeMostRecentPrimary: 2 on list mostRecentPrimary.getPdpId() = {}\n\n",
mostRecentPrimary.getPdpId());
- assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+ assertEquals("pdp4", mostRecentPrimary.getPdpId());
// If we have only one pdp on in the listOfDesignated,
@@ -536,7 +538,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestComputeMostRecentPrimary: 1 on list mostRecentPrimary.getPdpId() = {}\n\n",
mostRecentPrimary.getPdpId());
- assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+ assertEquals("pdp4", mostRecentPrimary.getPdpId());
// Finally, if none are on the listOfDesignated, it will again choose the most recently designated pdp.
@@ -549,7 +551,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestComputeMostRecentPrimary: 0 on list mostRecentPrimary.getPdpId() = {}\n\n",
mostRecentPrimary.getPdpId());
- assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+ assertEquals("pdp4", mostRecentPrimary.getPdpId());
}
@@ -624,7 +626,7 @@ public class StandbyStateManagementTest {
// The designatedPdp should be null
- assertTrue(designatedPdp == null);
+ assertNull(designatedPdp);
// Now let's try having only one pdp in listOfDesignated, but not in the same site as the most recent primary
@@ -637,7 +639,7 @@ public class StandbyStateManagementTest {
// Now the designatedPdp should be the one and only selection in the listOfDesignated
- assertTrue(designatedPdp.getPdpId().equals(pdp2.getPdpId()));
+ assertEquals(designatedPdp.getPdpId(), pdp2.getPdpId());
// Now let's put 2 pdps in the listOfDesignated, neither in the same site as the mostRecentPrimary
@@ -651,7 +653,7 @@ public class StandbyStateManagementTest {
// The designatedPdp should now be the one with the lowest lexiographic score - pdp1
- assertTrue(designatedPdp.getPdpId().equals(pdp1.getPdpId()));
+ assertEquals(designatedPdp.getPdpId(), pdp1.getPdpId());
// Finally, we will have 2 pdps in the listOfDesignated, one in the same site with the mostRecentPrimary
@@ -666,7 +668,7 @@ public class StandbyStateManagementTest {
// The designatedPdp should now be the one on the same site as the mostRecentPrimary
- assertTrue(designatedPdp.getPdpId().equals(pdp3.getPdpId()));
+ assertEquals(designatedPdp.getPdpId(), pdp3.getPdpId());
}
/**