Checkstyle the context-management package 03/60103/2
authorDinh Danh Le <dinh.danh.le@ericsson.com>
Sat, 11 Aug 2018 16:17:34 +0000 (17:17 +0100)
committerDinh Danh Le <dinh.danh.le@ericsson.com>
Sat, 11 Aug 2018 16:32:25 +0000 (17:32 +0100)
Change-Id: Ifc4fef920681f21b0a965ea55d9bb78785ec66f9
Signed-off-by: Dinh Danh Le <dinh.danh.le@ericsson.com>
Issue-ID: POLICY-1034

14 files changed:
context/context-management/src/main/java/org/onap/policy/apex/context/ContextAlbum.java
context/context-management/src/main/java/org/onap/policy/apex/context/ContextException.java
context/context-management/src/main/java/org/onap/policy/apex/context/ContextRuntimeException.java
context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/AbstractSchemaHelper.java
context/context-management/src/main/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelper.java
context/context-management/src/main/java/org/onap/policy/apex/context/parameters/ContextParameters.java
context/context-management/src/main/java/org/onap/policy/apex/context/parameters/PersistorParameters.java
context/context-management/src/main/java/org/onap/policy/apex/context/parameters/SchemaParameters.java
context/context-management/src/test/java/org/onap/policy/apex/context/ContextExceptionTest.java
context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java
context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/MyBaseClass.java
context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/MySubClass.java

index 5591393..b3e8528 100644 (file)
@@ -27,26 +27,32 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
 
 /**
- * The Interface ContextAlbum is implemented by all classes that manage context in Apex. Context albums may store
- * context in memory, on disk, in a repository or in a mechanism such as a distributed map.
- * <p>
- * A context album uses plugins to handle its context schemas, its distribution, its locking, and its persistence.
- * <p>
- * The schema that defines the items in a context album is interpreted by a plugin that implements the
- * {@link SchemaHelper} interface. The schema helper uses the schema definition to provide new instances for a context
- * album. By default, context albums use Java schemas.
- * <p>
- * Context albums may be shared across an arbitrary number of JVMs using a distribution mechanism. Apex context
- * distributed context albums using plugins that implement the {@link Distributor} interface. By default, context albums
- * use JVM local distribution, that is context albums are only available in a single JVM
- * <p>
- * Items in a context album may be locked across all distributed instances of an album. Apex locks instances on context
- * albums using the distributed locking mechanism in a plugin that implements the {@link LockManager} interface. By
- * default, context albums use Java locking local to a single JVM on each context album instance.
+ * The Interface ContextAlbum is implemented by all classes that manage context in Apex. Context
+ * albums may store context in memory, on disk, in a repository or in a mechanism such as a
+ * distributed map.
+ *
+ * <p>A context album uses plugins to handle its context schemas, its distribution, its locking, and
+ * its persistence.
+ *
  * <p>
- * Context albums may be persisted to disk, database, or any other repository. Apex persists context albums using the
- * persistence mechanism in a plugin that implements the {@link Persistor} interface. By default, context albums use a
- * dummy persistor plugin that does not persist context albums.
+ * The schema that defines the items in a context album is interpreted by a plugin that implements
+ * the {@link SchemaHelper} interface. The schema helper uses the schema definition to provide new
+ * instances for a context album. By default, context albums use Java schemas.
+ *
+ * <p>Context albums may be shared across an arbitrary number of JVMs using a distribution mechanism.
+ * Apex context distributed context albums using plugins that implement the {@link Distributor}
+ * interface. By default, context albums use JVM local distribution, that is context albums are only
+ * available in a single JVM
+ *
+ * <p>Items in a context album may be locked across all distributed instances of an album. Apex locks
+ * instances on context albums using the distributed locking mechanism in a plugin that implements
+ * the {@link LockManager} interface. By default, context albums use Java locking local to a single
+ * JVM on each context album instance.
+ *
+ * <p>Context albums may be persisted to disk, database, or any other repository. Apex persists context
+ * albums using the persistence mechanism in a plugin that implements the {@link Persistor}
+ * interface. By default, context albums use a dummy persistor plugin that does not persist context
+ * albums.
  *
  * @author Liam Fallon (liam.fallon@ericsson.com)
  */
@@ -116,7 +122,7 @@ public interface ContextAlbum extends Map<String, Object> {
      *
      * @return the keys of the artifacts using the context album at the moment
      */
-    AxConcept[]  getUserArtifactStack();
+    AxConcept[] getUserArtifactStack();
 
     /**
      * Set the stack of artifact keys currently using this context item.
index de5cec0..aa800b3 100644 (file)
@@ -43,9 +43,9 @@ public class ContextException extends ApexException {
      * Instantiates a new apex context exception with a message and a caused by exception.
      *
      * @param message the message
-     * @param e the exception that caused this exception to be thrown
+     * @param ex the exception that caused this exception to be thrown
      */
-    public ContextException(final String message, final Exception e) {
-        super(message, e);
+    public ContextException(final String message, final Exception ex) {
+        super(message, ex);
     }
 }
index b2aa017..acfe9e7 100644 (file)
@@ -43,9 +43,9 @@ public class ContextRuntimeException extends ApexRuntimeException {
      * Instantiates a new apex context exception with a message and a caused by exception.
      *
      * @param message the message
-     * @param e the exception that caused this exception to be thrown
+     * @param ex the exception that caused this exception to be thrown
      */
-    public ContextRuntimeException(final String message, final Exception e) {
-        super(message, e);
+    public ContextRuntimeException(final String message, final Exception ex) {
+        super(message, ex);
     }
 }
index 8acc035..6ce924b 100644 (file)
@@ -32,8 +32,8 @@ import org.slf4j.ext.XLogger;
 import org.slf4j.ext.XLoggerFactory;
 
 /**
- * This class implements the {@link SchemaHelper} functionality that is common across all implementations. Schema
- * helpers for specific schema mechanisms specialize this class.
+ * This class implements the {@link SchemaHelper} functionality that is common across all
+ * implementations. Schema helpers for specific schema mechanisms specialize this class.
  *
  * @author Liam Fallon (liam.fallon@ericsson.com)
  */
@@ -62,8 +62,9 @@ public abstract class AbstractSchemaHelper implements SchemaHelper {
     /*
      * (non-Javadoc)
      *
-     * @see org.onap.policy.apex.context.SchemaHelper#init(org.onap.policy.apex.model.basicmodel.concepts.AxKey,
-     * org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema)
+     * @see
+     * org.onap.policy.apex.context.SchemaHelper#init(org.onap.policy.apex.model.basicmodel.concepts
+     * .AxKey, org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema)
      */
     @Override
     public void init(final AxKey incomingUserKey, final AxContextSchema incomingSchema) throws ContextRuntimeException {
index a4bfe69..1bfe77a 100644 (file)
@@ -36,9 +36,9 @@ import org.slf4j.ext.XLogger;
 import org.slf4j.ext.XLoggerFactory;
 
 /**
- * This class implements translation to and from Apex distributed objects and Java objects when a Java schema is used.
- * It creates schema items as Java objects and marshals and unmarshals these objects in various formats. All objects
- * must be of the type of Java class defined in the schema.
+ * This class implements translation to and from Apex distributed objects and Java objects when a
+ * Java schema is used. It creates schema items as Java objects and marshals and unmarshals these
+ * objects in various formats. All objects must be of the type of Java class defined in the schema.
  *
  * @author Liam Fallon (liam.fallon@ericsson.com)
  */
@@ -49,6 +49,7 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
     // This map defines the built in types in types in Java
     // @formatter:off
     private static final Map<String, Class<?>> BUILT_IN_MAP = new HashMap<>();
+
     static {
         BUILT_IN_MAP.put("int",    Integer  .TYPE);
         BUILT_IN_MAP.put("long",   Long     .TYPE);
@@ -65,8 +66,10 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
     /*
      * (non-Javadoc)
      *
-     * @see org.onap.policy.apex.context.impl.schema.AbstractSchemaHelper#init(org.onap.policy.apex.model.basicmodel.
-     * concepts. AxKey, org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema)
+     * @see
+     * org.onap.policy.apex.context.impl.schema.AbstractSchemaHelper#init(org.onap.policy.apex.model
+     * .basicmodel. concepts. AxKey,
+     * org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema)
      */
     @Override
     public void init(final AxKey userKey, final AxContextSchema schema) {
@@ -80,7 +83,7 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
         } catch (final IllegalArgumentException e) {
 
             String resultSting = userKey.getID() + ": class/type " + schema.getSchema() + " for context schema \""
-                            + schema.getID() + "\" not found.";
+                    + schema.getID() + "\" not found.";
             if (JavaSchemaHelper.BUILT_IN_MAP.get(javatype) != null) {
                 resultSting += " Primitive types are not supported. Use the appropriate Java boxing type instead.";
             } else {
@@ -101,7 +104,7 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
         if (incomingObject == null) {
             return null;
         }
-        
+
         if (getSchemaClass() == null) {
             final String returnString =
                     getUserKey().getID() + ": could not create an instance, schema class for the schema is null";
@@ -109,7 +112,7 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
             throw new ContextRuntimeException(returnString);
         }
 
-       if (incomingObject instanceof JsonElement) {
+        if (incomingObject instanceof JsonElement) {
             final String elementJsonString = new Gson().toJson((JsonElement) incomingObject);
             return new Gson().fromJson(elementJsonString, this.getSchemaClass());
         }
@@ -119,9 +122,9 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
         }
 
         final String returnString = getUserKey().getID() + ": the object \"" + incomingObject + "\" of type \""
-                        + incomingObject.getClass().getCanonicalName()
-                        + "\" is not an instance of JsonObject and is not assignable to \""
-                        + getSchemaClass().getCanonicalName() + "\"";
+                + incomingObject.getClass().getCanonicalName()
+                + "\" is not an instance of JsonObject and is not assignable to \""
+                + getSchemaClass().getCanonicalName() + "\"";
         LOGGER.warn(returnString);
         throw new ContextRuntimeException(returnString);
     }
@@ -171,8 +174,8 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
             return new Gson().toJson(schemaObject);
         } else {
             final String returnString = getUserKey().getID() + ": object \"" + schemaObject.toString()
-                            + "\" of class \"" + schemaObject.getClass().getCanonicalName()
-                            + "\" not compatible with class \"" + getSchemaClass().getCanonicalName() + "\"";
+                    + "\" of class \"" + schemaObject.getClass().getCanonicalName() + "\" not compatible with class \""
+                    + getSchemaClass().getCanonicalName() + "\"";
             LOGGER.warn(returnString);
             throw new ContextRuntimeException(returnString);
         }
@@ -192,8 +195,7 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
     /**
      * Do a numeric conversion between numeric types.
      *
-     * @param object
-     *        The incoming numeric object
+     * @param object The incoming numeric object
      * @return The converted object
      */
     private Object numericConversion(final Object object) {
@@ -221,8 +223,7 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
     /**
      * Do a string conversion to the class type.
      *
-     * @param object
-     *        The incoming numeric object
+     * @param object The incoming numeric object
      * @return The converted object
      */
     private Object stringConversion(final Object object) {
@@ -232,8 +233,8 @@ public class JavaSchemaHelper extends AbstractSchemaHelper {
             return stringConstructor.newInstance(object.toString());
         } catch (final Exception e) {
             final String returnString = getUserKey().getID() + ": object \"" + object.toString() + "\" of class \""
-                            + object.getClass().getCanonicalName() + "\" not compatible with class \""
-                            + getSchemaClass().getCanonicalName() + "\"";
+                    + object.getClass().getCanonicalName() + "\" not compatible with class \""
+                    + getSchemaClass().getCanonicalName() + "\"";
             LOGGER.warn(returnString);
             throw new ContextRuntimeException(returnString);
         }
index e50cc60..8bda76d 100644 (file)
@@ -24,21 +24,21 @@ import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
 import org.onap.policy.apex.model.basicmodel.service.ParameterService;
 
 /**
- * Bean class to hold parameters for context handling in Apex. This class contains all the context parameters for schema
- * handling, distribution, locking, and persistence of context albums.
- * <p>
- * The following parameters are defined:
+ * Bean class to hold parameters for context handling in Apex. This class contains all the context
+ * parameters for schema handling, distribution, locking, and persistence of context albums.
+ *
+ * <p>The following parameters are defined:
  * <ol>
- * <li>flushPeriod: Context is flushed to any persistor plugin that is defined periodically, and the period for flushing
- * is the flush period.
- * <li>distributorParameters: The parameters (a {@link distributorParameters} instance) for the distributor plugin that
- * is being used for context album distribution
- * <li>schemaParameters: The parameters (a {@link SchemaParameters} instance) for the schema plugin that is being used
- * for context album schemas
- * <li>lockManagerParameters: The parameters (a {@link LockManagerParameters} instance) for the locking mechanism plugin
- * that is being used for context album locking
- * <li>persistorParameters: The parameters (a {@link PersistorParameters} instance) for the persistence plugin that is
- * being used for context album persistence
+ * <li>flushPeriod: Context is flushed to any persistor plugin that is defined periodically, and the
+ * period for flushing is the flush period.
+ * <li>distributorParameters: The parameters (a {@link distributorParameters} instance) for the
+ * distributor plugin that is being used for context album distribution
+ * <li>schemaParameters: The parameters (a {@link SchemaParameters} instance) for the schema plugin
+ * that is being used for context album schemas
+ * <li>lockManagerParameters: The parameters (a {@link LockManagerParameters} instance) for the
+ * locking mechanism plugin that is being used for context album locking
+ * <li>persistorParameters: The parameters (a {@link PersistorParameters} instance) for the
+ * persistence plugin that is being used for context album persistence
  * </ol>
  *
  * @author Liam Fallon (liam.fallon@ericsson.com)
@@ -53,7 +53,8 @@ public class ContextParameters extends AbstractParameters {
     // @formatter:on
 
     /**
-     * Constructor to create a context parameters instance and register the instance with the parameter service.
+     * Constructor to create a context parameters instance and register the instance with the
+     * parameter service.
      */
     public ContextParameters() {
         super(ContextParameters.class.getCanonicalName());
index c9b0d85..6fd3200 100644 (file)
@@ -24,14 +24,14 @@ import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
 import org.onap.policy.apex.model.basicmodel.service.ParameterService;
 
 /**
- * A persistor parameter class that may be specialized by context persistor plugins that require plugin specific
- * parameters.
- * <p>
- * The following parameters are defined:
+ * A persistor parameter class that may be specialized by context persistor plugins that require
+ * plugin specific parameters.
+ *
+ * <p>The following parameters are defined:
  * <ol>
  * <li>pluginClass: the persistor plugin as the JVM local dummy ephemeral persistor
- * <li>flushPeriod: Context is flushed to any persistor plugin that is defined periodically, and the period for flushing
- * is the flush period.
+ * <li>flushPeriod: Context is flushed to any persistor plugin that is defined periodically, and the
+ * period for flushing is the flush period.
  * </ol>
  *
  * @author Liam Fallon (liam.fallon@ericsson.com)
@@ -51,7 +51,8 @@ public class PersistorParameters extends AbstractParameters {
     private long flushPeriod = DEFAULT_FLUSH_PERIOD;
 
     /**
-     * Constructor to create a persistor parameters instance and register the instance with the parameter service.
+     * Constructor to create a persistor parameters instance and register the instance with the
+     * parameter service.
      */
     public PersistorParameters() {
         super(PersistorParameters.class.getCanonicalName());
@@ -59,8 +60,8 @@ public class PersistorParameters extends AbstractParameters {
     }
 
     /**
-     * Constructor to create a persistor parameters instance with the name of a sub class of this class and register the
-     * instance with the parameter service.
+     * Constructor to create a persistor parameters instance with the name of a sub class of this
+     * class and register the instance with the parameter service.
      *
      * @param parameterClassName the class name of a sub class of this class
      */
index 858a6a3..12e203c 100644 (file)
@@ -28,12 +28,13 @@ import org.onap.policy.apex.model.basicmodel.service.AbstractParameters;
 import org.onap.policy.apex.model.basicmodel.service.ParameterService;
 
 /**
- * Bean class holding schema parameters for schemas and their helpers. As more than one schema can be used in Apex
- * simultaneously, this class is used to hold the schemas that are defined in a given Apex system and to get the schema
- * helper plugin parameters {@link SchemaHelperParameters} for each schema.
- * <p>
- * The default {@code Java} schema is always defined and its parameters are held in a {@link JavaSchemaHelperParameters}
- * instance.
+ * Bean class holding schema parameters for schemas and their helpers. As more than one schema can
+ * be used in Apex simultaneously, this class is used to hold the schemas that are defined in a
+ * given Apex system and to get the schema helper plugin parameters {@link SchemaHelperParameters}
+ * for each schema.
+ *
+ * <p>The default {@code Java} schema is always defined and its parameters are held in a
+ * {@link JavaSchemaHelperParameters} instance.
  *
  * @author Liam Fallon (liam.fallon@ericsson.com)
  */
@@ -45,7 +46,8 @@ public class SchemaParameters extends AbstractParameters {
     private Map<String, SchemaHelperParameters> schemaHelperParameterMap;
 
     /**
-     * Constructor to create a distributor parameters instance and register the instance with the parameter service.
+     * Constructor to create a distributor parameters instance and register the instance with the
+     * parameter service.
      */
     public SchemaParameters() {
         super(SchemaParameters.class.getCanonicalName());
index 15560f7..07960ba 100644 (file)
@@ -17,6 +17,7 @@
  * SPDX-License-Identifier: Apache-2.0
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.apex.context;
 
 import static org.junit.Assert.assertEquals;
@@ -30,12 +31,15 @@ public class ContextExceptionTest {
     @Test
     public void testContextException() {
         assertEquals("context exception message", new ContextException("context exception message").getMessage());
-        assertEquals("context exception message", new ContextException("context exception message", new IOException()).getMessage());
+        assertEquals("context exception message",
+                new ContextException("context exception message", new IOException()).getMessage());
     }
 
     @Test
     public void testContextRuntimeException() {
-        assertEquals("context exception message", new ContextRuntimeException("context exception message").getMessage());
-        assertEquals("context exception message", new ContextRuntimeException("context exception message", new IOException()).getMessage());
+        assertEquals("context exception message",
+                new ContextRuntimeException("context exception message").getMessage());
+        assertEquals("context exception message",
+                new ContextRuntimeException("context exception message", new IOException()).getMessage());
     }
 }
index e5cc61f..bed6785 100644 (file)
@@ -93,8 +93,8 @@ public class ContextAlbumImplTest {
             new ContextAlbumImpl(new AxContextAlbum(), new JVMLocalDistributor(), new LinkedHashMap<String, Object>());
             fail("this test should throw an exception");
         } catch (ApexRuntimeException e) {
-            assertEquals("Model for org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas not found in model service",
-                            e.getMessage());
+            assertEquals("Model for org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas "
+                    + "not found in model service", e.getMessage());
         } catch (ContextException e) {
             fail("this test should throw an ApexRuntimeException");
         }
@@ -112,7 +112,7 @@ public class ContextAlbumImplTest {
                         true, AxArtifactKey.getNullKey());
 
         AxContextAlbum axContextAlbumRO = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy",
-                        false, simpleStringSchema.getKey());
+                false, simpleStringSchema.getKey());
 
         try {
             new ContextAlbumImpl(axContextAlbum, new JVMLocalDistributor(), new LinkedHashMap<String, Object>());
@@ -195,8 +195,9 @@ public class ContextAlbumImplTest {
             albumRO.remove("AllKey0");
             fail("test should throw an exception");
         } catch (ContextRuntimeException e) {
-            assertEquals("album \"TestContextAlbum:0.0.1\" remove() not allowed on read only albums for key=\"AllKey0\"",
-                            e.getMessage());
+            assertEquals(
+                    "album \"TestContextAlbum:0.0.1\" remove() not allowed on read only albums for key=\"AllKey0\"",
+                    e.getMessage());
         }
 
         try {
index 17e5dee..ea29bd8 100644 (file)
@@ -35,6 +35,7 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
 import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
 
 /**
+ * JavaSchemaHelperInstanceCreationTest.
  * @author Liam Fallon (liam.fallon@ericsson.com)
  * @version
  */
@@ -73,9 +74,8 @@ public class JavaSchemaHelperInstanceCreationTest {
             schemaHelper0.createNewInstance();
             fail("this test should throw an exception here");
         } catch (final Exception e) {
-            assertEquals(
-                    "AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\" using the default constructor \"Boolean()\"",
-                    e.getMessage());
+            assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\" using the default"
+                    + " constructor \"Boolean()\"", e.getMessage());
         }
         assertEquals(true, schemaHelper0.createNewInstance("true"));
 
@@ -84,9 +84,8 @@ public class JavaSchemaHelperInstanceCreationTest {
             schemaHelper1.createNewInstance();
             fail("this test should throw an exception here");
         } catch (final Exception e) {
-            assertEquals(
-                    "AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\" using the default constructor \"Long()\"",
-                    e.getMessage());
+            assertEquals("AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\" using the default "
+                    + "constructor \"Long()\"", e.getMessage());
         }
         assertEquals(65536L, schemaHelper1.createNewInstance("65536"));
 
index a27c64f..6dd6e25 100644 (file)
  * SPDX-License-Identifier: Apache-2.0
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.apex.context.impl.schema.java;
 
 public class MyBaseClass {
     final String stringField;
-    
+
     public MyBaseClass(final String stringField) {
         this.stringField = stringField;
     }
-    
+
     public String getStringField() {
         return stringField;
     }
index 2f837a3..f68bcf4 100644 (file)
@@ -17,6 +17,7 @@
  * SPDX-License-Identifier: Apache-2.0
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.policy.apex.context.impl.schema.java;
 
 public class MySubClass extends MyBaseClass  {