summaryrefslogtreecommitdiffstats
path: root/integrity-audit/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-07-03 14:04:48 -0400
committerJim Hahn <jrh3@att.com>2019-07-03 15:37:19 -0400
commit53f9550501ca1854318c1f552b0aba2e255b6748 (patch)
tree7880100f7af979c83c1ea1f06b001acacefa3c2b /integrity-audit/src/test
parent7bdb762dca351370630050d544b68c0d7972fb43 (diff)
Fix remaining sonar issues in Integrity Audit
Renamed enums to upper case - this might disrupt other repos, though it should be minimal. Renamed constants in a junit test. Change-Id: Ifd864bb61eec3d9b3c7a0321fe3841696046f6f6 Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'integrity-audit/src/test')
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java96
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java10
-rw-r--r--integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java21
3 files changed, 63 insertions, 64 deletions
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java
index 965712a2..99cf4b2a 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditCompareEntriesTest.java
@@ -129,26 +129,26 @@ public class DbAuditCompareEntriesTest extends IntegrityAuditTestBase {
* Two entries with the same field values
*/
entry1.setDesignated(false);
- entry1.setJdbcDriver(dbDriver);
- entry1.setJdbcPassword(dbPass);
+ entry1.setJdbcDriver(DB_DRIVER);
+ entry1.setJdbcPassword(DB_PASS);
entry1.setJdbcUrl(dbUrl);
- entry1.setJdbcUser(dbUser);
+ entry1.setJdbcUser(DB_USER);
entry1.setLastUpdated(date);
- entry1.setNodeType(nodeType);
+ entry1.setNodeType(NODE_TYPE);
entry1.setPersistenceUnit(A_SEQ_PU);
entry1.setResourceName(resourceName1);
- entry1.setSite(siteName);
+ entry1.setSite(SITE_NAME);
entry2.setDesignated(false);
- entry2.setJdbcDriver(dbDriver);
- entry2.setJdbcPassword(dbPass);
+ entry2.setJdbcDriver(DB_DRIVER);
+ entry2.setJdbcPassword(DB_PASS);
entry2.setJdbcUrl(dbUrl);
- entry2.setJdbcUser(dbUser);
+ entry2.setJdbcUser(DB_USER);
entry2.setLastUpdated(date);
- entry2.setNodeType(nodeType);
+ entry2.setNodeType(NODE_TYPE);
entry2.setPersistenceUnit(A_SEQ_PU);
entry2.setResourceName(resourceName2);
- entry2.setSite(siteName);
+ entry2.setSite(SITE_NAME);
dbAudit.writeAuditDebugLog(className, resourceName1, resourceName2, entry1, entry2);
@@ -190,26 +190,26 @@ public class DbAuditCompareEntriesTest extends IntegrityAuditTestBase {
* Create two entries with different designated values
*/
entry1.setDesignated(false);
- entry1.setJdbcDriver(dbDriver);
- entry1.setJdbcPassword(dbPass);
+ entry1.setJdbcDriver(DB_DRIVER);
+ entry1.setJdbcPassword(DB_PASS);
entry1.setJdbcUrl(dbUrl);
- entry1.setJdbcUser(dbUser);
+ entry1.setJdbcUser(DB_USER);
entry1.setLastUpdated(date);
- entry1.setNodeType(nodeType);
+ entry1.setNodeType(NODE_TYPE);
entry1.setPersistenceUnit(A_SEQ_PU);
entry1.setResourceName(resourceName1);
- entry1.setSite(siteName);
+ entry1.setSite(SITE_NAME);
entry2.setDesignated(true);
- entry2.setJdbcDriver(dbDriver);
- entry2.setJdbcPassword(dbPass);
+ entry2.setJdbcDriver(DB_DRIVER);
+ entry2.setJdbcPassword(DB_PASS);
entry2.setJdbcUrl(dbUrl);
- entry2.setJdbcUser(dbUser);
+ entry2.setJdbcUser(DB_USER);
entry2.setLastUpdated(date);
- entry2.setNodeType(nodeType);
+ entry2.setNodeType(NODE_TYPE);
entry2.setPersistenceUnit(A_SEQ_PU);
entry2.setResourceName(resourceName2);
- entry2.setSite(siteName);
+ entry2.setSite(SITE_NAME);
HashMap<Object, Object> myEntries = new HashMap<>();
HashMap<Object, Object> theirEntries = new HashMap<>();
@@ -253,45 +253,45 @@ public class DbAuditCompareEntriesTest extends IntegrityAuditTestBase {
* 4 entries, one mismatch, two miss entries
*/
entry1.setDesignated(false);
- entry1.setJdbcDriver(dbDriver);
- entry1.setJdbcPassword(dbPass);
+ entry1.setJdbcDriver(DB_DRIVER);
+ entry1.setJdbcPassword(DB_PASS);
entry1.setJdbcUrl(dbUrl);
- entry1.setJdbcUser(dbUser);
+ entry1.setJdbcUser(DB_USER);
entry1.setLastUpdated(date);
- entry1.setNodeType(nodeType);
+ entry1.setNodeType(NODE_TYPE);
entry1.setPersistenceUnit(A_SEQ_PU);
entry1.setResourceName(resourceName1);
- entry1.setSite(siteName);
+ entry1.setSite(SITE_NAME);
entry2.setDesignated(true);
- entry2.setJdbcDriver(dbDriver);
- entry2.setJdbcPassword(dbPass);
+ entry2.setJdbcDriver(DB_DRIVER);
+ entry2.setJdbcPassword(DB_PASS);
entry2.setJdbcUrl(dbUrl);
- entry2.setJdbcUser(dbUser);
+ entry2.setJdbcUser(DB_USER);
entry2.setLastUpdated(date);
- entry2.setNodeType(nodeType);
+ entry2.setNodeType(NODE_TYPE);
entry2.setPersistenceUnit(A_SEQ_PU);
entry2.setResourceName(resourceName2);
- entry2.setSite(siteName);
+ entry2.setSite(SITE_NAME);
entry3.setDesignated(false);
- entry3.setJdbcDriver(dbDriver);
- entry3.setJdbcPassword(dbPass);
+ entry3.setJdbcDriver(DB_DRIVER);
+ entry3.setJdbcPassword(DB_PASS);
entry3.setJdbcUrl(dbUrl);
- entry3.setJdbcUser(dbUser);
+ entry3.setJdbcUser(DB_USER);
entry3.setLastUpdated(date);
- entry3.setNodeType(nodeType);
+ entry3.setNodeType(NODE_TYPE);
entry3.setPersistenceUnit(A_SEQ_PU);
entry3.setResourceName(resourceName2);
entry3.setSite("SiteB");
entry4.setDesignated(false);
- entry4.setJdbcDriver(dbDriver);
- entry4.setJdbcPassword(dbPass);
+ entry4.setJdbcDriver(DB_DRIVER);
+ entry4.setJdbcPassword(DB_PASS);
entry4.setJdbcUrl(dbUrl);
- entry4.setJdbcUser(dbUser);
+ entry4.setJdbcUser(DB_USER);
entry4.setLastUpdated(date);
- entry4.setNodeType(nodeType);
+ entry4.setNodeType(NODE_TYPE);
entry4.setPersistenceUnit(A_SEQ_PU);
entry4.setResourceName(resourceName2);
entry4.setSite("SiteB");
@@ -339,26 +339,26 @@ public class DbAuditCompareEntriesTest extends IntegrityAuditTestBase {
* Two entries with the same field values
*/
entry1.setDesignated(false);
- entry1.setJdbcDriver(dbDriver);
- entry1.setJdbcPassword(dbPass);
+ entry1.setJdbcDriver(DB_DRIVER);
+ entry1.setJdbcPassword(DB_PASS);
entry1.setJdbcUrl(dbUrl);
- entry1.setJdbcUser(dbUser);
+ entry1.setJdbcUser(DB_USER);
entry1.setLastUpdated(date);
- entry1.setNodeType(nodeType);
+ entry1.setNodeType(NODE_TYPE);
entry1.setPersistenceUnit(A_SEQ_PU);
entry1.setResourceName(resourceName1);
- entry1.setSite(siteName);
+ entry1.setSite(SITE_NAME);
entry2.setDesignated(false);
- entry2.setJdbcDriver(dbDriver);
- entry2.setJdbcPassword(dbPass);
+ entry2.setJdbcDriver(DB_DRIVER);
+ entry2.setJdbcPassword(DB_PASS);
entry2.setJdbcUrl(dbUrl);
- entry2.setJdbcUser(dbUser);
+ entry2.setJdbcUser(DB_USER);
entry2.setLastUpdated(date);
- entry2.setNodeType(nodeType);
+ entry2.setNodeType(NODE_TYPE);
entry2.setPersistenceUnit(A_SEQ_PU);
entry2.setResourceName(resourceName2);
- entry2.setSite(siteName);
+ entry2.setSite(SITE_NAME);
HashMap<Object, Object> myEntries = new HashMap<>();
HashMap<Object, Object> theirEntries = new HashMap<>();
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
index 27cd168f..13d48608 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
@@ -138,7 +138,7 @@ public class DbAuditTest extends IntegrityAuditTestBase {
assertThatThrownBy(() -> {
DbAudit dbAudit = new DbAudit(dbDao);
- dbAudit.dbAudit(RESOURCE_NAME, A_SEQ_PU, nodeType);
+ dbAudit.dbAudit(RESOURCE_NAME, A_SEQ_PU, NODE_TYPE);
}).isInstanceOf(DbAuditException.class);
logger.info("noEntitiesTest: Exit");
@@ -158,9 +158,9 @@ public class DbAuditTest extends IntegrityAuditTestBase {
// Add one entry in the database
dbDao = new DbDao(RESOURCE_NAME, A_SEQ_PU, properties);
DbAudit dbAudit = new DbAudit(dbDao);
- dbAudit.dbAudit(RESOURCE_NAME, A_SEQ_PU, nodeType);
+ dbAudit.dbAudit(RESOURCE_NAME, A_SEQ_PU, NODE_TYPE);
- List<IntegrityAuditEntity> iaeList = dbDao.getIntegrityAuditEntities(A_SEQ_PU, nodeType);
+ List<IntegrityAuditEntity> iaeList = dbDao.getIntegrityAuditEntities(A_SEQ_PU, NODE_TYPE);
logger.info("List size: " + iaeList.size());
verifyItemsInLog(log, "one");
@@ -225,7 +225,7 @@ public class DbAuditTest extends IntegrityAuditTestBase {
* as DB2 it can be confirmed that the mismatch is resolved
*/
DbAudit dbAudit = new DbAudit(dbDao);
- dbAudit.dbAudit(RESOURCE_NAME, A_SEQ_PU, nodeType);
+ dbAudit.dbAudit(RESOURCE_NAME, A_SEQ_PU, NODE_TYPE);
// update pdp3 entry in DB1 to point to DB2
new DbDao("pdp3", A_SEQ_PU, properties, dbUrl2).destroy();
@@ -234,7 +234,7 @@ public class DbAuditTest extends IntegrityAuditTestBase {
* Run the audit again and correct the mismatch, the result should be one entry in the
* mismatchKeySet because of the missing entry from the beginning of the test
*/
- dbAudit.dbAudit(RESOURCE_NAME, A_SEQ_PU, nodeType);
+ dbAudit.dbAudit(RESOURCE_NAME, A_SEQ_PU, NODE_TYPE);
assertFalse(dbglog.getExtracted().isEmpty());
diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
index 0edaaa78..1866bba0 100644
--- a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
+++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
@@ -96,11 +96,11 @@ public class IntegrityAuditTestBase {
public static final String DEFAULT_DB_URL_PREFIX = "jdbc:h2:mem:";
- protected static final String dbDriver = "org.h2.Driver";
- protected static final String dbUser = "testu";
- protected static final String dbPass = "testp";
- protected static final String siteName = "SiteA";
- protected static final String nodeType = "pdp_xacml";
+ protected static final String DB_DRIVER = "org.h2.Driver";
+ protected static final String DB_USER = "testu";
+ protected static final String DB_PASS = "testp";
+ protected static final String SITE_NAME = "SiteA";
+ protected static final String NODE_TYPE = "pdp_xacml";
// will be defined by the test *Classes*
protected static String dbUrl;
@@ -174,7 +174,6 @@ public class IntegrityAuditTestBase {
/**
* Saves current configuration information and then sets new values.
*
- * @param dbDriver the name of the DB Driver class
* @param dbUrl the URL to the DB
* @throws IOException if an IO error occurs
*/
@@ -196,12 +195,12 @@ public class IntegrityAuditTestBase {
IntegrityAudit.setUnitTesting(true);
properties = new Properties();
- properties.put(IntegrityAuditProperties.DB_DRIVER, dbDriver);
+ properties.put(IntegrityAuditProperties.DB_DRIVER, DB_DRIVER);
properties.put(IntegrityAuditProperties.DB_URL, dbUrl);
- properties.put(IntegrityAuditProperties.DB_USER, dbUser);
- properties.put(IntegrityAuditProperties.DB_PWD, dbPass);
- properties.put(IntegrityAuditProperties.SITE_NAME, siteName);
- properties.put(IntegrityAuditProperties.NODE_TYPE, nodeType);
+ properties.put(IntegrityAuditProperties.DB_USER, DB_USER);
+ properties.put(IntegrityAuditProperties.DB_PWD, DB_PASS);
+ properties.put(IntegrityAuditProperties.SITE_NAME, SITE_NAME);
+ properties.put(IntegrityAuditProperties.NODE_TYPE, NODE_TYPE);
emf = Persistence.createEntityManagerFactory(A_SEQ_PU, makeProperties());