Fixes for checkstyle issues 51/60551/1
authorPamela Dragosh <pdragosh@research.att.com>
Tue, 14 Aug 2018 13:45:44 +0000 (09:45 -0400)
committerPamela Dragosh <pdragosh@research.att.com>
Tue, 14 Aug 2018 13:45:50 +0000 (09:45 -0400)
More fixes for spacing, adding comments, adding period at the
end, and move code closer to usage.

Issue-ID: POLICY-881
Change-Id: Ife99eaf627a221e87d65d24dfd145b0ee4e06d21
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
17 files changed:
common-logging/src/main/java/org/onap/policy/common/logging/eelf/DroolsPDPMDCInfo.java
common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java
common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java
integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java
integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java
integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
integrity-audit/src/main/resources/META-INF/persistence.xml
integrity-audit/src/test/java/org/onap/policy/common/ia/AuditPeriodTest.java
integrity-audit/src/test/java/org/onap/policy/common/ia/AuditorTimeTest.java
integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java
integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
integrity-monitor/src/main/java/org/onap/policy/common/im/MonitorTime.java
integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java
integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java
integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java
integrity-monitor/src/test/java/org/onap/policy/common/im/MonitorTimeTest.java

index 0c6c13b..f5ab4c7 100644 (file)
@@ -41,7 +41,7 @@ public class DroolsPDPMDCInfo implements MDCInfo {
     }
 
     /**
-     * Get the MMDC Info
+     * Get the MMDC Info.
      * 
      * @return the instance of ConcurrentHashMap.
      */
index 566362c..9d9165e 100644 (file)
@@ -49,7 +49,7 @@ public class PropertyUtil {
     private static HashMap<File, ListenerRegistration> registrations = new HashMap<>();
 
     /**
-     * Read in a properties file
+     * Read in a properties file.
      * 
      * @param file the properties file
      * @return a Properties object, containing the associated properties
@@ -73,7 +73,7 @@ public class PropertyUtil {
     }
 
     /**
-     * Read in a properties file
+     * Read in a properties file.
      * 
      * @param fileName the properties file
      * @return a Properties object, containing the associated properties
index b4fcfc1..478f557 100644 (file)
@@ -27,6 +27,7 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyLong;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.mock;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -46,9 +47,6 @@ import org.powermock.reflect.Whitebox;
 
 public class PropertyUtilTest {
 
-    /**
-     * 
-     */
     private static final String TIMER_FIELD = "timer";
     private static final File FILE = new File("target/test.properties");
     private static Timer saveTimer;
index dc396a0..177391c 100644 (file)
@@ -709,7 +709,7 @@ public class AuditThread extends Thread {
      * Indicates that the {@link #run()} method has started. This method simply returns,
      * and may overridden by junit tests.
      * 
-     * @throws InterruptedException
+     * @throws InterruptedException can be interrupted
      */
     public void runStarted() throws InterruptedException {
         // does nothing
@@ -719,7 +719,7 @@ public class AuditThread extends Thread {
      * Indicates that an audit has completed. This method simply returns, and may
      * overridden by junit tests.
      * 
-     * @throws InterruptedException
+     * @throws InterruptedException can be interrupted
      */
     public void auditCompleted() throws InterruptedException {
         // does nothing
index 9cff742..95eecbc 100644 (file)
@@ -41,13 +41,15 @@ public class AuditorTime {
     private static Supplier<CurrentTime> supplier = () -> currentTime;
 
     /**
-     * 
+     * Constructor.
      */
     private AuditorTime() {
         super();
     }
 
     /**
+     * Get instance.
+     * 
      * @return the CurrentTime singleton
      */
     public static CurrentTime getInstance() {
index 4d15205..d50c705 100644 (file)
@@ -206,8 +206,10 @@ public class IntegrityAudit {
         logger.info("startAuditThread: Entering");
 
         if (integrityAuditPeriodSeconds >= 0) {
-            this.auditThread = makeAuditThread(this.resourceName, this.persistenceUnit, this.properties, integrityAuditPeriodSeconds);
-            logger.info("startAuditThread: Audit started and will run every " + integrityAuditPeriodSeconds + " seconds");
+            this.auditThread = makeAuditThread(this.resourceName, this.persistenceUnit, 
+                            this.properties, integrityAuditPeriodSeconds);
+            logger.info("startAuditThread: Audit started and will run every " + integrityAuditPeriodSeconds 
+                            + " seconds");
             this.auditThread.start();
             
         } else {
@@ -269,6 +271,7 @@ public class IntegrityAudit {
     }
 
     /**
+     * Return if audit thread.
      * 
      * @return {@code true} if an audit thread exists, {@code false} otherwise
      */
@@ -279,13 +282,13 @@ public class IntegrityAudit {
     /**
      * Creates an audit thread. May be overridden by junit tests.
      * 
-     * @param resourceName2
-     * @param persistenceUnit2
-     * @param properties2
+     * @param resourceName2 the resource name
+     * @param persistenceUnit2 the persistence unit
+     * @param properties2 properties
      * @param integrityAuditPeriodSeconds2
      * 
      * @return a new audit thread
-     * @throws IntegrityAuditException
+     * @throws IntegrityAuditException audit exception
      */
     protected AuditThread makeAuditThread(String resourceName2, String persistenceUnit2, Properties properties2,
                     int integrityAuditPeriodSeconds2) throws IntegrityAuditException {
index 2f43561..33c701b 100644 (file)
   -->
 
 <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
-       <persistence-unit name="testPU" transaction-type="RESOURCE_LOCAL">
-       <!-- Limited use for generating the DB and schema files for iatest DB - uses eclipselink -->
-               <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-               <class>org.onap.policy.common.ia.jpa.IntegrityAuditEntity</class>
-               <class>org.onap.policy.common.ia.jpa.IaTestEntity</class>
-               <shared-cache-mode>NONE</shared-cache-mode>
-               <properties>
-                       <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
-        </properties>
-       </persistence-unit>
+ <persistence-unit name="testPU" transaction-type="RESOURCE_LOCAL">
+  <!-- Limited use for generating the DB and schema files for iatest DB - 
+   uses eclipselink -->
+  <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+  <class>org.onap.policy.common.ia.jpa.IntegrityAuditEntity</class>
+  <class>org.onap.policy.common.ia.jpa.IaTestEntity</class>
+  <shared-cache-mode>NONE</shared-cache-mode>
+  <properties>
+   <property name="javax.persistence.schema-generation.database.action"
+    value="drop-and-create" />
+  </properties>
+ </persistence-unit>
 
-       <persistence-unit name="integrityAuditPU" transaction-type="RESOURCE_LOCAL">
-       <!-- For operational use -->
-               <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-               <class>org.onap.policy.common.ia.jpa.IntegrityAuditEntity</class>               
-               <shared-cache-mode>NONE</shared-cache-mode>     
-               <properties>
-                       <!-- none -->
-        </properties>
-       </persistence-unit>
+ <persistence-unit name="integrityAuditPU"
+  transaction-type="RESOURCE_LOCAL">
+  <!-- For operational use -->
+  <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+  <class>org.onap.policy.common.ia.jpa.IntegrityAuditEntity</class>
+  <shared-cache-mode>NONE</shared-cache-mode>
+  <properties>
+   <!-- none -->
+  </properties>
+ </persistence-unit>
 </persistence>
index 5baf21a..9aad686 100644 (file)
@@ -227,7 +227,7 @@ public class AuditPeriodTest extends IntegrityAuditTestBase {
                         runAudit(p);
                         long elapsed = p.getTimeInMillis() - tbegin;
                         
-                        synchronized(tmin) {
+                        synchronized (tmin) {
                             tmin.set(Math.min(tmin.get(), elapsed));
                         }
 
index 6ee1010..7da157f 100644 (file)
 package org.onap.policy.common.ia;
 
 import static org.junit.Assert.*;
+
 import org.junit.Test;
 import org.onap.policy.common.utils.time.CurrentTime;
 
 /**
- * 
+ * Tests the AuditorTime class.
  */
 public class AuditorTimeTest {
 
index e7ea47e..8e84878 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.policy.common.ia;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.fail;
+
 import java.util.List;
 import java.util.Properties;
 import javax.persistence.EntityManager;
index 94ee029..9324dfb 100644 (file)
@@ -22,6 +22,9 @@ package org.onap.policy.common.ia;
 
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -45,8 +48,6 @@ import org.onap.policy.common.utils.time.CurrentTime;
 import org.onap.policy.common.utils.time.TestTime;
 import org.powermock.reflect.Whitebox;
 import org.slf4j.LoggerFactory;
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
 
 /**
  * All JUnits are designed to run in the local development environment where they have write
@@ -267,6 +268,8 @@ public class IntegrityAuditTestBase {
     }
 
     /**
+     * Get the test time.
+     * 
      * @return the {@link TestTime} in use by this thread
      */
     public static TestTime getTestTime() {
@@ -521,10 +524,11 @@ public class IntegrityAuditTestBase {
          * @param resourceName the resource name
          * @param persistenceUnit the persistence unit
          * @param properties the properties
-         * @param time 
+         * @param time the time
          * @throws Exception if an error occurs
          */
-        public MyIntegrityAudit(String resourceName, String persistenceUnit, Properties properties, TestTime time) throws Exception {
+        public MyIntegrityAudit(String resourceName, String persistenceUnit, 
+                        Properties properties, TestTime time) throws Exception {
             super(resourceName, persistenceUnit, properties);
             
             myTime = time;
@@ -536,6 +540,8 @@ public class IntegrityAuditTestBase {
         }
         
         /**
+         * Get time in milliseconds.
+         * 
          * @return the "current" time for the auditor
          */
         public long getTimeInMillis() {
@@ -545,8 +551,8 @@ public class IntegrityAuditTestBase {
         /**
          * Sleeps for a period of time.
          * 
-         * @param sleepMs
-         * @throws InterruptedException
+         * @param sleepMs time to sleep
+         * @throws InterruptedException can be interrupted
          */
         public void sleep(long sleepMs) throws InterruptedException {
             myTime.sleep(sleepMs);
index eee7705..9845fc7 100644 (file)
@@ -213,7 +213,8 @@ public class IntegrityMonitor {
         // 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: {}", 
+                            factory.getPersistenceUnit());
             throw new IntegrityMonitorException("Unable to create IM Entity Manager Factory");
         }
 
@@ -1713,7 +1714,7 @@ public class IntegrityMonitor {
             try {
                 factory.runStarted();
 
-                while(!stopRequested) {
+                while (!stopRequested) {
                     MonitorTime.getInstance().sleep(CYCLE_INTERVAL_MILLIS);
                     
                     IntegrityMonitor.this.runOnce();
@@ -1873,7 +1874,7 @@ public class IntegrityMonitor {
          * Indicates that the {@link FpManager#run()} method has started. This method
          * simply returns.
          * 
-         * @throws InterruptedException
+         * @throws InterruptedException can be interrupted
          */
         public void runStarted() throws InterruptedException {
             // does nothing
@@ -1882,13 +1883,15 @@ public class IntegrityMonitor {
         /**
          * Indicates that a monitor activity has completed. This method simply returns.
          * 
-         * @throws InterruptedException
+         * @throws InterruptedException can be interrupted
          */
         public void monitorCompleted() throws InterruptedException {
             // does nothing
         }
 
         /**
+         * Get persistence unit.
+         * 
          * @return the persistence unit to be used
          */
         public String getPersistenceUnit() {
index 271fa65..e489a8c 100644 (file)
@@ -33,13 +33,15 @@ public class MonitorTime {
     private static CurrentTime instance = new CurrentTime();
 
     /**
-     * 
+     * Constructor.
      */
     private MonitorTime() {
         super();
     }
 
     /**
+     * Get instance.
+     * 
      * @return the CurrentTime singleton
      */
     public static CurrentTime getInstance() {
index 8aec2f0..fe40893 100644 (file)
@@ -22,6 +22,7 @@ package org.onap.policy.common.im;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+
 import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.Semaphore;
index f7ffa21..3c4fba2 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.policy.common.im;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
+
 import java.util.Date;
 import java.util.List;
 import java.util.Properties;
@@ -645,8 +646,6 @@ public class IntegrityMonitorTest extends IntegrityMonitorTestBase {
         myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "5");
         myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "5");
 
-        IntegrityMonitor im = makeMonitor(resourceName, myProp);
-
         // Note: do ***NOT*** do waitStep() here
 
         // Add a group1 dependent resources to put an entry in the forward
@@ -663,6 +662,8 @@ public class IntegrityMonitorTest extends IntegrityMonitorTestBase {
 
         new StateManagement(emf, "group1_dep1");
 
+        IntegrityMonitor im = makeMonitor(resourceName, myProp);
+
         assertNoException(im, imx -> {
             imx.evaluateSanity();
         });
index adde768..ba1fc34 100644 (file)
@@ -22,6 +22,7 @@ package org.onap.policy.common.im;
 
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Properties;
@@ -233,6 +234,8 @@ public class IntegrityMonitorTestBase {
     }
 
     /**
+     * Get saved factory.
+     * 
      * @return the original integrity monitor factory
      */
     static Factory getSavedFactory() {
@@ -252,6 +255,8 @@ public class IntegrityMonitorTestBase {
     }
     
     /**
+     * Get current test time.
+     * 
      * @return the "current" time, in milliseconds
      */
     protected static long getCurrentTestTime() {
@@ -272,7 +277,7 @@ public class IntegrityMonitorTestBase {
     /**
      * Waits for a semaphore to be acquired.
      * 
-     * @param sem
+     * @param sem semaphore to wait on
      * @throws InterruptedException if the thread is interrupted
      * @throws AssertionError if the semaphore was not acquired within the allotted time
      */
index 5f20a83..69d2f85 100644 (file)
 
 package org.onap.policy.common.im;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import org.junit.Test;
 import org.onap.policy.common.utils.time.CurrentTime;
 
 /**
- * 
+ * Class that tests MonitorTime.
  */
 public class MonitorTimeTest {