diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2019-10-14 11:39:45 -0400 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2019-10-14 21:14:27 -0400 |
commit | 0950d79047d3404c15b4dd30cffeb81346565f64 (patch) | |
tree | e5c9534b7f3349684dad00cab74c4b14b9dfe733 /POLICY-SDK-APP/src/test/java/org | |
parent | 4e6615528e03f1a6f7808e28481bd55fe39ed572 (diff) |
Sonar cleanup in controllers etc
Variable renaming of consecutive capital letters.
Adding Javadoc
Missing curly braces
Re-writing some methods to reduce cyclomatic complexity
Combining while's into a simple for statement.
Addressing previous review comments
No real effort on code coverage in this one.
Issue-ID: POLICY-2133
Change-Id: I4afb3030203e1dbc743507e037ca3d57faf41f1d
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'POLICY-SDK-APP/src/test/java/org')
-rw-r--r-- | POLICY-SDK-APP/src/test/java/org/onap/policy/conf/HibernateSessionTest.java | 4 | ||||
-rw-r--r-- | POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java | 37 |
2 files changed, 25 insertions, 16 deletions
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/conf/HibernateSessionTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/conf/HibernateSessionTest.java index 3bd48d67a..2f079f139 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/conf/HibernateSessionTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/conf/HibernateSessionTest.java @@ -31,6 +31,10 @@ import org.mockito.Mockito; import org.onap.policy.controller.PolicyController; public class HibernateSessionTest { + + /** + * setup. + */ @Before public void setup() { PolicyController.setLogdbUrl("testURL"); diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java index 3bc89c9d0..16c53841c 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/daoImp/CommonClassDaoImplTest.java @@ -64,6 +64,11 @@ public class CommonClassDaoImplTest { Server server; CommonClassDaoImpl commonClassDao; + /** + * setUp. + * + * @throws Exception Exception + */ @Before public void setUp() throws Exception { try { @@ -148,17 +153,17 @@ public class CommonClassDaoImplTest { try { // Add data UserInfo userinfo = new UserInfo(); - String loginId_userName = "Test"; - userinfo.setUserLoginId(loginId_userName); - userinfo.setUserName(loginId_userName); + String loginIdUserName = "Test"; + userinfo.setUserLoginId(loginIdUserName); + userinfo.setUserName(loginIdUserName); commonClassDao.save(userinfo); List<Object> dataCur = commonClassDao.getDataByQuery("from UserInfo", new SimpleBindings()); assertEquals(1, dataCur.size()); UserInfo cur = (UserInfo) dataCur.get(0); - assertEquals(loginId_userName, cur.getUserLoginId()); - assertEquals(loginId_userName, cur.getUserName()); + assertEquals(loginIdUserName, cur.getUserLoginId()); + assertEquals(loginIdUserName, cur.getUserName()); assertFalse(dataCur.isEmpty()); @@ -190,7 +195,7 @@ public class CommonClassDaoImplTest { assertTrue(1 == dataCur.size()); assertTrue(dataCur.get(0) instanceof PolicyEntity); assertEquals(name, ((PolicyEntity) dataCur.get(0)).getPolicyName()); - assertEquals(pe, ((PolicyEntity) dataCur.get(0))); + assertEquals(pe, (dataCur.get(0))); } catch (Exception e) { logger.debug("Exception Occured" + e); @@ -229,7 +234,7 @@ public class CommonClassDaoImplTest { List<Object> dataCur = commonClassDao.getDataByQuery(query, params); assertTrue(1 == dataCur.size()); - assertEquals(pv, (PolicyVersion) dataCur.get(0)); + assertEquals(pv, dataCur.get(0)); } catch (Exception e) { logger.debug("Exception Occured" + e); @@ -244,11 +249,11 @@ public class CommonClassDaoImplTest { try { // Add data WatchPolicyNotificationTable watch = new WatchPolicyNotificationTable(); - String policyFileName = "banana"; watch.setLoginIds("Test"); watch.setPolicyName("bananaWatch"); commonClassDao.save(watch); + String policyFileName = "banana"; if (policyFileName.contains("/")) { policyFileName = policyFileName.substring(0, policyFileName.indexOf("/")); policyFileName = policyFileName.replace("/", File.separator); @@ -268,7 +273,7 @@ public class CommonClassDaoImplTest { // Assertions assertTrue(dataCur.size() == 1); assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable); - assertEquals(watch, (WatchPolicyNotificationTable) dataCur.get(0)); + assertEquals(watch, dataCur.get(0)); } catch (Exception e) { logger.debug("Exception Occured" + e); @@ -294,19 +299,19 @@ public class CommonClassDaoImplTest { commonClassDao.save(pe); String dbCheckName = "dummyScope:action"; - String[] splitDBCheckName = dbCheckName.split(":"); // Current Implementation String query = "FROM PolicyEntity where policyName like :splitDBCheckName1 and scope = :splitDBCheckName0"; SimpleBindings params = new SimpleBindings(); - params.put("splitDBCheckName1", splitDBCheckName[1] + "%"); - params.put("splitDBCheckName0", splitDBCheckName[0]); + String[] splitDbCheckName = dbCheckName.split(":"); + params.put("splitDBCheckName1", splitDbCheckName[1] + "%"); + params.put("splitDBCheckName0", splitDbCheckName[0]); List<Object> dataCur = commonClassDao.getDataByQuery(query, params); // Assertions assertTrue(dataCur.size() == 1); assertTrue(dataCur.get(0) instanceof PolicyEntity); - assertEquals(pe, (PolicyEntity) dataCur.get(0)); + assertEquals(pe, dataCur.get(0)); } catch (Exception e) { logger.debug("Exception Occured" + e); @@ -337,7 +342,7 @@ public class CommonClassDaoImplTest { // Assertions assertTrue(dataCur.size() == 1); assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable); - assertEquals(watch, (WatchPolicyNotificationTable) dataCur.get(0)); + assertEquals(watch, dataCur.get(0)); } catch (Exception e) { logger.debug("Exception Occured" + e); @@ -381,8 +386,8 @@ public class CommonClassDaoImplTest { if (dataCur.size() >= 1) { assertTrue(dataCur.get(0) instanceof WatchPolicyNotificationTable); - assertFalse(watch.equals((WatchPolicyNotificationTable) dataCur.get(0))); - assertFalse(watch.equals((WatchPolicyNotificationTable) dataCur.get(0))); + assertFalse(watch.equals(dataCur.get(0))); + assertFalse(watch.equals(dataCur.get(0))); } } catch (Exception e) { logger.debug("Exception Occured" + e); |