aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common
diff options
context:
space:
mode:
authorTaka Cho <takamune.cho@att.com>2020-06-09 12:04:20 -0400
committerTaka Cho <takamune.cho@att.com>2020-06-09 12:04:51 -0400
commitfbd144a2442fa7273c8b1d920cd2f7611b2aefcd (patch)
treed8daf38b5c83e55573fc25af4ffc07e336832768 /controlloop/common
parent442a2a8dd64c724363433e6e4794eb19da66314b (diff)
reduce sonar issue - drool-applications
In some conditions for assertTrue, sonarcloud recommends using assertEquals Assert.assertTrue(a.equals(b)); Assert.assertTrue(a == b); Assert.assertTrue(a == null); Assert.assertTrue(a != null); Assert.assertFalse(a.equals(b)); Compliant Solution Assert.assertEquals(a, b); Assert.assertSame(a, b); Assert.assertNull(a); Assert.assertNotNull(a); Assert.assertNotEquals(a, b); Change-Id: Ic50bf6e961b74abcc698c2cc0347dd0472fefe71 Issue-ID: POLICY-2616 Signed-off-by: Taka Cho <takamune.cho@att.com>
Diffstat (limited to 'controlloop/common')
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java12
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java22
2 files changed, 17 insertions, 17 deletions
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
index db16c4528..2d9fb7e1d 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
@@ -647,8 +647,8 @@ public class ControlLoopEventManagerTest {
VirtualControlLoopEvent onsetEvent = getOnsetEvent();
ControlLoopEventManager manager = makeManager(onsetEvent);
- assertTrue(0 == manager.getControlLoopTimeout(null));
- assertTrue(120 == manager.getControlLoopTimeout(120));
+ assertEquals(0, manager.getControlLoopTimeout(null));
+ assertEquals(120, manager.getControlLoopTimeout(120));
InputStream is = new FileInputStream(new File(TEST_YAML));
final String yamlString = IOUtils.toString(is, StandardCharsets.UTF_8);
@@ -673,8 +673,8 @@ public class ControlLoopEventManagerTest {
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
- assertTrue(0 == manager.getControlLoopTimeout(null));
- assertTrue(120 == manager.getControlLoopTimeout(120));
+ assertEquals(0, manager.getControlLoopTimeout(null));
+ assertEquals(120, manager.getControlLoopTimeout(120));
}
@Test
@@ -690,8 +690,8 @@ public class ControlLoopEventManagerTest {
assertNotNull(notification);
assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
- assertTrue(0 == manager.getControlLoopTimeout(null));
- assertTrue(120 == manager.getControlLoopTimeout(120));
+ assertEquals(0, manager.getControlLoopTimeout(null));
+ assertEquals(120, manager.getControlLoopTimeout(120));
}
@Test
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
index 4cb365a76..b64d9484e 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
@@ -226,7 +226,7 @@ public class ControlLoopOperationManagerTest {
//
PolicyResult result = manager.onResponse(dmaapResponse);
logger.debug("{}", manager);
- assertTrue(result == null);
+ assertNull(result);
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
//
@@ -239,7 +239,7 @@ public class ControlLoopOperationManagerTest {
dmaapResponse.setBody(outputBody);
result = manager.onResponse(dmaapResponse);
logger.debug("{}", manager);
- assertTrue(result.equals(PolicyResult.FAILURE));
+ assertEquals(PolicyResult.FAILURE, result);
assertFalse(manager.isOperationComplete());
assertFalse(manager.isOperationRunning());
//
@@ -268,7 +268,7 @@ public class ControlLoopOperationManagerTest {
//
result = manager.onResponse(dmaapResponse);
logger.debug("{}", manager);
- assertTrue(result == null);
+ assertNull(result);
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
//
@@ -281,15 +281,15 @@ public class ControlLoopOperationManagerTest {
dmaapResponse.setBody(outputBody);
result = manager.onResponse(dmaapResponse);
logger.debug("{}", manager);
- assertTrue(result.equals(PolicyResult.FAILURE));
+ assertEquals(PolicyResult.FAILURE, result);
//
// Should be complete now
//
assertTrue(manager.isOperationComplete());
assertFalse(manager.isOperationRunning());
assertNotNull(manager.getOperationResult());
- assertTrue(manager.getOperationResult().equals(PolicyResult.FAILURE_RETRIES));
- assertTrue(manager.getHistory().size() == 2);
+ assertEquals(PolicyResult.FAILURE_RETRIES, manager.getOperationResult());
+ assertEquals(2, manager.getHistory().size());
}
@Test
@@ -354,7 +354,7 @@ public class ControlLoopOperationManagerTest {
//
PolicyResult result = manager.onResponse(dmaapResponse);
logger.debug("{}", manager);
- assertTrue(result == null);
+ assertNull(result);
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
//
@@ -364,8 +364,8 @@ public class ControlLoopOperationManagerTest {
logger.debug("{}", manager);
assertTrue(manager.isOperationComplete());
assertFalse(manager.isOperationRunning());
- assertTrue(manager.getHistory().size() == 1);
- assertTrue(manager.getOperationResult().equals(PolicyResult.FAILURE_TIMEOUT));
+ assertEquals(1, manager.getHistory().size());
+ assertEquals(PolicyResult.FAILURE_TIMEOUT, manager.getOperationResult());
//
// Now we are going to Fail the previous request
//
@@ -381,8 +381,8 @@ public class ControlLoopOperationManagerTest {
//
assertTrue(manager.isOperationComplete());
assertFalse(manager.isOperationRunning());
- assertTrue(manager.getHistory().size() == 1);
- assertTrue(manager.getOperationResult().equals(PolicyResult.FAILURE_TIMEOUT));
+ assertEquals(1, manager.getHistory().size());
+ assertEquals(PolicyResult.FAILURE_TIMEOUT, manager.getOperationResult());
}
@Test