Fix checkstyle issues 97/60597/1
authorPamela Dragosh <pdragosh@research.att.com>
Tue, 14 Aug 2018 18:22:34 +0000 (14:22 -0400)
committerPamela Dragosh <pdragosh@research.att.com>
Tue, 14 Aug 2018 18:22:41 +0000 (14:22 -0400)
Spacing, missing javadoc

Issue-ID: POLICY-883
Change-Id: Ice65c6c1baf0bb7c6273411f078bacfe3496b89b
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
controlloop/common/feature-controlloop-amsterdam/src/test/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeatureTest.java
controlloop/common/feature-controlloop-casablanca/src/test/java/org/onap/policy/drools/apps/controlloop/feature/casablanca/CasablancaFeatureTest.java
controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java
controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java
controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
controlloop/common/guard/src/test/java/org/onap/policy/guard/PIPEngineGetHistoryTest.java
controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java
controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java

index fa608ca..a1df89c 100644 (file)
@@ -663,7 +663,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
         if (event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED) != null
                 || event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED) != null) {
             
-            if(isClosedLoopDisabled(event)) {
+            if (isClosedLoopDisabled(event)) {
                 throw new AaiException("is-closed-loop-disabled is set to true on VServer or VNF");
             }
             
@@ -671,7 +671,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
             return;
         }
         
-        if(vnfResponse != null || vserverResponse != null) {
+        if (vnfResponse != null || vserverResponse != null) {
             // query has already been performed
             return;
         }
index 3c818b8..790d434 100644 (file)
@@ -43,26 +43,26 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Control Loop Metrics Tracker
+ * Control Loop Metrics Tracker.
  */
 public interface ControlLoopMetrics {
 
     /**
-     * gets all transaction identifiers being monitored
+     * Gets all transaction identifiers being monitored.
      *
      * @return transaction id list
      */
     List<UUID> getTransactionIds();
 
     /**
-     * gets all detailed transactions
+     * Gets all detailed transactions.
      *
      * @return list of transactions
      */
     List<VirtualControlLoopNotification> getTransactions();
 
     /**
-     * track controller's notification events
+     * Track controller's notification events.
      *
      * @param controller policy controller sending out notification
      * @param notification notification
@@ -70,7 +70,7 @@ public interface ControlLoopMetrics {
     void transactionEvent(PolicyController controller, VirtualControlLoopNotification notification);
 
     /**
-     * gets an in-progress transaction
+     * Gets an in-progress transaction.
      *
      * @param requestId request ID
      * @return in progress notification
@@ -78,49 +78,49 @@ public interface ControlLoopMetrics {
     VirtualControlLoopNotification getTransaction(UUID requestId);
 
     /**
-     * removes an in-progress transaction
+     * Removes an in-progress transaction.
      *
      * @param requestId request ID
      */
     void removeTransaction(UUID requestId);
 
     /**
-     * get cache size
+     * Get cache size.
      *
      * @return cache size
      */
     long getCacheSize();
 
     /**
-     * get cache size
+     * Get cache size.
      *
      * @return cache size
      */
     long getCacheOccupancy();
 
     /**
-     * sets cache size
+     * Sets cache size.
      *
      * @param cacheSize cache size
      */
     void setMaxCacheSize(long cacheSize);
 
     /**
-     * cached transaction expiration timeout in seconds
+     * Cached transaction expiration timeout in seconds.
      *
      * @return transaction timeout in seconds
      */
     long getTransactionTimeout();
 
     /**
-     * sets transaction timeout in seconds
+     * Sets transaction timeout in seconds.
      *
      * @param transactionTimeout transaction timeout in seconds
      */
     void setTransactionTimeout(long transactionTimeout);
 
     /**
-     * reset cache
+     * Reset cache.
      *
      * @param cacheSize new cache size
      * @param transactionTimeout new transaction timeout in seconds
@@ -128,19 +128,19 @@ public interface ControlLoopMetrics {
     void resetCache(long cacheSize, long transactionTimeout);
 
     /**
-     * refresh underlying transaction management
+     * Refresh underlying transaction management.
      */
     void refresh();
 
     /**
-     * singleton manager object
+     * Singleton manager object.
      */
     ControlLoopMetrics manager = new CacheBasedControlLoopMetricsManager();
 }
 
 
 /**
- * Control Loop Metrics Tracker Implementation
+ * Control Loop Metrics Tracker Implementation.
  */
 class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
 
@@ -189,24 +189,24 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
         CacheLoader<UUID, VirtualControlLoopNotification> loader =
                 new CacheLoader<UUID, VirtualControlLoopNotification>() {
 
-                    @Override
-                    public VirtualControlLoopNotification load(UUID key) throws Exception {
-                        return null;
-                    }
-                };
+            @Override
+            public VirtualControlLoopNotification load(UUID key) throws Exception {
+                return null;
+            }
+        };
 
         RemovalListener<UUID, VirtualControlLoopNotification> listener =
                 new RemovalListener<UUID, VirtualControlLoopNotification>() {
-                    @Override
-                    public void onRemoval(RemovalNotification<UUID, VirtualControlLoopNotification> notification) {
-                        if (notification.wasEvicted()) {
-                            evicted(notification.getValue());
-                        } else {
-                            logger.info("REMOVAL: {} because of {}", notification.getValue().getRequestId(),
+            @Override
+            public void onRemoval(RemovalNotification<UUID, VirtualControlLoopNotification> notification) {
+                if (notification.wasEvicted()) {
+                    evicted(notification.getValue());
+                } else {
+                    logger.info("REMOVAL: {} because of {}", notification.getValue().getRequestId(),
                                     notification.getCause().name());
-                        }
-                    }
-                };
+                }
+            }
+        };
 
         synchronized (this) {
             if (this.cache != null) {
@@ -280,7 +280,7 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
     }
 
     /**
-     * tracks an in progress control loop transaction
+     * Tracks an in progress control loop transaction.
      *
      * @param notification control loop notification
      */
@@ -293,7 +293,7 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
     }
 
     /**
-     * end of a control loop transaction
+     * End of a control loop transaction.
      *
      * @param notification control loop notification
      */
@@ -307,8 +307,9 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
         }
 
         this.transaction(notification, startTime);
-        if (startNotification != null)
+        if (startNotification != null) {
             cache.invalidate(startNotification);
+        }
     }
 
     protected void evicted(VirtualControlLoopNotification notification) {
index b15fb14..37bafa4 100644 (file)
@@ -33,23 +33,23 @@ import org.slf4j.LoggerFactory;
 public class ControlLoopMetricsFeature implements PolicyControllerFeatureAPI {
 
     /**
-     * Feature Sequence Priority
+     * Feature Sequence Priority.
      */
     public final static int FEATURE_SEQUENCE_PRIORITY = 100000;
 
     /**
-     * Properties Configuration Name
+     * Properties Configuration Name.
      */
     public static final String CONFIGURATION_PROPERTIES_NAME = "feature-controlloop-trans";
 
     /**
-     * maximum number of transaction cache entries
+     * Maximum number of transaction cache entries.
      */
     public static final String CL_CACHE_TRANS_SIZE_PROPERTY = "controlloop.cache.transactions.size";
     public static final int CL_CACHE_TRANS_SIZE_DEFAULT = 100;
 
     /**
-     * transaction timeout in minutes
+     * Transaction timeout in minutes.
      */
     public static final String CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY =
             "controllop.cache.transactions.timeout.seconds";
@@ -61,12 +61,12 @@ public class ControlLoopMetricsFeature implements PolicyControllerFeatureAPI {
     }
 
     /**
-     * Logger
+     * Logger.
      */
     private static Logger logger = LoggerFactory.getLogger(ControlLoopMetricsFeature.class);
 
     /**
-     * Intercept Control Loop Notifications
+     * Intercept Control Loop Notifications.
      *
      * @param controller - controller
      * @param protocol - protocol
index df93c7a..1f1e9de 100644 (file)
@@ -39,13 +39,16 @@ import org.onap.policy.drools.system.PolicyController;
 import org.onap.policy.drools.system.PolicyEngine;
 
 /**
- * ControlLoopMetrics Tests
+ * ControlLoopMetrics Tests.
  */
 public class ControlLoopMetricsFeatureTest {
 
     private static final Path configPath = SystemPersistence.manager.getConfigurationPath();
     private static PolicyController testController;
 
+    /**
+     * Setup method.
+     */
     @BeforeClass
     public static void setUp() {
         SystemPersistence.manager.setConfigurationDir("src/test/resources");
index e9ff010..e4fd274 100644 (file)
@@ -64,6 +64,8 @@ public class PolicyGuard {
     }
     
     /**
+     * Get the factory.
+     * 
      * @return the factory used to access various objects
      */
     protected static Factory getFactory() {
@@ -72,7 +74,7 @@ public class PolicyGuard {
     
     /**
      * Sets the factory to be used by junit tests.
-     * @param factory
+     * @param factory factory
      */
     protected static void setFactory(Factory factory) {
         PolicyGuard.factory = factory;
@@ -95,7 +97,7 @@ public class PolicyGuard {
         String owner = makeOwner(targetType, requestID);
 
         boolean result = factory.getManager().lock(targetInstance, owner, holdSec);
-        if(!result) {
+        if (!result) {
             return LockResult.createLockResult(GuardResult.LOCK_DENIED, null);
         }
         
@@ -145,7 +147,7 @@ public class PolicyGuard {
         boolean result = factory.getManager().refresh(lock.getTargetInstance(), owner, holdSec);
         
         logger.debug("Lock {} extend {}", lock, result);
-        return(result ? GuardResult.LOCK_ACQUIRED : GuardResult.LOCK_DENIED);
+        return (result ? GuardResult.LOCK_ACQUIRED : GuardResult.LOCK_DENIED);
     }
 
     /**
@@ -160,7 +162,7 @@ public class PolicyGuard {
         String owner = makeOwner(lock.getTargetType(), lock.getRequestID());
         boolean result = factory.getManager().unlock(lock.getTargetInstance(), owner);
         
-        if(result) {
+        if (result) {
             logger.debug("Unlocked {}", lock);
             return true;            
         }
@@ -184,17 +186,17 @@ public class PolicyGuard {
 
     /**
      * Combines the target type and request ID to yield a single, "owner" string.
-     * @param targetType
-     * @param requestID
+     * @param targetType target type
+     * @param requestID request id
      * @return the "owner" of a resource
      * @throws IllegalArgumentException if either argument is null
      */
     private static String makeOwner(TargetType targetType, UUID requestID) {
-        if(targetType == null) {
+        if (targetType == null) {
             throw new IllegalArgumentException("null targetType for lock request id " + requestID);
         }
 
-        if(requestID == null) {
+        if (requestID == null) {
             throw new IllegalArgumentException("null requestID for lock type " + targetType);
         }
         
@@ -207,6 +209,8 @@ public class PolicyGuard {
     public static class Factory {
 
         /**
+         * Get the manager.
+         * 
          * @return the lock manager to be used
          */
         public PolicyResourceLockManager getManager() {
index 233fc0b..46a815c 100644 (file)
@@ -135,7 +135,7 @@ public final class Util {
     /**
      * Sets Guard Properties.
      * 
-     * @see /guard/src/test/java/org/onap/policy/guard/UtilTest.java for setting test properties
+     * <p>see /guard/src/test/java/org/onap/policy/guard/UtilTest.java for setting test properties
      */
     public static void setGuardEnvProps(String url, String username, String password, String clientName,
             String clientPassword, String environment) {
index e728d41..8c7392e 100644 (file)
@@ -113,6 +113,9 @@ public class PIPEngineGetHistoryTest {
         emf.close();
     }
 
+    /**
+     * Setup method.
+     */
     @Before
     public void setUp() {
         // clear the table
index dd1ede4..9cee0af 100644 (file)
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+
 import java.util.UUID;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -105,6 +106,9 @@ public class PolicyGuardTest {
         PolicyGuard.setFactory(saveFactory);
     }
     
+    /**
+     * Setup method.
+     */
     @Before
     public void setUp() {
         mgr = spy(new PolicyResourceLockManager() {
@@ -282,14 +286,14 @@ public class PolicyGuardTest {
 
         // acquired
         result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid, dlcb, LOCK_SEC);
-        verify(mgr).lock(INSTANCENAME, type+":"+uuid, LOCK_SEC);
+        verify(mgr).lock(INSTANCENAME, type + ":" + uuid, LOCK_SEC);
         assertEquals(GuardResult.LOCK_ACQUIRED, result.getA());
         assertEquals(VMTargetLock.class, result.getB().getClass());
 
         // diff owner - denied
         UUID uuid2 = UUID.randomUUID();
-        result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid2, dlcb, LOCK_SEC+10);
-        verify(mgr).lock(INSTANCENAME, type+":"+uuid2, LOCK_SEC+10);
+        result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid2, dlcb, LOCK_SEC + 10);
+        verify(mgr).lock(INSTANCENAME, type + ":" + uuid2, LOCK_SEC + 10);
         assertEquals(GuardResult.LOCK_DENIED, result.getA());
         assertNull(result.getB());
     }
@@ -302,21 +306,21 @@ public class PolicyGuardTest {
 
         // acquired
         result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid, dlcb, LOCK_SEC);
-        verify(mgr).lock(INSTANCENAME, type+":"+uuid, LOCK_SEC);
+        verify(mgr).lock(INSTANCENAME, type + ":" + uuid, LOCK_SEC);
         assertEquals(GuardResult.LOCK_ACQUIRED, result.getA());
         assertEquals(VMTargetLock.class, result.getB().getClass());
         
         TargetLock lock = result.getB();
         
         // refresh - re-acquired
-        assertEquals(GuardResult.LOCK_ACQUIRED, PolicyGuard.lockTarget(lock, LOCK_SEC+1));
-        verify(mgr).refresh(INSTANCENAME, type+":"+uuid, LOCK_SEC+1);
+        assertEquals(GuardResult.LOCK_ACQUIRED, PolicyGuard.lockTarget(lock, LOCK_SEC + 1));
+        verify(mgr).refresh(INSTANCENAME, type + ":" + uuid, LOCK_SEC + 1);
         
         // unlock
         PolicyGuard.unlockTarget(lock);
         
         // refresh - denied, as we no longer own the lock
-        assertEquals(GuardResult.LOCK_DENIED, PolicyGuard.lockTarget(lock, LOCK_SEC+2));
+        assertEquals(GuardResult.LOCK_DENIED, PolicyGuard.lockTarget(lock, LOCK_SEC + 2));
     }
 
     @Test(expected = IllegalArgumentException.class)
index b088af7..27c9bf8 100644 (file)
@@ -52,6 +52,9 @@ public class ControlLoopCompiler implements Serializable {
     private static final long serialVersionUID = 1L;
     private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopCompiler.class.getName());
     
+    /**
+     * Compiles the policy from an object.
+     */
     public static ControlLoopPolicy compile(ControlLoopPolicy policy, 
                     ControlLoopCompilerCallback callback) throws CompilerException {
         //
@@ -66,6 +69,15 @@ public class ControlLoopCompiler implements Serializable {
         return policy;
     }
     
+    /**
+     * Compiles the policy from an input stream.
+     * 
+     * @param yamlSpecification the yaml input stream
+     * @param callback method to callback during compilation
+     * @return
+     * 
+     * @throws CompilerException throws any compile exception found
+     */
     public static ControlLoopPolicy compile(InputStream yamlSpecification, 
                     ControlLoopCompilerCallback callback) throws CompilerException {
         Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class));
@@ -84,7 +96,7 @@ public class ControlLoopCompiler implements Serializable {
         if (controlLoop == null && callback != null) {
             callback.onError("controlLoop cannot be null");
         }
-        if (controlLoop!=null){
+        if (controlLoop != null) {
             if ((controlLoop.getControlLoopName() == null || controlLoop.getControlLoopName().length() < 1) 
                             && callback != null) {
                 callback.onError("Missing controlLoopName");