From 1ff3457738007037364a103c28836d582098f764 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Tue, 27 Nov 2018 15:15:57 -0500 Subject: Remove Factory from IntegrityMonitor Also removed unneeded method override in junit test. Change-Id: I7186e9f75443f7b8ba8376aa0e00a5cf4c573696 Issue-ID: POLICY-1287 Signed-off-by: Jim Hahn --- .../onap/policy/common/im/IntegrityMonitor.java | 68 ++++++++++------------ 1 file changed, 31 insertions(+), 37 deletions(-) (limited to 'integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java') diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java index 8e9dd3dd..9801b530 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java @@ -75,9 +75,6 @@ public class IntegrityMonitor { */ private static final String QUERY_STRING = "Select f from ForwardProgressEntity f where f.resourceName=:rn"; - // may be changed by junit tests - private static Factory factory = new Factory(); - private static String resourceName = null; boolean alarmExists = false; @@ -224,13 +221,13 @@ public class IntegrityMonitor { // // Create the entity manager factory // - emf = Persistence.createEntityManagerFactory(factory.getPersistenceUnit(), properties); + emf = Persistence.createEntityManagerFactory(getPersistenceUnit(), properties); // // Did it get created? // if (emf == null) { - logger.error("Error creating IM entity manager factory with persistence unit: {}", - factory.getPersistenceUnit()); + logger.error("Error creating IM entity manager factory with persistence unit: {}", + getPersistenceUnit()); throw new IntegrityMonitorException("Unable to create IM Entity Manager Factory"); } @@ -1714,13 +1711,13 @@ public class IntegrityMonitor { logger.debug("FPManager thread running"); try { - factory.runStarted(); + runStarted(); while (!stopRequested) { MonitorTime.getInstance().sleep(CYCLE_INTERVAL_MILLIS); - - this.runOnce(); - factory.monitorCompleted(); + + runOnce(); + monitorCompleted(); } } catch (InterruptedException e) { @@ -1865,38 +1862,35 @@ public class IntegrityMonitor { public Map getAllNotWellMap() { return allNotWellMap; } + + // these methods may be overridden by junit tests /** - * Wrapper used to access various objects. Overridden by junit tests. + * Indicates that the {@link FpManager#run()} method has started. This method + * simply returns. + * + * @throws InterruptedException can be interrupted */ - public static class Factory { - - /** - * Indicates that the {@link FpManager#run()} method has started. This method simply returns. - * - * @throws InterruptedException can be interrupted - */ - public void runStarted() throws InterruptedException { - // does nothing - } + protected void runStarted() throws InterruptedException { + // does nothing + } - /** - * Indicates that a monitor activity has completed. This method simply returns. - * - * @throws InterruptedException can be interrupted - */ - public void monitorCompleted() throws InterruptedException { - // does nothing - } + /** + * Indicates that a monitor activity has completed. This method simply returns. + * + * @throws InterruptedException can be interrupted + */ + protected void monitorCompleted() throws InterruptedException { + // does nothing + } - /** - * Get persistence unit. - * - * @return the persistence unit to be used - */ - public String getPersistenceUnit() { - return PERSISTENCE_UNIT; - } + /** + * Get persistence unit. + * + * @return the persistence unit to be used + */ + protected String getPersistenceUnit() { + return PERSISTENCE_UNIT; } /* -- cgit 1.2.3-korg