aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java2
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java2
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java10
-rw-r--r--main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java4
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java10
-rw-r--r--main/src/test/resources/logback-test.xml41
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java2
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java5
-rw-r--r--plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java24
-rw-r--r--plugins/forwarding-plugins/src/test/resources/logback-test.xml41
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/PolicyDecoderCsarHpa.java5
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java8
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java5
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestAttribute.java2
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestContent.java3
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestDirective.java3
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorFeature.java4
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorProperty.java4
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestHpaFeatureAttribute.java2
-rw-r--r--pom.xml31
-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
24 files changed, 177 insertions, 55 deletions
diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java
index 7ef5fd75..f7314220 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.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.
@@ -69,7 +70,6 @@ public class DistributionParameterHandler {
} catch (final Exception e) {
final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
+ "\"\n" + "(" + e.getClass().getSimpleName() + "):" + e.getMessage();
- LOGGER.error(errorMessage, e);
throw new PolicyDistributionException(errorMessage, e);
}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java
index 687970dc..640353ea 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-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 PolicyForwarderConfigurationParametersJsonAdapter
} catch (final ClassNotFoundException e) {
final String errorMessage = "parameter \"" + PARAMETER_CLASS_NAME + "\" value \""
+ policyForwarderParameterClassName + "\", could not find class";
- LOGGER.warn(errorMessage, e);
throw new IllegalArgumentException(errorMessage, e);
}
return policyForwarderParameterClass;
diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
index a50fa6bc..3f19baf1 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/startstop/DistributionActivator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
package org.onap.policy.distribution.main.startstop;
+import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -82,12 +83,14 @@ public class DistributionActivator {
try {
final Class<AbstractReceptionHandler> receptionHandlerClass = (Class<AbstractReceptionHandler>) Class
.forName(receptionHandlerParameters.getReceptionHandlerClassName());
- final AbstractReceptionHandler receptionHandler = receptionHandlerClass.newInstance();
+ final AbstractReceptionHandler receptionHandler =
+ receptionHandlerClass.getDeclaredConstructor().newInstance();
receptionHandler.initialize(receptionHandlerParameters.getName());
receptionHandlersMap.put(receptionHandlerParameters.getName(), receptionHandler);
DistributionActivator.setAlive(true);
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException
- | PluginInitializationException exp) {
+ | PluginInitializationException | IllegalArgumentException | InvocationTargetException
+ | NoSuchMethodException | SecurityException exp) {
throw new PolicyDistributionException(exp.getMessage(), exp);
}
}
@@ -126,7 +129,6 @@ public class DistributionActivator {
// Stop the distribution rest server
restServer.stop();
} catch (final Exception exp) {
- LOGGER.error("Policy distribution service termination failed", exp);
throw new PolicyDistributionException(exp.getMessage(), exp);
}
}
diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java
index 13da2169..2c676333 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.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.
@@ -84,7 +85,8 @@ public class Main {
try {
activator.initialize();
} catch (final PolicyDistributionException e) {
- LOGGER.error("start of policy distribution service failed, used parameters are " + Arrays.toString(args),
+ LOGGER.error("start of policy distribution service failed, used parameters are {}",
+ Arrays.toString(args),
e);
return;
}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
index e1c5d22b..e5d03aaf 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * 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.
@@ -20,6 +21,7 @@
package org.onap.policy.distribution.main.startstop;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -62,9 +64,11 @@ public class TestMain {
@Test
public void testMain_Help() {
- final String[] distributionConfigParameters =
- { "-h" };
- Main.main(distributionConfigParameters);
+ assertThatCode(() -> {
+ final String[] distributionConfigParameters =
+ { "-h" };
+ Main.main(distributionConfigParameters);
+ }).doesNotThrowAnyException();
}
@Test
diff --git a/main/src/test/resources/logback-test.xml b/main/src/test/resources/logback-test.xml
new file mode 100644
index 00000000..f2f8acbb
--- /dev/null
+++ b/main/src/test/resources/logback-test.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2020 AT&T. All rights reserved.
+ ================================================================================
+ 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=========================================================
+-->
+
+<configuration>
+
+ <contextName>policy-api</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="org.eclipse.jetty.server.RequestLog" level="WARN" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+</configuration>
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java
index 55735662..e88f7eb9 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Intel Crop. All rights reserved.
+ * 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.
@@ -97,7 +98,6 @@ public class FilePolicyForwarder implements PolicyForwarder {
LOGGER.debug("Sucessfully forwarded the policy to store into file {}.", path);
} catch (final InvalidPathException | IOException exp) {
final String message = "Error sending policy to file under path:" + fileForwarderParameters.getPath();
- LOGGER.error(message, exp);
throw new PolicyForwardingException(message, exp);
}
}
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java
index 5cd9966d..e3c013ad 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* 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.
@@ -153,10 +154,8 @@ public class LifecycleApiPolicyForwarder implements PolicyForwarder {
throw new PolicyForwardingException("Failed creating the entity - " + entity);
}
} catch (final HttpClientConfigException exception) {
- LOGGER.error(
- "Invocation of path " + path + " failed for entity " + entity + " due to error opening Http client",
+ throw new PolicyForwardingException("Invocation of path " + path + " failed for entity " + entity,
exception);
- throw new PolicyForwardingException("Failed creating the entity - " + entity, exception);
}
return response;
}
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java
index 7d84657a..5fce708e 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* 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.
@@ -20,6 +21,7 @@
package org.onap.policy.distribution.forwarding.lifecycle.api;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.ArrayList;
@@ -83,20 +85,22 @@ public class LifecycleApiPolicyForwarderTest {
@Test
public void testForwardPolicyUsingSimulator() throws Exception {
+ assertThatCode(() -> {
+ final ToscaServiceTemplate toscaServiceTemplate1 =
+ standardCoder.decode(ResourceUtils.getResourceAsString(POLICY_TYPE), ToscaServiceTemplate.class);
+ final ToscaServiceTemplate toscaServiceTemplate2 =
+ standardCoder.decode(ResourceUtils.getResourceAsString(POLICY), ToscaServiceTemplate.class);
- final ToscaServiceTemplate toscaServiceTemplate1 =
- standardCoder.decode(ResourceUtils.getResourceAsString(POLICY_TYPE), ToscaServiceTemplate.class);
- final ToscaServiceTemplate toscaServiceTemplate2 =
- standardCoder.decode(ResourceUtils.getResourceAsString(POLICY), ToscaServiceTemplate.class);
+ final LifecycleApiPolicyForwarder forwarder = new LifecycleApiPolicyForwarder();
+ forwarder.configure(LifecycleApiForwarderParameters.class.getSimpleName());
- final LifecycleApiPolicyForwarder forwarder = new LifecycleApiPolicyForwarder();
- forwarder.configure(LifecycleApiForwarderParameters.class.getSimpleName());
+ final Collection<ToscaEntity> policies = new ArrayList<>();
+ policies.add(toscaServiceTemplate1);
+ policies.add(toscaServiceTemplate2);
- final Collection<ToscaEntity> policies = new ArrayList<>();
- policies.add(toscaServiceTemplate1);
- policies.add(toscaServiceTemplate2);
+ forwarder.forward(policies);
- forwarder.forward(policies);
+ }).doesNotThrowAnyException();
}
@Test
diff --git a/plugins/forwarding-plugins/src/test/resources/logback-test.xml b/plugins/forwarding-plugins/src/test/resources/logback-test.xml
new file mode 100644
index 00000000..29d86d48
--- /dev/null
+++ b/plugins/forwarding-plugins/src/test/resources/logback-test.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2020 AT&T Inc. All rights reserved.
+ ================================================================================
+ 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=========================================================
+-->
+
+<configuration>
+
+ <contextName>policy-api</contextName>
+ <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <logger name="org.eclipse.jetty.server.RequestLog" level="WARN" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+</configuration>
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/PolicyDecoderCsarHpa.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/PolicyDecoderCsarHpa.java
index e1e1a9a9..51aa15f6 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/PolicyDecoderCsarHpa.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/hpa/PolicyDecoderCsarHpa.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* 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.
@@ -46,6 +47,10 @@ import org.slf4j.LoggerFactory;
public class PolicyDecoderCsarHpa implements PolicyDecoder<Csar, ToscaServiceTemplate> {
private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderCsarHpa.class);
+ //
+ // This is initialized in configure() but then never used here
+ //
+ @SuppressWarnings("unused")
private PolicyDecoderCsarHpaParameters decoderParameters;
public static final String TOSCA_POLICY_SCOPE = "scope";
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java
index 4b58d2da..643785fa 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.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.
@@ -37,8 +38,6 @@ import org.onap.policy.distribution.reception.decoding.PolicyDecoder;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* This class extracts policy files from a CSAR file.
@@ -47,7 +46,6 @@ import org.slf4j.LoggerFactory;
*/
public class PolicyDecoderFileInCsarToPolicy implements PolicyDecoder<Csar, ToscaEntity> {
- private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderFileInCsarToPolicy.class);
private PolicyDecoderFileInCsarToPolicyParameterGroup decoderParameters;
private StandardCoder coder;
@@ -87,9 +85,7 @@ public class PolicyDecoderFileInCsarToPolicy implements PolicyDecoder<Csar, Tosc
}
}
} catch (final IOException | CoderException exp) {
- final String message = "Failed decoding the policy";
- LOGGER.error(message, exp);
- throw new PolicyDecodingException(message, exp);
+ throw new PolicyDecodingException("Failed decoding the policy", exp);
}
return policyList;
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
index 9c336327..b89a679b 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.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.
@@ -267,9 +268,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
return tempArtifactFile.toPath();
}
} catch (final Exception exp) {
- final String message = "Failed to write artifact to local repository";
- LOGGER.error(message, exp);
- throw new ArtifactDownloadException(message, exp);
+ throw new ArtifactDownloadException("Failed to write artifact to local repository", exp);
}
}
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestAttribute.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestAttribute.java
index cf03ff30..b4e2ed43 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestAttribute.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestAttribute.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * 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.
@@ -23,7 +24,6 @@ package org.onap.policy.distribution.reception.decoding.hpa;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.onap.policy.distribution.reception.decoding.hpa.Attribute;
/**
* Class to perform unit test for Attribute 0f {@link Attribute}.
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestContent.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestContent.java
index 3770bc77..bc8f4d5c 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestContent.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestContent.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * 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.
@@ -23,8 +24,6 @@ package org.onap.policy.distribution.reception.decoding.hpa;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.onap.policy.distribution.reception.decoding.hpa.Content;
-import org.onap.policy.distribution.reception.decoding.hpa.FlavorFeature;
/**
* Class to perform unit test for Content 0f {@link Content}.
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestDirective.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestDirective.java
index 9ab53931..7429fe7a 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestDirective.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestDirective.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * 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.
@@ -23,8 +24,6 @@ package org.onap.policy.distribution.reception.decoding.hpa;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.onap.policy.distribution.reception.decoding.hpa.Attribute;
-import org.onap.policy.distribution.reception.decoding.hpa.Directive;
/**
* Class to perform unit test for Directive 0f {@link Directive}.
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorFeature.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorFeature.java
index 47b74c71..b9fee589 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorFeature.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorFeature.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * 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.
@@ -23,9 +24,6 @@ package org.onap.policy.distribution.reception.decoding.hpa;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.onap.policy.distribution.reception.decoding.hpa.Directive;
-import org.onap.policy.distribution.reception.decoding.hpa.FlavorFeature;
-import org.onap.policy.distribution.reception.decoding.hpa.FlavorProperty;
/**
* Class to perform unit test for FlavorFeature 0f {@link FlavorFeature}.
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorProperty.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorProperty.java
index 2d0504da..af6600c8 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorProperty.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestFlavorProperty.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * 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.
@@ -23,9 +24,6 @@ package org.onap.policy.distribution.reception.decoding.hpa;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.onap.policy.distribution.reception.decoding.hpa.Directive;
-import org.onap.policy.distribution.reception.decoding.hpa.FlavorProperty;
-import org.onap.policy.distribution.reception.decoding.hpa.HpaFeatureAttribute;
/**
* Class to perform unit test for FlavorProperty 0f {@link FlavorProperty}.
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestHpaFeatureAttribute.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestHpaFeatureAttribute.java
index fddeb168..3c6531db 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestHpaFeatureAttribute.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/hpa/TestHpaFeatureAttribute.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * 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.
@@ -23,7 +24,6 @@ package org.onap.policy.distribution.reception.decoding.hpa;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.onap.policy.distribution.reception.decoding.hpa.HpaFeatureAttribute;
/**
* Class to perform unit test for HpaFeatureAttribute 0f {@link HpaFeatureAttribute}.
diff --git a/pom.xml b/pom.xml
index 961a5d61..9b20e819 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,6 +4,7 @@
================================================================================
Copyright (C) 2018, 2020 AT&T Intellectual Property. 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.
@@ -64,11 +65,15 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.onap.policy.common</groupId>
<artifactId>policy-endpoints</artifactId>
@@ -86,6 +91,30 @@
<build>
<plugins>
<plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <versionRange>2.17,)</versionRange>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ <plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
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;