summaryrefslogtreecommitdiffstats
path: root/reception/src/main/java/org
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2020-03-26 10:03:11 -0400
committerPamela Dragosh <pdragosh@research.att.com>2020-03-26 13:36:49 -0400
commitdffa54c9a27bcd9524e2aa75684ff02d70507b59 (patch)
tree50bf1fe93e35a74d5ead879bea76aada4b4c04b5 /reception/src/main/java/org
parent7bec6ce98fd24275d31b9aafe5b2f9bd515faf2c (diff)
Remove unused imports and clean logs
Unused imports and marked an unused variable. Added m2e eclipse settings (other repos have this). Added some test logback.xml to clear out jetty debug messages. Replaced deprecated newInstance with getDeclaredConstructor. newInstance Either log or throw Exception - chose throw Added some assertions to JUnit test. Issue-ID: POLICY-2305 Change-Id: Ia4e9ce62dc7fb45aea247d470ca7245e694fc26e Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'reception/src/main/java/org')
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java3
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java17
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java2
-rw-r--r--reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java2
4 files changed, 15 insertions, 9 deletions
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java
index 2ea18704..52c34cec 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2020 AT&T Inc.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -85,7 +86,7 @@ public abstract class AbstractReceptionHandler implements ReceptionHandler {
try {
policyForwarder.forward(policies);
} catch (final PolicyForwardingException policyForwardingException) {
- LOGGER.error("Error when forwarding policies to " + policyForwarder, policyForwardingException);
+ LOGGER.error("Error when forwarding policies to {}", policyForwarder, policyForwardingException);
}
}
}
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
index f837e520..5067c841 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2020 AT&T Inc.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
package org.onap.policy.distribution.reception.handling;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
@@ -92,11 +94,13 @@ public class PluginHandler {
final Class<PolicyDecoder<PolicyInput, ToscaEntity>> policyDecoderClass =
(Class<PolicyDecoder<PolicyInput, ToscaEntity>>) Class
.forName(decoderParameters.getDecoderClassName());
- final PolicyDecoder<PolicyInput, ToscaEntity> decoder = policyDecoderClass.newInstance();
+ final PolicyDecoder<PolicyInput, ToscaEntity> decoder =
+ policyDecoderClass.getDeclaredConstructor().newInstance();
decoder.configure(decoderParameters.getDecoderConfigurationName());
policyDecoders.add(decoder);
- } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException exp) {
- LOGGER.error("exception occured while initializing decoders", exp);
+ } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
+ | SecurityException exp) {
throw new PluginInitializationException(exp.getMessage(), exp.getCause());
}
}
@@ -116,11 +120,12 @@ public class PluginHandler {
try {
final Class<PolicyForwarder> policyForwarderClass =
(Class<PolicyForwarder>) Class.forName(forwarderParameters.getForwarderClassName());
- final PolicyForwarder policyForwarder = policyForwarderClass.newInstance();
+ final PolicyForwarder policyForwarder = policyForwarderClass.getDeclaredConstructor().newInstance();
policyForwarder.configure(forwarderParameters.getForwarderConfigurationName());
policyForwarders.add(policyForwarder);
- } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException exp) {
- LOGGER.error("exception occured while initializing forwarders", exp);
+ } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
+ | SecurityException exp) {
throw new PluginInitializationException(exp.getMessage(), exp.getCause());
}
}
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java
index c30d3d3d..b1c8053b 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2020 AT&T Inc.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,7 +76,6 @@ public class PolicyDecoderConfigurationParametersJsonAdapter
} catch (final ClassNotFoundException exp) {
final String errorMessage = "parameter \"" + PARAMETER_CLASS_NAME + "\" value \""
+ policyDecoderParameterClassName + "\", could not find class";
- LOGGER.warn(errorMessage, exp);
throw new IllegalArgumentException(errorMessage, exp);
}
return policyDecoderParameterClass;
diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java
index 9b3a4d2b..9a34ee61 100644
--- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java
+++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2020 AT&T Inc.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,7 +75,6 @@ public class ReceptionHandlerConfigurationParametersJsonAdapter
} catch (final ClassNotFoundException e) {
final String errorMessage = "parameter \"" + PARAMETER_CLASS_NAME + "\" value \""
+ receptionHAndlerParameterClassName + "\", could not find class";
- LOGGER.warn(errorMessage, e);
throw new IllegalArgumentException(errorMessage, e);
}
return receptionHandlerParameterClass;