diff options
Diffstat (limited to 'ONAP-REST/src/test')
8 files changed, 269 insertions, 186 deletions
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java index 47456106b..3cedd2312 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/daoimpl/PolicyValidationDaoImplTest.java @@ -24,6 +24,8 @@ package org.onap.policy.rest.daoimpl; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -53,7 +55,7 @@ import org.onap.policy.rest.jpa.OnapName; import org.onap.policy.rest.jpa.PolicyEntity; import org.onap.policy.rest.jpa.PolicyRoles; import org.onap.policy.rest.jpa.PolicyVersion; -import org.onap.policy.rest.jpa.SystemLogDB; +import org.onap.policy.rest.jpa.SystemLogDb; import org.onap.policy.rest.jpa.UserInfo; import org.onap.policy.rest.jpa.WatchPolicyNotificationTable; import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder; @@ -70,7 +72,7 @@ public class PolicyValidationDaoImplTest { /** * Set up all unit tests. - * + * * @throws SQLException on SQL exceptions */ @BeforeClass @@ -98,13 +100,13 @@ public class PolicyValidationDaoImplTest { PolicyValidationDaoImpl.setSessionfactory(sessionFactory); // PolicyController.setLogTableLimit("1"); // HibernateSession.setSession(sessionFactory); - SystemLogDB data1 = new SystemLogDB(); + SystemLogDb data1 = new SystemLogDb(); data1.setDate(new Date()); data1.setLogtype("INFO"); data1.setRemote("Test"); data1.setSystem("Test"); data1.setType("Test"); - SystemLogDB data2 = new SystemLogDB(); + SystemLogDb data2 = new SystemLogDb(); data2.setDate(new Date()); data2.setLogtype("error"); data2.setRemote("Test"); @@ -332,6 +334,64 @@ public class PolicyValidationDaoImplTest { assertTrue(dataCur.size() == 1); assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable); assertEquals(watch, dataCur.get(0)); + + WatchPolicyNotificationTable table0 = new WatchPolicyNotificationTable(); + WatchPolicyNotificationTable table1 = new WatchPolicyNotificationTable(); + assertEquals(table0, table0); + assertEquals(table0, table1); + assertNotEquals(table0, null); + String helloString = "Hello"; + Object helloObject = helloString; + assertNotEquals(table0, helloObject); + + table0.setId(1); + assertNotEquals(table0, table1); + table1.setId(1); + assertEquals(table0, table1); + + table0.setPolicyName("GoToOz"); + assertNotEquals(table0, table1); + table1.setPolicyName("GoToOz"); + assertEquals(table0, table1); + table1.setPolicyName(null); + assertNotEquals(table0, table1); + table0.setPolicyName(null); + assertEquals(table0, table1); + table1.setPolicyName("GoToOz"); + assertNotEquals(table0, table1); + table0.setPolicyName("GoToOz"); + assertEquals(table0, table1); + assertEquals(table0, table1); + table1.setPolicyName("InOz"); + assertNotEquals(table0, table1); + table0.setPolicyName("InOz"); + assertEquals(table0, table1); + + table0.setLoginIds("Wizard"); + assertNotEquals(table0, table1); + table1.setLoginIds("Wizard"); + assertEquals(table0, table1); + table1.setLoginIds(null); + assertNotEquals(table0, table1); + table0.setLoginIds(null); + assertEquals(table0, table1); + table0.setLoginIds("Wizard"); + assertNotEquals(table0, table1); + table1.setLoginIds("Wizard"); + assertEquals(table0, table1); + table1.setLoginIds(null); + table1.setLoginIds("Witch"); + assertNotEquals(table0, table1); + table0.setLoginIds("Witch"); + assertEquals(table0, table1); + + assertNotNull(table0.hashCode()); + assertNotNull(table1.hashCode()); + assertEquals(table0.hashCode(), table0.hashCode()); + + table0.setLoginIds("Witci"); + assertNotEquals(table0, table1); + assertNotEquals(table0.hashCode(), table1.hashCode()); } /* @@ -453,6 +513,7 @@ public class PolicyValidationDaoImplTest { UserInfo userInfo = new UserInfo(); userInfo.setUserLoginId("TestID"); userInfo.setUserName("Test"); + assertEquals("Test", userInfo.getIdentiferByUserId().getUri().getPath()); commonClassDao.save(userInfo); List<String> multipleData = new ArrayList<>(); multipleData.add("TestID:Test1"); diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java index 3967bb48e..501c7fd92 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java @@ -289,6 +289,13 @@ public class ActionDictionaryJpaTest { data.setXacmlId("Test"); assertTrue("Test".equals(data.getXacmlId())); data.toString(); + + RuleAlgorithms ra0 = new RuleAlgorithms(new DummyIdentifier()); + assertTrue(ra0.isStandard()); + assertFalse(ra0.isCustom()); + RuleAlgorithms ra1 = new RuleAlgorithms(new DummyIdentifier(), 'C'); + assertFalse(ra1.isStandard()); + assertTrue(ra1.isCustom()); } @Test diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJpaTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJpaTest.java index 96a00f934..00fba8ca6 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJpaTest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ClosedLoopPolicyDictionaryJpaTest.java @@ -57,13 +57,13 @@ public class ClosedLoopPolicyDictionaryJpaTest { */ @Test public void testVsclAction() { - VSCLAction data = new VSCLAction(); + VsclAction data = new VsclAction(); data.preUpdate(); data.prePersist(); data.setId(1); assertTrue(1 == data.getId()); - data.setVsclaction("Test"); - assertTrue("Test".equals(data.getVsclaction())); + data.setAction("Test"); + assertTrue("Test".equals(data.getAction())); data.setDescription("Test"); assertTrue("Test".equals(data.getDescription())); data.setCreatedDate(new Date()); @@ -81,13 +81,13 @@ public class ClosedLoopPolicyDictionaryJpaTest { */ @Test public void testVnfType() { - VNFType data = new VNFType(); + VnfType data = new VnfType(); data.preUpdate(); data.prePersist(); data.setId(1); assertTrue(1 == data.getId()); - data.setVnftype("Test"); - assertTrue("Test".equals(data.getVnftype())); + data.setType("Test"); + assertTrue("Test".equals(data.getType())); data.setDescription("Test"); assertTrue("Test".equals(data.getDescription())); data.setCreatedDate(new Date()); @@ -138,8 +138,8 @@ public class ClosedLoopPolicyDictionaryJpaTest { assertTrue("Test".equals(data.getVarbindName())); data.setVarbindDescription("Test"); assertTrue("Test".equals(data.getVarbindDescription())); - data.setVarbindOID("Test"); - assertTrue("Test".equals(data.getVarbindOID())); + data.setVarbindOid("Test"); + assertTrue("Test".equals(data.getVarbindOid())); data.setCreatedDate(new Date()); assertTrue(data.getCreatedDate() != null); data.setModifiedDate(new Date()); diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJpaTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJpaTest.java index caeb808d8..a6505a3f6 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJpaTest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/CommonDictionaryJpaTest.java @@ -178,8 +178,8 @@ public class CommonDictionaryJpaTest { data.prePersist(); data.setId(1); assertTrue(1 == data.getId()); - data.setRiskName("Test"); - assertTrue("Test".equals(data.getRiskName())); + data.setName("Test"); + assertTrue("Test".equals(data.getName())); data.setDescription("Test"); assertTrue("Test".equals(data.getDescription())); data.setCreatedDate(new Date()); diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FwDictionaryJpaTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FwDictionaryJpaTest.java index cee9dde78..42df1c93d 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FwDictionaryJpaTest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/FwDictionaryJpaTest.java @@ -240,8 +240,8 @@ public class FwDictionaryJpaTest { assertTrue("Test".equals(data.getServiceDescription())); data.setServiceType("Test"); assertTrue("Test".equals(data.getServiceType())); - data.setServiceTransProtocol("Test"); - assertTrue("Test".equals(data.getServiceTransProtocol())); + data.setServiceTransportProtocol("Test"); + assertTrue("Test".equals(data.getServiceTransportProtocol())); data.setServiceAppProtocol("Test"); assertTrue("Test".equals(data.getServiceAppProtocol())); data.setServicePorts("Test"); @@ -261,15 +261,15 @@ public class FwDictionaryJpaTest { data.setTermName("Test"); assertTrue("Test".equals(data.getTermName())); data.setDescription("Test"); - assertTrue("Test".equals(data.getTermDescription())); - data.setFromZones("Test"); + assertTrue("Test".equals(data.getDescription())); + data.setFromZone("Test"); assertTrue("Test".equals(data.getFromZone())); - data.setToZones("Test"); + data.setToZone("Test"); assertTrue("Test".equals(data.getToZone())); - data.setSrcIPList("Test"); - assertTrue("Test".equals(data.getSrcIPList())); - data.setDestIPList("Test"); - assertTrue("Test".equals(data.getDestIPList())); + data.setSrcIpList("Test"); + assertTrue("Test".equals(data.getSrcIpList())); + data.setDestIpList("Test"); + assertTrue("Test".equals(data.getDestIpList())); data.setProtocolList("Test"); assertTrue("Test".equals(data.getProtocolList())); data.setPortList("Test"); diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java index 1fcc7baa6..174d63506 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java @@ -247,7 +247,7 @@ public class MicroServiceDictionaryJpaTest { */ @Test public void testVmType() { - VMType data = new VMType(); + VmType data = new VmType(); data.setId(1); assertTrue(1 == data.getId()); data.setName("Test"); diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJpaTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJpaTest.java index b392b6f5a..a55ff8d6e 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJpaTest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyEntityJpaTest.java @@ -21,7 +21,9 @@ package org.onap.policy.rest.jpa; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -130,256 +132,261 @@ public class PolicyEntityJpaTest { PolicyEntity entity0 = new PolicyEntity(); PolicyEntity entity1 = new PolicyEntity(); - assertTrue(entity0.equals(entity0)); - assertTrue(entity0.equals(entity1)); - assertFalse(entity0.equals(null)); + assertEquals(entity0, entity0); + assertEquals(entity0, entity1); + assertNotEquals(entity0, null); String helloString = "Hello"; Object helloObject = helloString; - assertFalse(entity0.equals(helloObject)); + assertNotEquals(entity0, helloObject); entity0.setPolicyId(1); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setPolicyId(1); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setPolicyId(2); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setPolicyId(2); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setPolicyName("GoToOz"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setPolicyName("GoToOz"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setPolicyName(null); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setPolicyName(null); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setPolicyName("GoToOz"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setPolicyName("GoToOz"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setPolicyName("GoToOzNow"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setPolicyName("GoToOzNow"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setScope("All"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setScope("All"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setScope(null); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setScope(null); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setScope("All"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setScope("All"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setScope("AllIn"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setScope("AllIn"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setVersion(1); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setVersion(1); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setPolicyVersion(1); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setPolicyVersion(1); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setPolicyVersion(2); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setPolicyVersion(2); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setPolicyData("SomeData"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setPolicyData("SomeData"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setPolicyData(null); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setPolicyData(null); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setPolicyData("SomeData"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setPolicyData("SomeData"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setPolicyData("SomeMoreData"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setPolicyData("SomeMoreData"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); ConfigurationDataEntity cde0 = new ConfigurationDataEntity(); entity0.setConfigurationDataEntity(cde0); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setConfigurationDataEntity(cde0); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setConfigurationDataEntity(null); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setConfigurationDataEntity(null); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); ConfigurationDataEntity cde1 = new ConfigurationDataEntity(); entity1.setConfigurationDataEntity(cde1); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setConfigurationDataEntity(cde1); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); ActionBodyEntity abe0 = new ActionBodyEntity(); entity0.setActionBodyEntity(abe0); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setActionBodyEntity(abe0); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setActionBodyEntity(null); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setActionBodyEntity(null); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setActionBodyEntity(abe0); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setActionBodyEntity(abe0); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); ActionBodyEntity abe1 = new ActionBodyEntity(); entity1.setActionBodyEntity(abe1); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setActionBodyEntity(abe1); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setDescription("Description"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setDescription("Description"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setDescription(null); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setDescription(null); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setDescription("Description"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setDescription("Description"); - assertTrue(entity0.equals(entity1)); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); + assertEquals(entity0, entity1); entity1.setDescription("Description Extra"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setDescription("Description Extra"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setDeleted(true); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setDeleted(true); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setDeleted(false); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setDeleted(false); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setDeleteReasonCode("NoReason"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setDeleteReasonCode("NoReason"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setDeleteReasonCode(null); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setDeleteReasonCode(null); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setDeleteReasonCode("NoReason"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setDeleteReasonCode("NoReason"); - assertTrue(entity0.equals(entity1)); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); + assertEquals(entity0, entity1); entity1.setDeleteReasonCode("NoOtherReason"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setDeleteReasonCode("NoOtherReason"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setCreatedBy("Dorothy"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setCreatedBy("Dorothy"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setCreatedBy(null); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setCreatedBy(null); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setCreatedBy("Dorothy"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setCreatedBy("Dorothy"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setCreatedBy("Toto"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setCreatedBy("Toto"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setCreatedDate(new Date(12345L)); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setCreatedDate(new Date(12345L)); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setCreatedDate(null); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setCreatedDate(null); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setCreatedDate(new Date(12345L)); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setCreatedDate(new Date(12345L)); - assertTrue(entity0.equals(entity1)); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); + assertEquals(entity0, entity1); entity1.setCreatedDate(new Date(123456L)); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setCreatedDate(new Date(123456L)); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setModifiedBy("Dorothy"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setModifiedBy("Dorothy"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setModifiedBy(null); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setModifiedBy(null); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setModifiedBy("Dorothy"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setModifiedBy("Dorothy"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setModifiedBy("Toto"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setModifiedBy("Toto"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setModifiedDate(new Date(12345L)); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setModifiedDate(new Date(12345L)); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setModifiedDate(null); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setModifiedDate(null); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setModifiedDate(new Date(12345L)); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setModifiedDate(new Date(12345L)); - assertTrue(entity0.equals(entity1)); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); + assertEquals(entity0, entity1); entity1.setModifiedDate(new Date(123456L)); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setModifiedDate(new Date(123456L)); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity0.setDeletedBy("Dorothy"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity1.setDeletedBy("Dorothy"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setDeletedBy(null); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setDeletedBy(null); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); entity1.setDeletedBy("Dorothy"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setDeletedBy("Dorothy"); - assertTrue(entity0.equals(entity1)); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); + assertEquals(entity0, entity1); entity1.setDeletedBy("Toto"); - assertFalse(entity0.equals(entity1)); + assertNotEquals(entity0, entity1); entity0.setDeletedBy("Toto"); - assertTrue(entity0.equals(entity1)); + assertEquals(entity0, entity1); assertNotNull(entity0.hashCode()); assertNotNull(entity1.hashCode()); + assertEquals(entity0.hashCode(), entity0.hashCode()); + + entity0.setDeletedBy("Totp"); + assertNotEquals(entity0, entity1); + assertNotEquals(entity0.hashCode(), entity1.hashCode()); } /** @@ -405,7 +412,9 @@ public class PolicyEntityJpaTest { assertTrue(data.isDeleted()); assertTrue(data.getCreatedDate() != null); assertTrue(data.getModifiedDate() != null); - data.equals(new ConfigurationDataEntity()); + String helloString = "Hello"; + Object helloObject = helloString; + assertNotEquals(data, helloObject); data.hashCode(); } diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJpaTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJpaTest.java index 26d47a2fc..f56e55783 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJpaTest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/PolicyUtilsJpaTest.java @@ -21,7 +21,8 @@ package org.onap.policy.rest.jpa; -import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -116,97 +117,102 @@ public class PolicyUtilsJpaTest { PolicyVersion version0 = new PolicyVersion(); PolicyVersion version1 = new PolicyVersion(); - assertTrue(version0.equals(version0)); - assertTrue(version0.equals(version1)); - assertFalse(version0.equals(null)); + assertEquals(version0, version0); + assertEquals(version0, version1); + assertNotEquals(version0, null); String helloString = "Hello"; Object helloObject = helloString; - assertFalse(version0.equals(helloObject)); + assertNotEquals(version0, helloObject); version0.setId(1); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version1.setId(1); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version0.setActiveVersion(1); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version1.setActiveVersion(1); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version0.setCreatedBy("Dorothy"); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version1.setCreatedBy("Dorothy"); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version1.setCreatedBy(null); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version0.setCreatedBy(null); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version1.setCreatedBy("Dorothy"); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version0.setCreatedBy("Dorothy"); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version0.setCreatedDate(new Date(12345L)); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version1.setCreatedDate(new Date(12345L)); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version1.setCreatedDate(null); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version0.setCreatedDate(null); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version1.setCreatedDate(new Date(12345L)); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version0.setCreatedDate(new Date(12345L)); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version0.setHigherVersion(1); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version1.setHigherVersion(1); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version0.setModifiedBy("Dorothy"); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version1.setModifiedBy("Dorothy"); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version1.setModifiedBy(null); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version0.setModifiedBy(null); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version1.setModifiedBy("Dorothy"); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version0.setModifiedBy("Dorothy"); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version0.setModifiedDate(new Date(12345L)); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version1.setModifiedDate(new Date(12345L)); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version1.setModifiedDate(null); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version0.setModifiedDate(null); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version1.setModifiedDate(new Date(12345L)); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version0.setModifiedDate(new Date(12345L)); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version0.setPolicyName("GoToOz"); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version1.setPolicyName("GoToOz"); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version1.setPolicyName(null); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version0.setPolicyName(null); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); version1.setPolicyName("GoToOz"); - assertFalse(version0.equals(version1)); + assertNotEquals(version0, version1); version0.setPolicyName("GoToOz"); - assertTrue(version0.equals(version1)); + assertEquals(version0, version1); assertNotNull(version0.hashCode()); assertNotNull(version1.hashCode()); + assertEquals(version0.hashCode(), version0.hashCode()); + + version0.setPolicyName("GoToOy"); + assertNotEquals(version0, version1); + assertNotEquals(version0.hashCode(), version1.hashCode()); } /** * Test system log DB. */ @Test - public void testSystemLogDB() { - SystemLogDB data = new SystemLogDB(); - new SystemLogDB(1, "", "", "", "", ""); + public void testSystemLogDb() { + SystemLogDb data = new SystemLogDb(); + new SystemLogDb(1, "", "", "", "", ""); data.setId(1); assertTrue(1 == data.getId()); data.setDescription("Test"); |