From 92a628e50e3b64f0f382a467405a12cc345f58bf Mon Sep 17 00:00:00 2001 From: rb7147 Date: Thu, 21 Sep 2017 13:51:10 -0400 Subject: Added Junits for POLICY-SDK-APP Issue-Id: POLICY-52 Change-Id: I439c95736f50fe9140e71cad5a598c5b5239161b Signed-off-by: rb7147 --- .../src/main/java/org/onap/policy/admin/CheckPDP.java | 8 +++++++- .../org/onap/policy/admin/PolicyManagerServlet.java | 18 ++++-------------- .../org/onap/policy/admin/PolicyNotificationMail.java | 7 ++++++- .../org/onap/policy/admin/PolicyRestController.java | 18 +++++++++++++++++- .../policy/controller/CreateFirewallController.java | 8 ++++++++ .../org/onap/policy/daoImp/SystemLogDbDaoImpl.java | 14 ++------------ .../src/main/webapp/WEB-INF/conf/system.properties | 4 ++-- 7 files changed, 46 insertions(+), 31 deletions(-) (limited to 'POLICY-SDK-APP/src/main') diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java index 3febbed44..7ac9ca310 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java @@ -34,6 +34,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Properties; import org.onap.policy.common.logging.flexlogger.FlexLogger; @@ -49,9 +50,14 @@ public class CheckPDP { private static HashMap pdpMap = null; private static final Logger LOGGER = FlexLogger.getLogger(CheckPDP.class); - private CheckPDP(){ + public static Map getPdpMap() { + return pdpMap; + } + + public CheckPDP(){ //default constructor } + public static boolean validateID(String id) { // ReadFile try { diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java index 4f42023c9..c94c14de2 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java @@ -92,16 +92,6 @@ public class PolicyManagerServlet extends HttpServlet { private static final Logger LOGGER = FlexLogger.getLogger(PolicyManagerServlet.class); private static final long serialVersionUID = -8453502699403909016L; - private static boolean jUnit = false; - - public static boolean isjUnit() { - return jUnit; - } - - public static void setjUnit(boolean jUnit) { - PolicyManagerServlet.jUnit = jUnit; - } - private enum Mode { LIST, RENAME, COPY, DELETE, EDITFILE, ADDFOLDER, DESCRIBEPOLICYFILE, VIEWPOLICY, ADDSUBSCOPE, SWITCHVERSION, EXPORT, SEARCHLIST } @@ -542,7 +532,7 @@ public class PolicyManagerServlet extends HttpServlet { peParams.put("split_1", split[1]); peParams.put("split_0", split[0]); List queryData = null; - if(jUnit){ + if(PolicyController.isjUnit()){ queryData = controller.getDataByQuery(query, null); }else{ queryData = controller.getDataByQuery(query, peParams); @@ -684,7 +674,7 @@ public class PolicyManagerServlet extends HttpServlet { } PolicyController controller = getPolicyControllerInstance(); List scopesList = null; - if(jUnit){ + if(PolicyController.isjUnit()){ scopesList = controller.getDataByQuery(scopeNamequery, null); }else{ scopesList = controller.getDataByQuery(scopeNamequery, params); @@ -709,7 +699,7 @@ public class PolicyManagerServlet extends HttpServlet { List activePolicies = null; List scopesList = null; - if(jUnit){ + if(PolicyController.isjUnit()){ activePolicies = controller.getDataByQuery(query, null); scopesList = controller.getDataByQuery(scopeNamequery, null); }else{ @@ -1422,7 +1412,7 @@ public class PolicyManagerServlet extends HttpServlet { peParams.put("split_1", split[1]); peParams.put("split_0", split[0]); List queryData = null; - if(jUnit){ + if(PolicyController.isjUnit()){ queryData = controller.getDataByQuery(query, null); }else{ queryData = controller.getDataByQuery(query, peParams); diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java index a4e476200..2326a9fb7 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java @@ -122,7 +122,12 @@ public class PolicyNotificationMail{ boolean sendFlag = false; SimpleBindings params = new SimpleBindings(); params.put("policyFileName", policyFileName); - List watchList = policyNotificationDao.getDataByQuery(query, params); + List watchList = null; + if(PolicyController.isjUnit()){ + watchList = policyNotificationDao.getDataByQuery(query, null); + }else{ + watchList = policyNotificationDao.getDataByQuery(query, params); + } if(watchList != null && !watchList.isEmpty()){ for(Object watch : watchList){ WatchPolicyNotificationTable list = (WatchPolicyNotificationTable) watch; diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java index 7234a3b6a..08f80304c 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java @@ -82,8 +82,24 @@ public class PolicyRestController extends RestrictedBaseController{ private static final String modal = "model"; private static final String importDictionary = "import_dictionary"; + private static CommonClassDao commonClassDao; + + public static CommonClassDao getCommonClassDao() { + return commonClassDao; + } + + public static void setCommonClassDao(CommonClassDao commonClassDao) { + PolicyRestController.commonClassDao = commonClassDao; + } + @Autowired - CommonClassDao commonClassDao; + private PolicyRestController(CommonClassDao commonClassDao){ + PolicyRestController.commonClassDao = commonClassDao; + } + + public PolicyRestController(){ + //default constructor + } @RequestMapping(value={"/policycreation/save_policy"}, method={RequestMethod.POST}) public void policyCreationController(HttpServletRequest request, HttpServletResponse response) { diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java index ed0bf4caf..9832f5803 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateFirewallController.java @@ -90,6 +90,14 @@ public class CreateFirewallController extends RestrictedBaseController { private static CommonClassDao commonClassDao; + public static CommonClassDao getCommonClassDao() { + return commonClassDao; + } + + public static void setCommonClassDao(CommonClassDao commonClassDao) { + CreateFirewallController.commonClassDao = commonClassDao; + } + private List tagCollectorList; private String jsonBody; List expandablePrefixIPList = new ArrayList<>(); diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java index 49024ba0d..c96da506f 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/daoImp/SystemLogDbDaoImpl.java @@ -43,16 +43,6 @@ import org.onap.policy.common.logging.flexlogger.Logger; public class SystemLogDbDaoImpl implements SystemLogDbDao { private static final Logger logger = FlexLogger.getLogger(SystemLogDbDaoImpl.class); - private static boolean jUnit = false; - - public static boolean isjUnit() { - return jUnit; - } - - public static void setjUnit(boolean jUnit) { - SystemLogDbDaoImpl.jUnit = jUnit; - } - @SuppressWarnings("unchecked") @Override public List getLoggingData() { @@ -61,7 +51,7 @@ public class SystemLogDbDaoImpl implements SystemLogDbDao { List system = null; try { String sqlWhere = null; - if(jUnit){ + if(PolicyController.isjUnit()){ sqlWhere = ""; }else{ sqlWhere = "date > DATE_SUB(curdate(), INTERVAL 5 DAY) ORDER BY date DESC limit "+PolicyController.getLogTableLimit()+""; @@ -90,7 +80,7 @@ public class SystemLogDbDaoImpl implements SystemLogDbDao { List system = null; try { String sqlWhere = null; - if(jUnit){ + if(PolicyController.isjUnit()){ sqlWhere = ""; }else{ sqlWhere = "date > DATE_SUB(curdate(), INTERVAL 5 DAY) and logtype = 'error' ORDER BY date DESC limit "+PolicyController.getSystemAlertTableLimit()+""; diff --git a/POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties b/POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties index 43b2de708..84c5dc5dd 100644 --- a/POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties +++ b/POLICY-SDK-APP/src/main/webapp/WEB-INF/conf/system.properties @@ -23,8 +23,8 @@ decryption_key = AGLDdG4D04BKm2IxIWEr8o== # The following properties MAY require changes by partner applications. ########################################################################## #Mysql -db.driver = com.mysql.jdbc.Driver -db.connectionURL = jdbc:mysql://localhost:3306/onapsdk1707 +db.driver = org.mariadb.jdbc.Driver +db.connectionURL = jdbc:mariadb://localhost:3306/onapsdk1707 db.userName = root db.password = db.hib.dialect = org.hibernate.dialect.MySQLDialect -- cgit 1.2.3-korg