aboutsummaryrefslogtreecommitdiffstats
path: root/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-06-21 13:19:31 -0400
committerJim Hahn <jrh3@att.com>2019-06-21 17:19:09 -0400
commitd6aa3faba917b45e01f5001fe3a768feddedc798 (patch)
tree077a51a89320f558f08b2d0512f6cf63450ae90d /integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java
parentc9392e1a126de54ae8a0e1f3316729e878115300 (diff)
Fix sonar issues in integrity monitor
Used Eclipse Refactor->Extract Method to reduce cyclomatic complexity. Flattened nested FpManager class into IntegrityMonitor class. Changed some strings to StringBuilder, where lots of concatenation was being done. Simplified some things by eliminating some try/catch blocks where an exception can't actually (except may an out-of-memory exception). Also addressed some sonar issues in the tests (e.g., use "<>" where appropriate). Eliminated some assertException methods, replacing them with assertj methods. Did not attempt to increase junit coverage. Change-Id: I311acaffcd87f0cbbf382c06c7fa26177007abd5 Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java')
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java50
1 files changed, 23 insertions, 27 deletions
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java
index d098af99..3e482ddf 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -53,7 +53,7 @@ public class StateManagementEntityTest extends IntegrityMonitorTestBase {
* Tear down after the test class.
*/
@AfterClass
- public static void tearDownClass() throws Exception {
+ public static void tearDownClass() {
IntegrityMonitorTestBase.tearDownAfterClass();
}
@@ -113,29 +113,25 @@ public class StateManagementEntityTest extends IntegrityMonitorTestBase {
logger.debug("??? after commit");
}
- try {
- Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
-
- query.setParameter("resource", resourceName);
-
- // Just test that we are retrieving the right object
- @SuppressWarnings("rawtypes")
- List resourceList = query.getResultList();
- if (!resourceList.isEmpty()) {
- // exist
- StateManagementEntity sme2 = (StateManagementEntity) resourceList.get(0);
-
- assertEquals(sme.getResourceName(), sme2.getResourceName());
- assertEquals(sme.getAdminState(), sme2.getAdminState());
- assertEquals(sme.getOpState(), sme2.getOpState());
- assertEquals(sme.getAvailStatus(), sme2.getAvailStatus());
- assertEquals(sme.getStandbyStatus(), sme2.getStandbyStatus());
- logger.debug("--");
- } else {
- logger.debug("Record not found, resourceName: {}", resourceName);
- }
- } catch (Exception ex) {
- logger.error("Exception on select query: " + ex.toString());
+ Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+
+ query.setParameter("resource", resourceName);
+
+ // Just test that we are retrieving the right object
+ @SuppressWarnings("rawtypes")
+ List resourceList = query.getResultList();
+ if (!resourceList.isEmpty()) {
+ // exist
+ StateManagementEntity sme2 = (StateManagementEntity) resourceList.get(0);
+
+ assertEquals(sme.getResourceName(), sme2.getResourceName());
+ assertEquals(sme.getAdminState(), sme2.getAdminState());
+ assertEquals(sme.getOpState(), sme2.getOpState());
+ assertEquals(sme.getAvailStatus(), sme2.getAvailStatus());
+ assertEquals(sme.getStandbyStatus(), sme2.getStandbyStatus());
+ logger.debug("--");
+ } else {
+ logger.debug("Record not found, resourceName: {}", resourceName);
}
logger.debug("\n\nJpaTest: Exit\n\n");