aboutsummaryrefslogtreecommitdiffstats
path: root/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
AgeCommit message (Collapse)AuthorFilesLines
2019-07-05Fix sonar issues in Integrity MonitorJim Hahn1-19/+20
Fixed most sonar issues, except for code coverage. Change-Id: I473635d896797b2290920da86c6770848bc2e883 Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-06-24Fix more sonar issues in Integrity Audit & MonitorJim Hahn1-576/+136
Removed duplicate code in DbDao by refactoring common code into a new updateIae() method. Removed duplicate code in IntegrityMonitor by refactoring common code into a new withinTransaction() method. Removed duplicate code in StateManagementEntity, StateElement by replacing with lombok Getter & Setter annotations. Removed duplicate code in StateManagement by refactoring common code into new setState() and getState() methods. Also removed logger.isDebugEnabled() tests. Added coverage for StateChangeNotifier. Change-Id: I2e29b836dafc5de569a2267206a6a34105e44021 Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-06-21Fix sonar issues in integrity monitorJim Hahn1-28/+27
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>
2018-10-01Fix minor sonarPamela Dragosh1-14/+17
These are mainly duplicate strings. But also combined if statements and fixing some debug messages missing arguments or format specifiers. Some duplicates I left alone as it seemed unreadable to change them. Also moving variables to their correct place (before constructors). Issue-ID: POLICY-1130 Change-Id: I8018c676b22fe8fec635f129fa37921ad1004569 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2018-06-21IntegrityMonitor: remove sleep from junit testsJim Hahn1-4/+1
Modified the code to use a CurrentTime object for its "time" operations (e.g., sleep(), currentTimeInMillis()). Modified junit tests to replace the CurrentTime object with TestTime objects so they don't actually do any sleeping. Update license date. Remove unneeded dependency from pom. Don't start FpManager thread within its own constructor. toMillis() should handle -1 as an input. Fix comment in test base superclass. Change time units in test base from DAYS to MILLISECONDS. Change-Id: Id6a4edb1747ca1a683e5d37522872b781294532d Issue-ID: POLICY-908 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-03-20Removed checkstyle warningsmmis1-905/+930
Removed checkstyle warnings in policy/common/im Issue-ID: POLICY-695 Change-Id: I32b4797249386c0d1bd0f50792880a1759503a67 Signed-off-by: mmis <michael.morris@ericsson.com>
2018-03-16Fixing 12 reported bugs in Sonar for policy/commoneikrwaq1-151/+132
Change-Id: I7bf453828f7a62070e7a73362798e6f2d4806b2f Issue-ID: POLICY-661 Signed-off-by: eikrwaq <waqas.ikram@ericsson.com>
2018-02-16Fix more generic exceptions in commonJim Hahn1-13/+13
Fixed a few more generic exceptions in integrity-audit and integrity-monitor. Fixed license dates. Change-Id: Ibbc21ae5f853896e0d3e416e33b5ea2a13672f62 Issue-ID: POLICY-246 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-02-13Add test coverage to integrity-monitorJim Hahn1-271/+140
Removed "test" from package name. Refactored tests, creating common IntegrityMonitorTestBase. Turned log/print statements into assertEquals in StateTransitionTest. Turned log/print statements into assertEquals in StateManagementTest. Modified AllSeemsWellTest to use IntegrityMonitorTestBase. Modified IntegrityMonitorTest to use IntegrityMonitorTestBase. Added several hooks to IntegrityMonitor to control timers at a finer granularity. Added hooks to IntegrityMonitor to control the FPManager thread. Remove hooks for refresh timer, as property suffices. Added assertException() and assertNoException() methods to IntegrityMonitorTestBase, and then replaced most "try/catch" blocks with calls to those methods. Updated StateManagement to close EntityManagers. Modify pom to remove scope from utils dependency. Fix some comments and remove an unneeded EntityTransaction variable. Change-Id: Ic0789d26f985a40a35f618343fa4e88aa473b2b3 Issue-ID: POLICY-582 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-01-05StateManagement EntityManager CreationKevin McKiou1-5/+22
Patch 1: This change modifies StateManagement methods that use transactions so that an EntityManager is created each time the method is called. This eliminates issues with EntityManager transactions being shared across threads causing errors when multiple threads are active. Issue-ID: POLICY-518 Change-Id: I071660a530de610ec56af82347b92496f87bf4e1 Signed-off-by: Kevin McKiou <km097d@att.com>
2017-11-21IntegrityMonitor check before commitKevin McKiou1-14/+42
Under some conditions the JPA transaction may be already closed when commit is called in StateManagement. Surround it with a check to see if the transaction is active, so it will not generate an error in the log. Issue-ID: POLICY-484 Change-Id: Id54585e68361a0be9ae8afd7e9ccba2f7eadfe5f Signed-off-by: Kevin McKiou <km097d@att.com>
2017-09-14Changed logger to slf4jMagnusen, Drew (dm741q)1-97/+201
Changed all instances of Sys.out or PolicyLogger to slf4j. Issue-ID: POLICY-178 Change-Id: Ia91af1deb18a9b5c466f6f8a6c546c17c54e14ad Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
2017-09-12Fix sonar critical associated with loggingPamela Dragosh1-25/+6
Addressing the following sonar critical: Use a logger to log this exception Either log or rethrow this exception It does not hurt to simply do these as well as clean out lines of code that dump to Sys.out via e.printStackTrace. Issue-ID: POLICY-195 Change-Id: Ibc328094a0653b7baa04778298e4a69955105ea3 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2017-08-15Resolve major/critical issues in integrity-monitorMagnusen, Drew (dm741q)1-30/+29
Resolved major and critical sonar issues in integrity-monitor module. Issue-ID: [POLICY-96] Change-Id: If1da196134a73535668d42f429d647fc819ecaee Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
2017-07-31[POLICY-71] replace openecomp for policy-commonGuo Ruijing1-0/+970
Change-Id: I3241f5d1f0234043b4dff718eda1ffdc48052276 Signed-off-by: Guo Ruijing <ruijing.guo@intel.com> Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>