From a65e4772f4557a109917532b2d9c49680ce3bb15 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 14 Sep 2018 16:45:06 +0100 Subject: Fix exception not logged or rethrown Eclipse sonarlint does not check for exception dropping by default, it must be configured. This commit addresses exception dropping in apex. Change-Id: I406838990b3424c2912124b25d7326502cacc96c Issue-ID: POLICY-1034 Signed-off-by: liamfallon --- .../apex/examples/adaptive/TestAnomalyDetectionTslUseCase.java | 5 +++-- .../policy/apex/examples/adaptive/TestApexActionListener.java | 7 ++----- .../policy/apex/examples/adaptive/TestAutoLearnTslUseCase.java | 8 ++++---- 3 files changed, 9 insertions(+), 11 deletions(-) (limited to 'examples/examples-adaptive/src/test') diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTslUseCase.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTslUseCase.java index cb7e3c824..c29a3cb6e 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTslUseCase.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTslUseCase.java @@ -38,6 +38,7 @@ import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.core.engine.engine.ApexEngine; import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory; import org.onap.policy.apex.core.engine.event.EnEvent; +import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.examples.adaptive.model.AdaptiveDomainModelFactory; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; @@ -148,7 +149,7 @@ public class TestAnomalyDetectionTslUseCase { assertEquals("ExecutionIDs are different", triggerEvent.getExecutionId(), result.getExecutionId()); triggerEvent.clear(); result.clear(); - Thread.sleep(1); + ThreadUtilities.sleep(1); apexEngine1.stop(); } @@ -215,7 +216,7 @@ public class TestAnomalyDetectionTslUseCase { result.clear(); } apexEngine1.stop(); - Thread.sleep(1000); + ThreadUtilities.sleep(1000); } /** 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 ec7c197b7..006d3de6f 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 @@ -69,11 +69,8 @@ public class TestApexActionListener implements EnEventListener { */ @Override public void onEnEvent(final EnEvent actionEvent) { - try { - Thread.sleep(100); - } catch (final InterruptedException e) { - e.printStackTrace(); - } + ThreadUtilities.sleep(100); + if (actionEvent != null) { System.out.println("Action event from engine:" + actionEvent.getName()); resultEvents.add(actionEvent); diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTslUseCase.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTslUseCase.java index 3052c31a7..10d69a457 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTslUseCase.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTslUseCase.java @@ -38,6 +38,7 @@ import org.onap.policy.apex.core.engine.EngineParameters; import org.onap.policy.apex.core.engine.engine.ApexEngine; import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory; import org.onap.policy.apex.core.engine.event.EnEvent; +import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.examples.adaptive.model.AdaptiveDomainModelFactory; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; @@ -146,7 +147,7 @@ public class TestAutoLearnTslUseCase { assertEquals("ExecutionIDs are different", triggerEvent.getExecutionId(), result.getExecutionId()); triggerEvent.clear(); result.clear(); - Thread.sleep(1); + ThreadUtilities.sleep(10); apexEngine1.stop(); } @@ -234,12 +235,11 @@ public class TestAutoLearnTslUseCase { LOGGER.info("Iteration " + iteration + ": \tpreval\t" + prevval + "\tval\t" + val + "\tavval\t" + avval); result.clear(); - Thread.sleep(1); + ThreadUtilities.sleep(10); } apexEngine1.stop(); - Thread.sleep(1000); - + ThreadUtilities.sleep(1000); } /** -- cgit 1.2.3-korg