summaryrefslogtreecommitdiffstats
path: root/integrity-audit/src
diff options
context:
space:
mode:
Diffstat (limited to 'integrity-audit/src')
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java2
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java2
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java9
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java2
-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
7 files changed, 71 insertions, 71 deletions
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java
index 25bafdc4..25335540 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java
@@ -131,7 +131,7 @@ public class AuditThread extends Thread {
* other nodes of similar type.
*/
dbDao = new DbDao(this.resourceName, this.persistenceUnit, this.properties);
- this.nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE);
+ this.nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE).toLowerCase();
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
index 0235715d..80177b30 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java
@@ -143,7 +143,7 @@ public class DbDao {
this.dbUrl = properties.getProperty(IntegrityAuditProperties.DB_URL).trim();
this.dbUser = properties.getProperty(IntegrityAuditProperties.DB_USER).trim();
this.siteName = properties.getProperty(IntegrityAuditProperties.SITE_NAME).trim();
- this.nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE).trim();
+ this.nodeType = properties.getProperty(IntegrityAuditProperties.NODE_TYPE).trim().toLowerCase();
this.properties = properties;
logger.debug("DbDao.assignProperties: exit:" + "\nresourceName: " + this.resourceName + "\npersistenceUnit: "
+ this.persistenceUnit + "\nproperties: " + this.properties);
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
index 61bf947e..41aea118 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
@@ -105,7 +105,7 @@ public class IntegrityAudit {
*/
public static boolean isNodeTypeEnum(String nt) {
for (NodeTypeEnum n : NodeTypeEnum.values()) {
- if (n.toString().equals(nt)) {
+ if (n.toString().equalsIgnoreCase(nt)) {
return true;
}
}
@@ -171,11 +171,12 @@ public class IntegrityAudit {
} else {
nodeType = nodeType.trim();
if (!isNodeTypeEnum(nodeType)) {
- String nodetypes = "nodeType must be one of[";
+ badparams.append("nodeType must be one of[");
for (NodeTypeEnum n : NodeTypeEnum.values()) {
- nodetypes = nodetypes.concat(n.toString() + " ");
+ badparams.append(n.toString());
+ badparams.append(' ');
}
- badparams.append(nodetypes + "] ");
+ badparams.append("] ");
return true;
}
}
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java
index 2ca5dd58..40b2af5a 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java
@@ -35,7 +35,7 @@ public class IntegrityAuditProperties {
public static final String NODE_TYPE = "node_type";
public enum NodeTypeEnum {
- pdp_xacml, pdp_drools, pap, pap_admin, logparser, brms_gateway, astra_gateway, elk_server, pypdp
+ PDP_XACML, PDP_DROOLS, PAP, PAP_ADMIN, LOGPARSER, BRMS_GATEWAY, ASTRA_GATEWAY, ELK_SERVER, PYPDP
}
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());