Fix minor checkstyle/eclipse warnings 61/103561/1
authorliamfallon <liam.fallon@est.tech>
Wed, 11 Mar 2020 21:29:17 +0000 (21:29 +0000)
committerliamfallon <liam.fallon@est.tech>
Wed, 11 Mar 2020 21:29:21 +0000 (21:29 +0000)
Some minor checkstyle and eclipse warnings have crept into the code in
the last few weeks. This review cleams them up.

Issue-ID: POLICY-1913
Change-Id: Ib5f103bc28c71a6c4db05ea05719eff41bb38914
Signed-off-by: liamfallon <liam.fallon@est.tech>
16 files changed:
client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestMainTest.java
client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestMainTest.java
client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java
core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DummyDeploymentClient.java
core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java
core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/threading/ThreadingTestThread.java
examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestApexActionListener.java
examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestApexActionListener.java
model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java
plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java
services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPluginsEventProducer.java
services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java
testsuites/integration/integration-uservice-test/pom.xml

index 245900d..91b5480 100644 (file)
@@ -48,86 +48,78 @@ public class DeploymentRestMainTest {
 
     @Test
     public void testDeploymentClientNoOptions() {
-        final String[] eventArgs = new String[]
-            {};
+        final String[] eventArgs = new String[] {};
         assertThat(testApexDeploymentRestMainConstructor(eventArgs)).isEqualTo("*** StdOut ***\n\n*** StdErr ***\n");
     }
 
     @Test
     public void testDeploymentClientBadOptions() {
-        final String[] eventArgs =
-            { "-zabbu" };
+        final String[] eventArgs = {"-zabbu"};
         Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
 
-        assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
-                "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
-                        + "parameter error, invalid command line arguments specified "
-                        + ": Unrecognized option: -zabbu");
+        assertThat(thrown).isInstanceOf(Exception.class)
+            .hasMessageContaining("Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
+                + "parameter error, invalid command line arguments specified " + ": Unrecognized option: -zabbu");
     }
 
     @Test
     public void testDeploymentClientHelp() {
-        final String[] eventArgs =
-            { "-h" };
+        final String[] eventArgs = {"-h"};
 
         Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
 
         assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
-                "usage: org.onap.policy.apex.client.deployment.rest.ApexDeploymentRestMain [options...]");
+            "usage: org.onap.policy.apex.client.deployment.rest.ApexDeploymentRestMain [options...]");
 
     }
 
     @Test
     public void testDeploymentClientPortBad() {
-        final String[] eventArgs =
-            { "-p", "hello" };
+        final String[] eventArgs = {"-p", "hello"};
 
         Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
 
-        assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
-                "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
-                        + "parameter error, error parsing argument \"port\" :For input string: \"hello\"");
+        assertThat(thrown).isInstanceOf(Exception.class)
+            .hasMessageContaining("Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
+                + "parameter error, error parsing argument \"port\" :For input string: \"hello\"");
 
     }
 
     @Test
     public void testDeploymentClientPortNegative() {
-        final String[] eventArgs =
-            { "-p", "-1" };
+        final String[] eventArgs = {"-p", "-1"};
 
         Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
 
         assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
-                "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[ApexDeploymentRestParameters: "
-                        + "URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
-                        + "port must be greater than 1023 and less than 65536");
+            "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[ApexDeploymentRestParameters: "
+                + "URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
+                + "port must be greater than 1023 and less than 65536");
 
     }
 
     @Test
     public void testDeploymentClientTtlTooSmall() {
-        final String[] eventArgs =
-            { "-t", "-2" };
+        final String[] eventArgs = {"-t", "-2"};
 
         Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
 
         assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
-                "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[ApexDeploymentRestParameters: "
-                        + "URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
-                        + "time to live must be greater than -1 (set to -1 to wait forever)");
+            "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[ApexDeploymentRestParameters: "
+                + "URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
+                + "time to live must be greater than -1 (set to -1 to wait forever)");
 
     }
 
     @Test
     public void testDeploymentClientTooManyPars() {
-        final String[] eventArgs =
-            { "-t", "10", "-p", "12344", "aaa", "bbb" };
+        final String[] eventArgs = {"-t", "10", "-p", "12344", "aaa", "bbb"};
 
         Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
 
-        assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
-                "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
-                        + "parameter error, too many command line arguments specified : [aaa, bbb]");
+        assertThat(thrown).isInstanceOf(Exception.class)
+            .hasMessageContaining("Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
+                + "parameter error, too many command line arguments specified : [aaa, bbb]");
     }
 
     @Test
@@ -141,35 +133,31 @@ public class DeploymentRestMainTest {
 
     @Test
     public void testDeploymentClientTtlNotNumber() {
-        final String[] eventArgs =
-            { "-t", "timetolive" };
+        final String[] eventArgs = {"-t", "timetolive"};
 
         Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
 
-        assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
-                "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
-                        + "parameter error, error parsing argument \"time-to-live\" :"
-                        + "For input string: \"timetolive\"");
+        assertThat(thrown).isInstanceOf(Exception.class)
+            .hasMessageContaining("Apex Services REST endpoint (ApexDeploymentRestMain: Config=[null], State=STOPPED) "
+                + "parameter error, error parsing argument \"time-to-live\" :" + "For input string: \"timetolive\"");
 
     }
 
     @Test
     public void testDeploymentClientPortTooBig() {
-        final String[] eventArgs =
-            { "-p", "65536" };
+        final String[] eventArgs = {"-p", "65536"};
 
         Throwable thrown = catchThrowable(() -> new ApexDeploymentRestMain(eventArgs, System.out));
 
         assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
-                "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[ApexDeploymentRestParameters: "
-                        + "URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
-                        + "port must be greater than 1023 and less than 65536");
+            "Apex Services REST endpoint (ApexDeploymentRestMain: Config=[ApexDeploymentRestParameters: "
+                + "URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
+                + "port must be greater than 1023 and less than 65536");
     }
 
     @Test
     public void testDeploymentOneSecStart() {
-        final String[] eventArgs =
-            { "-t", "1" };
+        final String[] eventArgs = {"-t", "1"};
 
         assertThatCode(() -> {
             ApexDeploymentRestMain monRestMain = new ApexDeploymentRestMain(eventArgs, System.out);
@@ -181,8 +169,7 @@ public class DeploymentRestMainTest {
 
     @Test
     public void testDeploymentForeverStart() {
-        final String[] eventArgs =
-            { "-t", "-1" };
+        final String[] eventArgs = {"-t", "-1"};
 
         ApexDeploymentRestMain monRestMain = new ApexDeploymentRestMain(eventArgs, System.out);
 
@@ -195,8 +182,8 @@ public class DeploymentRestMainTest {
 
         assertThatCode(() -> {
             monThread.start();
-            await().atMost(2, TimeUnit.SECONDS).until(
-                    () -> monRestMain.getState().equals(ApexDeploymentRestMain.ServicesState.RUNNING));
+            await().atMost(2, TimeUnit.SECONDS)
+                .until(() -> monRestMain.getState().equals(ApexDeploymentRestMain.ServicesState.RUNNING));
             monRestMain.shutdown();
         }).doesNotThrowAnyException();
     }
index 3e21ee5..5b01e04 100644 (file)
@@ -48,98 +48,86 @@ public class ServicesRestMainTest {
 
     @Test
     public void testServicesClientNoOptions() {
-        final String[] eventArgs = new String[]
-            {};
+        final String[] eventArgs = new String[] {};
 
         assertThat(testApexServicesRestMainConstructor(eventArgs)).isEqualTo("*** StdOut ***\n\n*** StdErr ***\n");
 
-
     }
 
     @Test
     public void testServicesClientBadOptions() {
-        final String[] eventArgs =
-            { "-zabbu" };
+        final String[] eventArgs = {"-zabbu"};
         Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
 
-        assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
-                "Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
-                        + "parameter error, invalid command line arguments specified "
-                        + ": Unrecognized option: -zabbu");
+        assertThat(thrown).isInstanceOf(Exception.class)
+            .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
+                + "parameter error, invalid command line arguments specified " + ": Unrecognized option: -zabbu");
     }
 
     @Test
     public void testServicesClientHelp() {
-        final String[] eventArgs =
-            { "-h" };
+        final String[] eventArgs = {"-h"};
         Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
 
         assertThat(thrown).isInstanceOf(Exception.class)
-                .hasMessageContaining("usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]");
+            .hasMessageContaining("usage: org.onap.policy.apex.client.full.rest.ApexServicesRestMain [options...]");
     }
 
     @Test
     public void testServicesClientPortBad() {
-        final String[] eventArgs =
-            { "-p", "hello" };
+        final String[] eventArgs = {"-p", "hello"};
 
         Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
 
         assertThat(thrown).isInstanceOf(Exception.class)
-                .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
-                        + "parameter error, error parsing argument \"port\" :For input string: \"hello\"");
+            .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
+                + "parameter error, error parsing argument \"port\" :For input string: \"hello\"");
 
     }
 
     @Test
     public void testServicesClientPortNegative() {
-        final String[] eventArgs =
-            { "-p", "-1" };
+        final String[] eventArgs = {"-p", "-1"};
 
         Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
 
         assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
-                "Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: "
-                        + "URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
-                        + "port must be greater than 1023 and less than 65536");
+            "Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: "
+                + "URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
+                + "port must be greater than 1023 and less than 65536");
 
     }
 
     @Test
     public void testServicesClientTtlTooSmall() {
-        final String[] eventArgs =
-            { "-t", "-2" };
+        final String[] eventArgs = {"-t", "-2"};
 
         Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
 
         assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
-                "Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: "
-                        + "URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
-                        + "time to live must be greater than -1 (set to -1 to wait forever)");
+            "Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: "
+                + "URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
+                + "time to live must be greater than -1 (set to -1 to wait forever)");
     }
 
     @Test
     public void testServicesClientTooManyPars() {
-        final String[] eventArgs =
-            { "-t", "10", "-p", "12344", "aaa", "bbb" };
+        final String[] eventArgs = {"-t", "10", "-p", "12344", "aaa", "bbb"};
         Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
 
         assertThat(thrown).isInstanceOf(Exception.class)
-                .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
-                        + "parameter error, too many command line arguments specified : [aaa, bbb]");
+            .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
+                + "parameter error, too many command line arguments specified : [aaa, bbb]");
     }
 
-
     @Test
     public void testServicesClientTtlNotNumber() {
-        final String[] eventArgs =
-            { "-t", "timetolive" };
+        final String[] eventArgs = {"-t", "timetolive"};
         Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
 
         assertThat(thrown).isInstanceOf(Exception.class)
-                .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
-                        + "parameter error, error parsing argument \"time-to-live\" :"
-                        + "For input string: \"timetolive\"");
+            .hasMessageContaining("Apex Editor REST endpoint (ApexServicesRestMain: Config=[null], State=STOPPED) "
+                + "parameter error, error parsing argument \"time-to-live\" :" + "For input string: \"timetolive\"");
     }
 
     @Test
@@ -155,14 +143,13 @@ public class ServicesRestMainTest {
 
     @Test
     public void testServicesClientPortTooBig() {
-        final String[] eventArgs =
-            { "-p", "65536" };
+        final String[] eventArgs = {"-p", "65536"};
         Throwable thrown = catchThrowable(() -> new ApexServicesRestMain(eventArgs, System.out));
 
         assertThat(thrown).isInstanceOf(Exception.class).hasMessageContaining(
-                "Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: "
-                        + "URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
-                        + "port must be greater than 1023 and less than 65536");
+            "Apex Editor REST endpoint (ApexServicesRestMain: Config=[ApexServicesRestParameters: "
+                + "URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
+                + "port must be greater than 1023 and less than 65536");
     }
 
     @Test
@@ -191,8 +178,8 @@ public class ServicesRestMainTest {
 
         assertThatCode(() -> {
             monThread.start();
-            await().atMost(6, TimeUnit.SECONDS).until(
-                    () -> monRestMain.getState().equals(ApexServicesRestMain.EditorState.RUNNING));
+            await().atMost(6, TimeUnit.SECONDS)
+                .until(() -> monRestMain.getState().equals(ApexServicesRestMain.EditorState.RUNNING));
             monRestMain.shutdown();
         }).doesNotThrowAnyException();
     }
index 71ca21d..f27a53a 100644 (file)
@@ -6,15 +6,15 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- * 
+ *
  * SPDX-License-Identifier: Apache-2.0
  * ============LICENSE_END=========================================================
  */
@@ -40,8 +40,7 @@ public class MonitoringRestMainTest {
     @Test
     public void testMonitoringClientBad() {
         try {
-            final String[] eventArgs =
-                { "-z" };
+            final String[] eventArgs = {"-z"};
 
             ApexMonitoringRestMain.main(eventArgs);
         } catch (Exception exc) {
@@ -52,8 +51,7 @@ public class MonitoringRestMainTest {
     @Test
     public void testMonitoringClientOk() {
         try {
-            final String[] eventArgs =
-                { "-t", "1" };
+            final String[] eventArgs = {"-t", "1"};
 
             ApexMonitoringRestMain.main(eventArgs);
         } catch (Exception exc) {
@@ -63,8 +61,7 @@ public class MonitoringRestMainTest {
 
     @Test
     public void testMonitoringClientNoOptions() {
-        final String[] eventArgs = new String[]
-            {};
+        final String[] eventArgs = new String[] {};
 
         final String outputString = testApexMonitoringRestMainConstructor(eventArgs);
 
@@ -74,121 +71,118 @@ public class MonitoringRestMainTest {
 
     @Test
     public void testMonitoringClientBadOptions() {
-        final String[] eventArgs =
-            { "-zabbu" };
+        final String[] eventArgs = {"-zabbu"};
 
         try {
             new ApexMonitoringRestMain(eventArgs, System.out);
             fail("test should throw an exception");
         } catch (Exception ex) {
-            assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
-                            + "parameter error, invalid command line arguments specified "
-                            + ": Unrecognized option: -zabbu", ex.getMessage().substring(0, 170));
+            assertEquals(
+                "Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
+                    + "parameter error, invalid command line arguments specified " + ": Unrecognized option: -zabbu",
+                ex.getMessage().substring(0, 170));
         }
     }
 
     @Test
     public void testMonitoringClientHelp() {
-        final String[] eventArgs =
-            { "-h" };
+        final String[] eventArgs = {"-h"};
 
         try {
             new ApexMonitoringRestMain(eventArgs, System.out);
             fail("test should throw an exception");
         } catch (Exception ex) {
             assertEquals("usage: org.onap.policy.apex.client.monitoring.rest.ApexMonitoringRestMain [options...]",
-                            ex.getMessage().substring(0, 86));
+                ex.getMessage().substring(0, 86));
         }
     }
 
     @Test
     public void testMonitoringClientPortBad() {
-        final String[] eventArgs =
-            { "-p", "hello" };
+        final String[] eventArgs = {"-p", "hello"};
 
         try {
             new ApexMonitoringRestMain(eventArgs, System.out);
             fail("test should throw an exception");
         } catch (Exception ex) {
-            assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
-                            + "parameter error, error parsing argument \"port\" :For input string: \"hello\"",
-                            ex.getMessage().substring(0, 156));
+            assertEquals(
+                "Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
+                    + "parameter error, error parsing argument \"port\" :For input string: \"hello\"",
+                ex.getMessage().substring(0, 156));
         }
     }
 
     @Test
     public void testMonitoringClientPortNegative() {
-        final String[] eventArgs =
-            { "-p", "-1" };
+        final String[] eventArgs = {"-p", "-1"};
 
         try {
             new ApexMonitoringRestMain(eventArgs, System.out);
             fail("test should throw an exception");
         } catch (Exception ex) {
             assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[ApexMonitoringRestParameters: "
-                            + "URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
-                            + "port must be greater than 1023 and less than 65536", ex.getMessage().substring(0, 227));
+                + "URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
+                + "port must be greater than 1023 and less than 65536", ex.getMessage().substring(0, 227));
         }
     }
 
     @Test
     public void testMonitoringClientTtlTooSmall() {
-        final String[] eventArgs =
-            { "-t", "-2" };
+        final String[] eventArgs = {"-t", "-2"};
 
         try {
             new ApexMonitoringRestMain(eventArgs, System.out);
             fail("test should throw an exception");
         } catch (Exception ex) {
-            assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[ApexMonitoringRestParameters: "
-                            + "URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
-                            + "time to live must be greater than -1 (set to -1 to wait forever)",
-                            ex.getMessage().substring(0, 244));
+            assertEquals(
+                "Apex Services REST endpoint (ApexMonitoringRestMain: Config=[ApexMonitoringRestParameters: "
+                    + "URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
+                    + "time to live must be greater than -1 (set to -1 to wait forever)",
+                ex.getMessage().substring(0, 244));
         }
     }
 
     @Test
     public void testMonitoringClientTooManyPars() {
-        final String[] eventArgs =
-            { "-t", "10", "-p", "12344", "aaa", "bbb" };
+        final String[] eventArgs = {"-t", "10", "-p", "12344", "aaa", "bbb"};
 
         try {
             new ApexMonitoringRestMain(eventArgs, System.out);
             fail("test should throw an exception");
         } catch (Exception ex) {
-            assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
-                            + "parameter error, too many command line arguments specified : [aaa, bbb]",
-                            ex.getMessage().substring(0, 154));
+            assertEquals(
+                "Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
+                    + "parameter error, too many command line arguments specified : [aaa, bbb]",
+                ex.getMessage().substring(0, 154));
         }
     }
 
     @Test
     public void testMonitoringClientTtlNotNumber() {
-        final String[] eventArgs =
-            { "-t", "timetolive" };
+        final String[] eventArgs = {"-t", "timetolive"};
 
         try {
             new ApexMonitoringRestMain(eventArgs, System.out);
             fail("test should throw an exception");
         } catch (Exception ex) {
-            assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
-                            + "parameter error, error parsing argument \"time-to-live\" :"
-                            + "For input string: \"timetolive\"", ex.getMessage().substring(0, 169));
+            assertEquals(
+                "Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
+                    + "parameter error, error parsing argument \"time-to-live\" :" + "For input string: \"timetolive\"",
+                ex.getMessage().substring(0, 169));
         }
     }
 
     @Test
     public void testMonitoringClientPortTooBig() {
-        final String[] eventArgs =
-            { "-p", "65536" };
+        final String[] eventArgs = {"-p", "65536"};
 
         try {
             new ApexMonitoringRestMain(eventArgs, System.out);
             fail("test should throw an exception");
         } catch (Exception ex) {
             assertEquals("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[ApexMonitoringRestParameters: "
-                            + "URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
-                            + "port must be greater than 1023 and less than 65536", ex.getMessage().substring(0, 230));
+                + "URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
+                + "port must be greater than 1023 and less than 65536", ex.getMessage().substring(0, 230));
         }
     }
 
@@ -205,8 +199,7 @@ public class MonitoringRestMainTest {
 
     @Test
     public void testMonitoringOneSecStart() {
-        final String[] eventArgs =
-            { "-t", "1" };
+        final String[] eventArgs = {"-t", "1"};
 
         try {
             ApexMonitoringRestMain monRestMain = new ApexMonitoringRestMain(eventArgs, System.out);
@@ -220,12 +213,12 @@ public class MonitoringRestMainTest {
 
     @Test
     public void testMonitoringForeverStart() {
-        final String[] eventArgs =
-            { "-t", "-1" };
+        final String[] eventArgs = {"-t", "-1"};
 
         ApexMonitoringRestMain monRestMain = new ApexMonitoringRestMain(eventArgs, System.out);
 
         Thread monThread = new Thread() {
+            @Override
             public void run() {
                 monRestMain.init();
             }
@@ -233,8 +226,8 @@ public class MonitoringRestMainTest {
 
         try {
             monThread.start();
-            await().atMost(6, TimeUnit.SECONDS).until(
-                    () -> monRestMain.getState().equals(ApexMonitoringRestMain.ServicesState.RUNNING));
+            await().atMost(6, TimeUnit.SECONDS)
+                .until(() -> monRestMain.getState().equals(ApexMonitoringRestMain.ServicesState.RUNNING));
             monRestMain.shutdown();
         } catch (Exception ex) {
             fail("test should not throw an exception");
@@ -243,7 +236,7 @@ public class MonitoringRestMainTest {
 
     /**
      * Run the application.
-     * 
+     *
      * @param eventArgs the command arguments
      * @return a string containing the command output
      */
index 965013a..4eda2ee 100644 (file)
@@ -21,6 +21,8 @@
 
 package org.onap.policy.apex.core.deployment;
 
+import static org.awaitility.Awaitility.await;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
@@ -42,8 +44,6 @@ import org.onap.policy.apex.core.protocols.engdep.messages.UpdateModel;
 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
 import org.onap.policy.common.utils.resources.TextFileUtils;
 
-import static org.awaitility.Awaitility.await;
-
 /**
  * Dummy deployment client.
  */
index d9691f1..5a13901 100644 (file)
@@ -25,6 +25,8 @@ import static org.awaitility.Awaitility.await;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import java.util.concurrent.TimeUnit;
+
 import org.junit.Test;
 import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageClient;
 import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener;
@@ -32,8 +34,6 @@ import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStri
 import org.slf4j.ext.XLogger;
 import org.slf4j.ext.XLoggerFactory;
 
-import java.util.concurrent.TimeUnit;
-
 /**
  * The Class EndToEndMessagingTest.
  *
index a2c5153..ee22121 100644 (file)
@@ -24,8 +24,6 @@ package org.onap.policy.apex.core.infrastructure.threading;
 import org.slf4j.ext.XLogger;
 import org.slf4j.ext.XLoggerFactory;
 
-import java.util.concurrent.CountDownLatch;
-
 /**
  * The Class ThreadingTestThread.
  *
@@ -42,9 +40,7 @@ public class ThreadingTestThread implements Runnable {
 
     private String threadName;
 
-    private CountDownLatch latch = new CountDownLatch(1);
-
-   /**
+    /**
      * {@inheritDoc}.
      */
     @Override
@@ -59,7 +55,7 @@ public class ThreadingTestThread implements Runnable {
             if (logger.isDebugEnabled()) {
                 logger.debug("in threading test thread \"" + threadName + "\", counter=" + counter + " . . .");
             }
-            if(!ThreadUtilities.sleep(50)) {
+            if (!ThreadUtilities.sleep(50)) {
                 interrupted = true;
             }
         }
index bca901e..11a7556 100644 (file)
 
 package org.onap.policy.apex.examples.aadm;
 
+import static org.awaitility.Awaitility.await;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import org.onap.policy.apex.core.engine.engine.EnEventListener;
 import org.onap.policy.apex.core.engine.event.EnEvent;
-import static org.awaitility.Awaitility.await;
 
 /**
  * The listener interface for receiving testApexAction events. The class that is interested in processing a
index 2892472..b06908d 100644 (file)
@@ -21,6 +21,8 @@
 
 package org.onap.policy.apex.examples.adaptive;
 
+import static org.awaitility.Awaitility.await;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
@@ -28,8 +30,6 @@ import java.util.concurrent.TimeUnit;
 import org.onap.policy.apex.core.engine.engine.EnEventListener;
 import org.onap.policy.apex.core.engine.event.EnEvent;
 
-import static org.awaitility.Awaitility.await;
-
 /**
  * The listener interface for receiving testApexAction events. The class that is interested in processing a
  * testApexAction event implements this interface, and the object created with that class is registered with a component
index b35d405..9e603f4 100644 (file)
@@ -142,7 +142,9 @@ public class EngineStatsTest {
         assertTrue(stats.equals(stats));
         assertTrue(stats.equals(clonedStats));
         assertFalse(stats.equals(null));
-        assertFalse(stats.equals("Hello"));
+
+        Object helloObject = "Hello";
+        assertFalse(stats.equals(helloObject));
         assertFalse(stats.equals(new AxEngineStats(new AxReferenceKey())));
 
         assertEquals(0, stats.compareTo(stats));
index bb5398c..95cf4ad 100644 (file)
@@ -21,8 +21,6 @@
 
 package org.onap.policy.apex.plugins.event.carrier.kafka;
 
-import java.util.EnumMap;
-import java.util.Map;
 import java.util.Properties;
 
 import org.apache.kafka.clients.producer.KafkaProducer;
@@ -30,10 +28,7 @@ import org.apache.kafka.clients.producer.Producer;
 import org.apache.kafka.clients.producer.ProducerRecord;
 import org.onap.policy.apex.service.engine.event.ApexEventException;
 import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer;
-import org.onap.policy.apex.service.engine.event.PeeredReference;
-import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
 import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
-import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -81,8 +76,8 @@ public class ApexKafkaProducer extends ApexPluginsEventProducer {
             // Kick off the Kafka producer
             kafkaProducer = new KafkaProducer<>(kafkaProducerProperties.getKafkaProducerProperties());
             if (LOGGER.isDebugEnabled()) {
-                LOGGER.debug("event producer " + this.name + " is ready to send to topics: "
-                        kafkaProducerProperties.getProducerTopic());
+                LOGGER.debug("event producer {} is ready to send to topics: {}", this.name,
+                        kafkaProducerProperties.getProducerTopic());
             }
         }
 
index 3341082..1bfa9d7 100644 (file)
@@ -216,7 +216,7 @@ public class ApexRestClientConusmerTest {
         // We have not set the URL, this test should not receive any events
         arcc.start();
         await().atMost(400, TimeUnit.MILLISECONDS).until(() -> outContent.toString()
-                        .contains("received an empty event from URL \"http://some.place.that.does.not/exist\""));
+            .contains("received an empty event from URL \"http://some.place.that.does.not/exist\""));
         arcc.stop();
         assertEquals(0, incomingEventReceiver.getEventCount());
     }
@@ -259,7 +259,7 @@ public class ApexRestClientConusmerTest {
         // We have not set the URL, this test should not receive any events
         arcc.start();
         await().atMost(200, TimeUnit.MILLISECONDS).until(() -> outContent.toString()
-                        .contains("received an empty event from URL \"http://some.place.that.does.not/exist\""));
+            .contains("received an empty event from URL \"http://some.place.that.does.not/exist\""));
         arcc.stop();
 
         assertEquals(0, incomingEventReceiver.getEventCount());
@@ -303,8 +303,8 @@ public class ApexRestClientConusmerTest {
 
         // We have not set the URL, this test should not receive any events
         arcc.start();
-        await().atMost(400, TimeUnit.MILLISECONDS).until(
-                () -> incomingEventReceiver.getLastEvent().equals("This is an event"));
+        await().atMost(400, TimeUnit.MILLISECONDS)
+            .until(() -> incomingEventReceiver.getLastEvent().equals("This is an event"));
         arcc.stop();
     }
 
index ce688d6..4ab65d9 100644 (file)
@@ -42,18 +42,12 @@ import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
 import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.consumer.ApexFileEventConsumer;
 import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
 import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import ch.qos.logback.classic.Level;
 
 /**
  * Test the ApexRestClientProducer class.
  *
  */
 public class ApexRestClientProducerTest {
-    private static final Logger LOGGER = LoggerFactory.getLogger(ApexRestClientProducer.class);
-
     @Mock
     private Client httpClientMock;
 
@@ -257,9 +251,6 @@ public class ApexRestClientProducerTest {
     public void testApexRestClientProducerPostEventCacheTrace() throws ApexEventException {
         MockitoAnnotations.initMocks(this);
 
-        ch.qos.logback.classic.Logger classicLogger = (ch.qos.logback.classic.Logger) LOGGER;
-        classicLogger.setLevel(Level.TRACE);
-
         ApexRestClientProducer arcp = new ApexRestClientProducer();
         assertNotNull(arcp);
 
index 422c91b..663ab8f 100644 (file)
@@ -21,8 +21,6 @@
 
 package org.onap.policy.apex.plugins.event.carrier.websocket;
 
-import java.util.EnumMap;
-import java.util.Map;
 import java.util.Properties;
 
 import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
@@ -32,10 +30,7 @@ import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStri
 import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessager;
 import org.onap.policy.apex.service.engine.event.ApexEventException;
 import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer;
-import org.onap.policy.apex.service.engine.event.PeeredReference;
-import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
 import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
-import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,7 +39,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author Liam Fallon (liam.fallon@ericsson.com)
  */
-public class ApexWebSocketProducer extends ApexPluginsEventProducer implements  WsStringMessageListener {
+public class ApexWebSocketProducer extends ApexPluginsEventProducer implements WsStringMessageListener {
     // Get a reference to the logger
     private static final Logger LOGGER = LoggerFactory.getLogger(ApexWebSocketProducer.class);
 
@@ -91,7 +86,7 @@ public class ApexWebSocketProducer extends ApexPluginsEventProducer implements
     @Override
     public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
             final Object event) {
-        super.sendEvent(executionId, executionProperties, eventName, event );
+        super.sendEvent(executionId, executionProperties, eventName, event);
 
         wsStringMessager.sendString((String) event);
     }
index 06c3d41..e126335 100644 (file)
 
 package org.onap.policy.apex.service.engine.event;
 
-import org.onap.policy.apex.core.infrastructure.threading.ApplicationThreadFactory;
-import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
-
 import java.util.EnumMap;
 import java.util.Map;
 import java.util.Properties;
 
+import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
+
 public abstract class ApexPluginsEventProducer implements ApexEventProducer {
     // The name for this producer
     protected String name = null;
     // The peer references for this event handler
-    protected Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap = new EnumMap<>(EventHandlerPeeredMode.class);
+    protected Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap =
+            new EnumMap<>(EventHandlerPeeredMode.class);
 
     /**
      * {@inheritDoc}.
@@ -62,7 +62,7 @@ public abstract class ApexPluginsEventProducer implements ApexEventProducer {
      */
     @Override
     public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
-                          final Object event) {
+            final Object event) {
         // Check if this is a synchronized event, if so we have received a reply
         final SynchronousEventCache synchronousEventCache =
                 (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
index 8f21a4f..b0dac33 100644 (file)
@@ -24,19 +24,14 @@ package org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.produce
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
-import java.util.EnumMap;
-import java.util.Map;
 import java.util.Properties;
 
 import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
 import org.onap.policy.apex.service.engine.event.ApexEventException;
-import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer;
 import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
-import org.onap.policy.apex.service.engine.event.PeeredReference;
-import org.onap.policy.apex.service.engine.event.SynchronousEventCache;
+import org.onap.policy.apex.service.engine.event.ApexPluginsEventProducer;
 import org.onap.policy.apex.service.engine.event.impl.filecarrierplugin.FileCarrierTechnologyParameters;
 import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
-import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,7 +51,8 @@ public class ApexFileEventProducer extends ApexPluginsEventProducer {
      * {@inheritDoc}.
      */
     @Override
-    public void init(final String producerName, final EventHandlerParameters producerParameters) throws ApexEventException {
+    public void init(final String producerName, final EventHandlerParameters producerParameters)
+            throws ApexEventException {
         this.name = producerName;
 
         // Get and check the Apex parameters from the parameter service
@@ -89,7 +85,6 @@ public class ApexFileEventProducer extends ApexPluginsEventProducer {
         } catch (final IOException e) {
             final String errorMessage = "ApexFileProducer \"" + producerName + "\" failed to open file for writing: \""
                     + fileCarrierTechnologyParameters.getFileName() + "\"";
-            LOGGER.warn(errorMessage, e);
             throw new ApexEventException(errorMessage, e);
         }
 
@@ -112,9 +107,8 @@ public class ApexFileEventProducer extends ApexPluginsEventProducer {
         try {
             stringEvent = (String) event;
         } catch (final Exception e) {
-            final String errorMessage = "error in ApexFileProducer \"" + name + "\" while transferring event \""
-                    + event + "\" to the output stream";
-            LOGGER.debug(errorMessage, e);
+            final String errorMessage = "error in ApexFileProducer \"" + name + "\" while transferring event \"" + event
+                    + "\" to the output stream";
             throw new ApexEventRuntimeException(errorMessage, e);
         }
 
index 6de0f0c..c1d76b0 100644 (file)
         <dependency>
             <groupId>org.awaitility</groupId>
             <artifactId>awaitility</artifactId>
-            <version>3.0.0</version>
             <scope>test</scope>
         </dependency>
     </dependencies>