From 690495d32c6033741d7a7c2413476f7ba88e2825 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Wed, 11 Mar 2020 21:29:17 +0000 Subject: Fix minor checkstyle/eclipse warnings 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 --- .../deployment/rest/DeploymentRestMainTest.java | 83 ++++++++---------- .../client/full/rest/ServicesRestMainTest.java | 73 +++++++--------- .../monitoring/rest/MonitoringRestMainTest.java | 99 ++++++++++------------ .../core/deployment/DummyDeploymentClient.java | 4 +- .../messaging/EndToEndStringMessagingTest.java | 4 +- .../threading/ThreadingTestThread.java | 8 +- .../apex/examples/aadm/TestApexActionListener.java | 3 +- .../examples/adaptive/TestApexActionListener.java | 4 +- .../enginemodel/concepts/EngineStatsTest.java | 4 +- .../event/carrier/kafka/ApexKafkaProducer.java | 9 +- .../restclient/ApexRestClientConusmerTest.java | 8 +- .../restclient/ApexRestClientProducerTest.java | 9 -- .../carrier/websocket/ApexWebSocketProducer.java | 9 +- .../engine/event/ApexPluginsEventProducer.java | 10 +-- .../producer/ApexFileEventProducer.java | 16 ++-- .../integration/integration-uservice-test/pom.xml | 1 - 16 files changed, 142 insertions(+), 202 deletions(-) diff --git a/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestMainTest.java b/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestMainTest.java index 245900d7d..91b5480b6 100644 --- a/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestMainTest.java +++ b/client/client-deployment/src/test/java/org/onap/policy/apex/client/deployment/rest/DeploymentRestMainTest.java @@ -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(); } diff --git a/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestMainTest.java b/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestMainTest.java index 3e21ee595..5b01e04fa 100644 --- a/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestMainTest.java +++ b/client/client-full/src/test/java/org/onap/policy/apex/client/full/rest/ServicesRestMainTest.java @@ -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(); } diff --git a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java index 71ca21d2e..f27a53adc 100644 --- a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java +++ b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java @@ -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 */ diff --git a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DummyDeploymentClient.java b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DummyDeploymentClient.java index 965013acb..4eda2eeba 100644 --- a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DummyDeploymentClient.java +++ b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/DummyDeploymentClient.java @@ -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. */ diff --git a/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java b/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java index d9691f17e..5a1390163 100644 --- a/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java +++ b/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/messaging/EndToEndStringMessagingTest.java @@ -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. * diff --git a/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/threading/ThreadingTestThread.java b/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/threading/ThreadingTestThread.java index a2c51539f..ee2212159 100644 --- a/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/threading/ThreadingTestThread.java +++ b/core/core-infrastructure/src/test/java/org/onap/policy/apex/core/infrastructure/threading/ThreadingTestThread.java @@ -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; } } diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestApexActionListener.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestApexActionListener.java index bca901e6b..11a755653 100644 --- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestApexActionListener.java +++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/TestApexActionListener.java @@ -21,13 +21,14 @@ 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 diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestApexActionListener.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestApexActionListener.java index 28924728e..b06908da2 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestApexActionListener.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestApexActionListener.java @@ -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 diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java index b35d40570..9e603f491 100644 --- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java +++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java @@ -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)); diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java index bb5398ceb..95cf4ad8b 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-kafka/src/main/java/org/onap/policy/apex/plugins/event/carrier/kafka/ApexKafkaProducer.java @@ -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()); } } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java index 3341082c0..1bfa9d778 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientConusmerTest.java @@ -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(); } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java index ce688d62d..4ab65d927 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/test/java/org/onap/policy/apex/plugins/event/carrier/restclient/ApexRestClientProducerTest.java @@ -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); diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java index 422c91bc3..663ab8f7f 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketProducer.java @@ -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); } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPluginsEventProducer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPluginsEventProducer.java index 06c3d4163..e12633555 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPluginsEventProducer.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPluginsEventProducer.java @@ -20,18 +20,18 @@ 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 peerReferenceMap = new EnumMap<>(EventHandlerPeeredMode.class); + protected Map 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); diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java index 8f21a4fb9..b0dac3372 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java @@ -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); } diff --git a/testsuites/integration/integration-uservice-test/pom.xml b/testsuites/integration/integration-uservice-test/pom.xml index 6de0f0cef..c1d76b02d 100644 --- a/testsuites/integration/integration-uservice-test/pom.xml +++ b/testsuites/integration/integration-uservice-test/pom.xml @@ -175,7 +175,6 @@ org.awaitility awaitility - 3.0.0 test -- cgit 1.2.3-korg