Fix checkstyle issues 22/74422/2
authorliamfallon <liam.fallon@est.tech>
Fri, 7 Dec 2018 22:28:49 +0000 (22:28 +0000)
committerliamfallon <liam.fallon@est.tech>
Sat, 8 Dec 2018 11:45:20 +0000 (11:45 +0000)
Some minor line length and formatting checkstyle warnings fixed.

Change-Id: Ib92069bbdb444560083e6d0dbf5d16a3ab824d82
Issue-ID: POLICY-1074
Signed-off-by: liamfallon <liam.fallon@est.tech>
context/context-test-utils/src/main/java/org/onap/policy/apex/context/test/distribution/ContextUpdate.java
core/core-deployment/src/main/java/org/onap/policy/apex/core/deployment/BatchDeployer.java
core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DeploymentClientTest.java
examples/examples-adaptive/src/main/java/org/onap/policy/apex/examples/adaptive/model/java/AutoLearnPolicyDecideTaskSelectionLogic.java
plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaExecutorParametersTest.java
plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutorTest.java
plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutorTest.java
plugins/plugins-executor/plugins-executor-java/src/test/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutorTest.java
testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchTest.java
testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorTest.java

index b897b83..e92d6a9 100644 (file)
@@ -96,8 +96,8 @@ public class ContextUpdate {
             fail(EXCEPTION_MESSAGE);
         } catch (final ContextRuntimeException e) {
             assertEquals("Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\":"
-                    + " LongContextAlbum:0.0.1: object \"zero\" of class \"java.lang.String\" not compatible with"
-                    + " class \"java.lang.Long\"", e.getMessage());
+                + " LongContextAlbum:0.0.1: object \"zero\" of class \"java.lang.String\" not compatible with"
+                + " class \"java.lang.Long\"", e.getMessage());
             LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
@@ -106,9 +106,9 @@ public class ContextUpdate {
             fail(EXCEPTION_MESSAGE);
         } catch (final ContextRuntimeException e) {
             assertEquals(
-                    "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum"
-                            + ":0.0.1: object \"\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\"",
-                    e.getMessage());
+                "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum"
+                    + ":0.0.1: object \"\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\"",
+                e.getMessage());
             LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
@@ -117,7 +117,7 @@ public class ContextUpdate {
             fail(EXCEPTION_MESSAGE);
         } catch (final ContextRuntimeException e) {
             assertEquals("album \"LongContextAlbum:0.0.1\" null values are illegal on key \"0\" for put()",
-                    e.getMessage());
+                e.getMessage());
             LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
         }
 
@@ -132,7 +132,6 @@ public class ContextUpdate {
         assertNull(dateContextAlbum.put("date0", tciA));
         assertTrue(dateContextAlbum.put("date0", tciA).equals(tciA));
 
-
         assertNull(mapContextAlbum.put("map0", tciC));
         assertTrue(mapContextAlbum.put("map0", tciC).equals(tciC));
 
@@ -161,9 +160,9 @@ public class ContextUpdate {
     }
 
     private ContextAlbum getContextAlbum(final String albumKey, final Distributor contextDistributor)
-            throws ContextException {
-        final ContextAlbum longContextAlbum =
-                contextDistributor.createContextAlbum(new AxArtifactKey(albumKey, VERSION));
+        throws ContextException {
+        final ContextAlbum longContextAlbum = contextDistributor
+            .createContextAlbum(new AxArtifactKey(albumKey, VERSION));
         assertNotNull(longContextAlbum);
         longContextAlbum.setUserArtifactStack(getAxArtifactKeyArray());
         return longContextAlbum;
@@ -173,7 +172,6 @@ public class ContextUpdate {
         final AxArtifactKey distributorKey = new AxArtifactKey(APEX_DISTRIBUTOR, VERSION);
         final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
 
-
         final AxContextModel multiModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
         contextDistributor.registerModel(multiModel);
         return contextDistributor;
index df845f5..90b1519 100644 (file)
@@ -32,9 +32,8 @@ import org.slf4j.ext.XLoggerFactory;
  * The Class {@link BatchDeployer} deploys an Apex model held as an XML or Json file onto an Apex engine. It uses the
  * EngDep protocol to communicate with the engine, with the EngDep protocol being carried on Java web sockets.
  *
- * <p>
- * This deployer is a simple command line deployer that reads the communication parameters and the location of the Apex
- * model file as arguments.
+ * <p>This deployer is a simple command line deployer that reads the communication parameters and the location of the
+ * Apex model file as arguments.
  *
  * @author Liam Fallon (liam.fallon@ericsson.com)
  */
@@ -97,7 +96,7 @@ public class BatchDeployer {
      * @throws ApexException on Apex errors
      */
     public void deployModel(final String modelFileName, final boolean ignoreConflicts, final boolean force)
-            throws ApexException {
+        throws ApexException {
         engineServiceFacade.deployModel(modelFileName, ignoreConflicts, force);
     }
 
@@ -110,7 +109,7 @@ public class BatchDeployer {
      * @throws ApexException on Apex errors
      */
     public void deployModel(final AxPolicyModel policyModel, final boolean ignoreConflicts, final boolean force)
-            throws ApexException {
+        throws ApexException {
         engineServiceFacade.deployModel(policyModel, ignoreConflicts, force);
     }
 
@@ -133,7 +132,7 @@ public class BatchDeployer {
     public static void main(final String[] args) throws ApexException {
         if (args.length != NUM_ARGUMENTS) {
             final String message = "invalid arguments: " + Arrays.toString(args)
-                    + "\nusage: BatchDeployer <server address> <port address> <model file path";
+                + "\nusage: BatchDeployer <server address> <port address> <model file path";
             LOGGER.error(message);
             throw new ApexDeploymentException(message);
         }
index b12e526..d5b34a0 100644 (file)
@@ -65,7 +65,7 @@ public class DeploymentClientTest {
     @SuppressWarnings("unchecked")
     @Test
     public void testDeploymentClientStart() throws Exception {
-        DeploymentClient deploymentClient = new DeploymentClient("localhost", 51273);
+        DeploymentClient deploymentClient = new DeploymentClient("localhost", 51332);
 
         final Field factoryField = deploymentClient.getClass().getDeclaredField("factory");
         factoryField.setAccessible(true);
@@ -81,7 +81,7 @@ public class DeploymentClientTest {
         Thread clientThread = new Thread(deploymentClient);
         clientThread.start();
 
-        ThreadUtilities.sleep(20);
+        ThreadUtilities.sleep(100);
 
         assertTrue(deploymentClient.isStarted());
         assertTrue(clientThread.isAlive());
@@ -114,26 +114,28 @@ public class DeploymentClientTest {
 
     @Test
     public void testDeploymentClientStartException() throws Exception {
-        DeploymentClient depoymentClient = new DeploymentClient("localhost", 51273);
+        DeploymentClient deploymentClient = new DeploymentClient("localhost", 51273);
 
-        final Field factoryField = depoymentClient.getClass().getDeclaredField("factory");
+        final Field factoryField = deploymentClient.getClass().getDeclaredField("factory");
         factoryField.setAccessible(true);
-        factoryField.set(depoymentClient, mockServiceFactory);
+        factoryField.set(deploymentClient, mockServiceFactory);
 
         Mockito.doReturn(mockService).when(mockServiceFactory).createClient(anyObject());
 
         Mockito.doNothing().when(mockService).addMessageListener(anyObject());
         Mockito.doThrow(new ApexRuntimeException("connection start failed")).when(mockService).startConnection();
 
-        Thread clientThread = new Thread(depoymentClient);
+        Thread clientThread = new Thread(deploymentClient);
         clientThread.start();
 
         ThreadUtilities.sleep(50);
 
-        assertFalse(depoymentClient.isStarted());
+        assertFalse(deploymentClient.isStarted());
         assertFalse(clientThread.isAlive());
-        assertEquals(0, depoymentClient.getReceiveQueue().size());
+        assertEquals(0, deploymentClient.getReceiveQueue().size());
 
         ThreadUtilities.sleep(100);
+        
+        deploymentClient.stopClient();
     }
 }
index 32387d0..ef697b0 100644 (file)
@@ -49,10 +49,10 @@ public class AutoLearnPolicyDecideTaskSelectionLogic {
     public boolean getTask(final TaskSelectionExecutionContext executor) {
         String idString = executor.subject.getId();
         executor.logger.debug(idString);
-        
+
         String inFieldsString = executor.inFields.toString();
         executor.logger.debug(inFieldsString);
-        
+
         final List<String> tasks = executor.subject.getTaskNames();
         size = tasks.size();
 
@@ -144,22 +144,22 @@ public class AutoLearnPolicyDecideTaskSelectionLogic {
         autoLearn.setAvDiffs(Arrays.asList(avdiffs));
         autoLearn.setCounts(Arrays.asList(counts));
     }
-    
 
     /**
-     * Calculate the return value of the learning
+     * Calculate the return value of the learning.
+     * 
      * @param diff the difference
-     * @param r the random value
+     * @param random the random value
      * @param closestupi closest to i upwards
      * @param closestdowni closest to i downwards
      * @param closestup closest up value
      * @param closestdown closest down value
      * @return the return value
      */
-    private int calculateReturnValue(final double diff, final int r, int closestupi, int closestdowni, double closestup,
-                    double closestdown) {
+    private int calculateReturnValue(final double diff, final int random, int closestupi, int closestdowni,
+        double closestup, double closestdown) {
         if (closestupi == -1 || closestdowni == -1) {
-            return r;
+            return random;
         }
         if (closestupi == closestdowni) {
             return closestupi;
index c852254..6638e71 100644 (file)
@@ -51,6 +51,9 @@ import org.onap.policy.common.parameters.ParameterService;
  *
  */
 public class JavaStateFinalizerExecutorTest {
+    /**
+     * Initiate Parameters.
+     */
     @Before
     public void initiateParameters() {
         ParameterService.register(new DistributorParameters());
@@ -59,6 +62,9 @@ public class JavaStateFinalizerExecutorTest {
         ParameterService.register(new EngineParameters());
     }
 
+    /**
+     * Clear down Parameters.
+     */
     @After
     public void clearParameters() {
         ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
@@ -90,9 +96,11 @@ public class JavaStateFinalizerExecutorTest {
         try {
             parentStateExcutor = new StateExecutor(new ExecutorFactoryImpl());
         } catch (StateMachineException e) {
+            fail("test should not throw an exception here");
         }
+
         AxState state = new AxState();
-        parentStateExcutor.setContext(null, state , internalContext);
+        parentStateExcutor.setContext(null, state, internalContext);
         AxStateFinalizerLogic stateFinalizerLogic = new AxStateFinalizerLogic();
         jsfe.setContext(parentStateExcutor, stateFinalizerLogic, internalContext);
 
@@ -116,7 +124,7 @@ public class JavaStateFinalizerExecutorTest {
             fail("test should throw an exception here");
         } catch (Exception jtseException) {
             assertEquals("state finalizer logic failed to run for state finalizer  \"NULL:0.0.0:NULL:NULL\"",
-                            jtseException.getMessage());
+                jtseException.getMessage());
         }
 
         AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
@@ -126,7 +134,7 @@ public class JavaStateFinalizerExecutorTest {
             fail("test should throw an exception here");
         } catch (Exception jtseException) {
             assertEquals("state finalizer logic failed to run for state finalizer  \"NULL:0.0.0:NULL:NULL\"",
-                            jtseException.getMessage());
+                jtseException.getMessage());
         }
 
         stateFinalizerLogic.setLogic("org.onap.policy.apex.plugins.executor.java.DummyJavaStateFinalizerLogic");
@@ -136,7 +144,7 @@ public class JavaStateFinalizerExecutorTest {
             fail("test should throw an exception here");
         } catch (Exception jtseException) {
             assertEquals("execute-post: state finalizer logic execution failure on state \"NULL:0.0.0:NULL:NULL\" "
-                            + "on finalizer logic NULL:0.0.0:NULL:NULL", jtseException.getMessage());
+                + "on finalizer logic NULL:0.0.0:NULL:NULL", jtseException.getMessage());
         }
 
         state.getStateOutputs().put("SelectedOutputIsMe", null);
index 74d0c82..f3ea1ce 100644 (file)
@@ -45,6 +45,9 @@ import org.onap.policy.common.parameters.ParameterService;
  *
  */
 public class JavaTaskExecutorTest {
+    /**
+     * Initiate Parameters.
+     */
     @Before
     public void initiateParameters() {
         ParameterService.register(new DistributorParameters());
@@ -52,6 +55,9 @@ public class JavaTaskExecutorTest {
         ParameterService.register(new PersistorParameters());
     }
 
+    /**
+     * Clear Parameters.
+     */
     @After
     public void clearParameters() {
         ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
index dbb250f..64dfaea 100644 (file)
@@ -45,6 +45,9 @@ import org.onap.policy.common.parameters.ParameterService;
  *
  */
 public class JavaTaskSelectExecutorTest {
+    /**
+     * Initiate Parameters.
+     */
     @Before
     public void initiateParameters() {
         ParameterService.register(new DistributorParameters());
@@ -52,6 +55,9 @@ public class JavaTaskSelectExecutorTest {
         ParameterService.register(new PersistorParameters());
     }
 
+    /**
+     * Clear Parameters.
+     */
     @After
     public void clearParameters() {
         ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
index f315f64..821cb68 100644 (file)
@@ -37,12 +37,13 @@ public class EventBatchTest {
         EventBatch batch = new EventBatch(1, "TheApexClient");
         assertNotNull(batch);
 
-        assertEquals("\"nameSpace\": \"org.onap.policy.apex.sample.events\"", batch.getBatchAsJsonString().substring(4, 53));
+        assertEquals("\"nameSpace\": \"org.onap.policy.apex.sample.events\"",
+            batch.getBatchAsJsonString().substring(4, 53));
 
         EventBatchStats stats = batch.getStats();
         assertEquals(1, stats.getBatchSize());
 
         InputEvent ie = batch.getInputEvent(0);
-        assertEquals("org.onap.policy.apex.sample.events",ie.getNameSpace());
+        assertEquals("org.onap.policy.apex.sample.events", ie.getNameSpace());
     }
 }
index e37ea96..3d37b3f 100644 (file)
@@ -55,8 +55,8 @@ public class EventGeneratorTest {
 
         EventGenerator eventGenerator = new EventGenerator(pars);
 
-        final String[] args =
-            { "-rfr", "target", "-c", "target/examples/config/SampleDomain/REST2RESTJsonEventJavascript.json" };
+        final String[] args = { "-rfr", "target", "-c",
+            "target/examples/config/SampleDomain/REST2RESTJsonEventJavascript.json" };
 
         final ApexMain apexMain = new ApexMain(args);
 
@@ -76,8 +76,7 @@ public class EventGeneratorTest {
     public void testEventGeneratorBadParams() {
         System.setOut(new PrintStream(outContent));
 
-        final String[] args =
-            { "-zzz" };
+        final String[] args = { "-zzz" };
 
         EventGenerator.main(args);
 
@@ -92,9 +91,7 @@ public class EventGeneratorTest {
     public void testEventGeneratorHelp() {
         System.setOut(new PrintStream(outContent));
 
-        final String[] args = {
-            "-h"
-        };
+        final String[] args = { "-h" };
 
         EventGenerator.main(args);
 
@@ -114,7 +111,7 @@ public class EventGeneratorTest {
             public void run() {
                 EventGenerator.main(null);
             }
-           }).start();
+        }).start();
 
         ThreadUtilities.sleep(1000);
         final String outString = outContent.toString();
@@ -127,7 +124,7 @@ public class EventGeneratorTest {
 
     @Test
     public void testEventGeneratorOutfileGood() {
-        EventGeneratorParameters pars =new EventGeneratorParameters();
+        EventGeneratorParameters pars = new EventGeneratorParameters();
         pars.setOutFile("target/statsOutFile.json");
 
         EventGenerator generator = new EventGenerator(pars);