From 427cbbb9e25f843bcf06d75904f6294ac07180be Mon Sep 17 00:00:00 2001 From: Taka Cho Date: Thu, 2 Jul 2020 11:56:18 -0400 Subject: drools-pdp sonar fix most of changes are assert statement Issue-ID: POLICY-2616 Change-Id: I3bd3076115d28d8cfabcbe0859cc4b21085e1394 Signed-off-by: Taka Cho --- .../persistence/DroolsSessionEntityTest.java | 31 +++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'feature-session-persistence/src/test') diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/DroolsSessionEntityTest.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/DroolsSessionEntityTest.java index 8853edf2..3033a7bd 100644 --- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/DroolsSessionEntityTest.java +++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/DroolsSessionEntityTest.java @@ -22,6 +22,7 @@ package org.onap.policy.drools.persistence; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import java.util.Date; @@ -36,11 +37,11 @@ public class DroolsSessionEntityTest { DroolsSessionEntity e2 = makeEnt("mynameA", 2); // session id is not part of hash code - assertTrue(entity.hashCode() == e2.hashCode()); + assertEquals(entity.hashCode(), e2.hashCode()); // diff sess name e2 = makeEnt("mynameB", 1); - assertTrue(entity.hashCode() != e2.hashCode()); + assertNotEquals(entity.hashCode(), e2.hashCode()); } /** Ensures that hashCode() functions as expected when the getXxx methods are overridden. */ @@ -51,11 +52,11 @@ public class DroolsSessionEntityTest { DroolsSessionEntity e2 = makeEnt("mynameA", 2); // session id is not part of hash code - assertTrue(entity.hashCode() == e2.hashCode()); + assertEquals(entity.hashCode(), e2.hashCode()); // diff sess name e2 = makeEnt("mynameB", 1); - assertTrue(entity.hashCode() != e2.hashCode()); + assertNotEquals(entity.hashCode(), e2.hashCode()); } @Test @@ -103,21 +104,21 @@ public class DroolsSessionEntityTest { DroolsSessionEntity entity = makeEnt("mynameA", 1); // diff object type - assertFalse(entity.equals("hello")); + assertNotEquals(entity, "hello"); // reflexive - assertTrue(entity.equals(entity)); + assertEquals(entity, entity); DroolsSessionEntity e2 = makeEnt("mynameA", 2); // session id is not part of hash code - assertTrue(entity.equals(e2)); - assertTrue(entity.equals(e2)); + assertEquals(entity, e2); + assertEquals(entity, e2); // diff sess name e2 = makeEnt("mynameB", 1); - assertFalse(entity.equals(e2)); - assertFalse(entity.equals(e2)); + assertNotEquals(entity, e2); + assertNotEquals(entity, e2); } /** Ensures that equals() functions as expected when the getXxx methods are overridden. */ @@ -126,18 +127,18 @@ public class DroolsSessionEntityTest { DroolsSessionEntity entity = makeEnt2("mynameA", 1); // reflexive - assertTrue(entity.equals(entity)); + assertEquals(entity, entity); DroolsSessionEntity e2 = makeEnt("mynameA", 2); // session id is not part of hash code - assertTrue(entity.equals(e2)); - assertTrue(entity.equals(e2)); + assertEquals(entity, e2); + assertEquals(entity, e2); // diff sess name e2 = makeEnt("mynameB", 1); - assertFalse(entity.equals(e2)); - assertFalse(entity.equals(e2)); + assertNotEquals(entity, e2); + assertNotEquals(entity, e2); } @Test -- cgit 1.2.3-korg