summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java85
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandlerClass.json54
-rw-r--r--main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json54
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java54
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterBuilder.java337
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java160
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcConfiguration.java88
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java159
-rw-r--r--plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json2
9 files changed, 719 insertions, 274 deletions
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java
index 14d1a105..a5eab8b1 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
+
import org.junit.Test;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.startstop.DistributionCommandLineArguments;
@@ -40,7 +41,8 @@ import org.onap.policy.distribution.main.testclasses.DummyPolicyForwarderParamet
public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerNoParameterFile() throws PolicyDistributionException {
- final String[] noArgumentString = {"-c", "parameters/NoParameterFile.json"};
+ final String[] noArgumentString =
+ { "-c", "parameters/NoParameterFile.json" };
final DistributionCommandLineArguments noArguments = new DistributionCommandLineArguments();
noArguments.parse(noArgumentString);
@@ -55,7 +57,8 @@ public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerEmptyParameters() throws PolicyDistributionException {
- final String[] emptyArgumentString = {"-c", "parameters/EmptyParameters.json"};
+ final String[] emptyArgumentString =
+ { "-c", "parameters/EmptyParameters.json" };
final DistributionCommandLineArguments emptyArguments = new DistributionCommandLineArguments();
emptyArguments.parse(emptyArgumentString);
@@ -70,7 +73,8 @@ public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerBadParameters() throws PolicyDistributionException {
- final String[] badArgumentString = {"-c", "parameters/BadParameters.json"};
+ final String[] badArgumentString =
+ { "-c", "parameters/BadParameters.json" };
final DistributionCommandLineArguments badArguments = new DistributionCommandLineArguments();
badArguments.parse(badArgumentString);
@@ -87,7 +91,8 @@ public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerInvalidParameters() throws PolicyDistributionException {
- final String[] invalidArgumentString = {"-c", "parameters/InvalidParameters.json"};
+ final String[] invalidArgumentString =
+ { "-c", "parameters/InvalidParameters.json" };
final DistributionCommandLineArguments invalidArguments = new DistributionCommandLineArguments();
invalidArguments.parse(invalidArgumentString);
@@ -104,7 +109,8 @@ public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerNoParameters() throws PolicyDistributionException {
- final String[] noArgumentString = {"-c", "parameters/NoParameters.json"};
+ final String[] noArgumentString =
+ { "-c", "parameters/NoParameters.json" };
final DistributionCommandLineArguments noArguments = new DistributionCommandLineArguments();
noArguments.parse(noArgumentString);
@@ -119,7 +125,8 @@ public class TestDistributionParameterHandler {
@Test
public void testParameterHandlerMinumumParameters() throws PolicyDistributionException {
- final String[] minArgumentString = {"-c", "parameters/MinimumParameters.json"};
+ final String[] minArgumentString =
+ { "-c", "parameters/MinimumParameters.json" };
final DistributionCommandLineArguments minArguments = new DistributionCommandLineArguments();
minArguments.parse(minArgumentString);
@@ -130,7 +137,8 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup() throws PolicyDistributionException {
- final String[] distributionConfigParameters = {"-c", "parameters/DistributionConfigParameters.json"};
+ final String[] distributionConfigParameters =
+ { "-c", "parameters/DistributionConfigParameters.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -157,7 +165,7 @@ public class TestDistributionParameterHandler {
public void testDistributionParameterGroup_InvalidForwarderConfigurationClassName()
throws PolicyDistributionException {
final String[] distributionConfigParameters =
- {"-c", "parameters/DistributionConfigParameters_InvalidForwarderConfigurationClassName.json"};
+ { "-c", "parameters/DistributionConfigParameters_InvalidForwarderConfigurationClassName.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -174,7 +182,7 @@ public class TestDistributionParameterHandler {
public void testDistributionParameterGroup_UnknownForwarderConfigurationClassName()
throws PolicyDistributionException {
final String[] distributionConfigParameters =
- {"-c", "parameters/DistributionConfigParameters_UnknownForwarderConfigurationClassName.json"};
+ { "-c", "parameters/DistributionConfigParameters_UnknownForwarderConfigurationClassName.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -191,7 +199,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_InvalidName() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- {"-c", "parameters/DistributionConfigParameters_InvalidName.json"};
+ { "-c", "parameters/DistributionConfigParameters_InvalidName.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -208,7 +216,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_NoReceptionHandler() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- {"-c", "parameters/DistributionConfigParameters_NoReceptionHandler.json"};
+ { "-c", "parameters/DistributionConfigParameters_NoReceptionHandler.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -224,7 +232,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_EmptyReceptionHandler() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- {"-c", "parameters/DistributionConfigParameters_EmptyReceptionHandler.json"};
+ { "-c", "parameters/DistributionConfigParameters_EmptyReceptionHandler.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -240,7 +248,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_NoPolicyDecoder() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- {"-c", "parameters/DistributionConfigParameters_NoPolicyDecoder.json"};
+ { "-c", "parameters/DistributionConfigParameters_NoPolicyDecoder.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -256,7 +264,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_NoPolicyForwarder() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- {"-c", "parameters/DistributionConfigParameters_NoPolicyForwarder.json"};
+ { "-c", "parameters/DistributionConfigParameters_NoPolicyForwarder.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -272,7 +280,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_EmptyPolicyDecoder() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- {"-c", "parameters/DistributionConfigParameters_EmptyPolicyDecoder.json"};
+ { "-c", "parameters/DistributionConfigParameters_EmptyPolicyDecoder.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -288,7 +296,7 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionParameterGroup_EmptyPolicyForwarder() throws PolicyDistributionException {
final String[] distributionConfigParameters =
- {"-c", "parameters/DistributionConfigParameters_EmptyPolicyForwarder.json"};
+ { "-c", "parameters/DistributionConfigParameters_EmptyPolicyForwarder.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -305,7 +313,7 @@ public class TestDistributionParameterHandler {
public void testDistributionParameterGroup_InvalidReceptionHandlerParameters()
throws PolicyDistributionException, IOException {
final String[] distributionConfigParameters =
- {"-c", "parameters/DistributionConfigParameters_InvalidReceptionHandlerParameters.json"};
+ { "-c", "parameters/DistributionConfigParameters_InvalidReceptionHandlerParameters.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -325,7 +333,7 @@ public class TestDistributionParameterHandler {
public void testDistributionParameterGroup_InvalidDecoderAndForwarderParameters()
throws PolicyDistributionException, IOException {
final String[] distributionConfigParameters =
- {"-c", "parameters/DistributionConfigParameters_InvalidDecoderAndForwarderParameters.json"};
+ { "-c", "parameters/DistributionConfigParameters_InvalidDecoderAndForwarderParameters.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -345,7 +353,7 @@ public class TestDistributionParameterHandler {
public void testDistributionParameterGroup_InvalidRestServerParameters()
throws PolicyDistributionException, IOException {
final String[] distributionConfigParameters =
- {"-c", "parameters/DistributionConfigParameters_InvalidRestServerParameters.json"};
+ { "-c", "parameters/DistributionConfigParameters_InvalidRestServerParameters.json" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
@@ -363,7 +371,8 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionVersion() throws PolicyDistributionException {
- final String[] distributionConfigParameters = {"-v"};
+ final String[] distributionConfigParameters =
+ { "-v" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
final String version = arguments.parse(distributionConfigParameters);
assertTrue(version.startsWith("ONAP Policy Framework Distribution Service"));
@@ -371,7 +380,8 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionHelp() throws PolicyDistributionException {
- final String[] distributionConfigParameters = {"-h"};
+ final String[] distributionConfigParameters =
+ { "-h" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
final String help = arguments.parse(distributionConfigParameters);
assertTrue(help.startsWith("usage:"));
@@ -379,7 +389,8 @@ public class TestDistributionParameterHandler {
@Test
public void testDistributionInvalidOption() throws PolicyDistributionException {
- final String[] distributionConfigParameters = {"-d"};
+ final String[] distributionConfigParameters =
+ { "-d" };
final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
try {
arguments.parse(distributionConfigParameters);
@@ -387,4 +398,34 @@ public class TestDistributionParameterHandler {
assertTrue(exp.getMessage().startsWith("invalid command line arguments specified"));
}
}
+
+ @Test
+ public void testDistributionParameterGroup_InvalidReceptionHandlerClass() throws PolicyDistributionException {
+ final String[] distributionConfigParameters =
+ { "-c", "parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json" };
+
+ final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
+ arguments.parse(distributionConfigParameters);
+
+ try {
+ new DistributionParameterHandler().getParameters(arguments);
+ } catch (final Exception e) {
+ assertTrue(e.getMessage().contains("could not find class"));
+ }
+ }
+
+ @Test
+ public void testDistributionParameterGroup_EmptyReceptionHandlerClass() throws PolicyDistributionException {
+ final String[] distributionConfigParameters =
+ { "-c", "parameters/DistributionConfigParameters_EmptyReceptionHandlerClass.json" };
+
+ final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
+ arguments.parse(distributionConfigParameters);
+
+ try {
+ new DistributionParameterHandler().getParameters(arguments);
+ } catch (final Exception e) {
+ assertTrue(e.getMessage().contains("invalid in JSON file"));
+ }
+ }
}
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandlerClass.json b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandlerClass.json
new file mode 100644
index 00000000..ef129fd6
--- /dev/null
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_EmptyReceptionHandlerClass.json
@@ -0,0 +1,54 @@
+{
+ "name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
+ "receptionHandlerParameters":{
+ "DummyReceptionHandler":{
+ "receptionHandlerType":"",
+ "receptionHandlerClassName":"org.onap.policy.distribution.main.testclasses.InvalidSdcReceptionHandler",
+ "receptionHandlerConfigurationName":"dummyReceptionHandlerConfiguration",
+ "pluginHandlerParameters":{
+ "policyDecoders":{
+ "DummyDecoder":{
+ "decoderType":"DummyDecoder",
+ "decoderClassName":"org.onap.policy.distribution.main.testclasses.DummyDecoder"
+ }
+ },
+ "policyForwarders":{
+ "DummyForwarder":{
+ "forwarderType":"DummyForwarder",
+ "forwarderClassName":"org.onap.policy.distribution.main.testclasses.DummyPolicyForwarder",
+ "forwarderConfigurationName": "dummyConfiguration"
+ }
+ }
+ }
+ }
+ },
+ "receptionHandlerConfigurationParameters":{
+ "dummyReceptionHandlerConfiguration":{
+ "parameterClassName":"",
+ "parameters":{
+ "myStringParameter": "stringValue",
+ "myIntegerParameter":20,
+ "myBooleanParameter": true
+ }
+ }
+ },
+ "policyForwarderConfigurationParameters":{
+ "dummyConfiguration":{
+ "parameterClassName":"org.onap.policy.distribution.main.testclasses.DummyPolicyForwarderParameterGroup",
+ "parameters":{
+ "useHttps": false,
+ "hostname": "192.168.99.100",
+ "port": 8081,
+ "userName": "user",
+ "password": "pw123",
+ "isManaged": true
+ }
+ }
+ }
+}
diff --git a/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json
new file mode 100644
index 00000000..d033a730
--- /dev/null
+++ b/main/src/test/resources/parameters/DistributionConfigParameters_InvalidReceptionHandlerClass.json
@@ -0,0 +1,54 @@
+{
+ "name":"SDCDistributionGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34"
+ },
+ "receptionHandlerParameters":{
+ "DummyReceptionHandler":{
+ "receptionHandlerType":"",
+ "receptionHandlerClassName":"org.onap.policy.distribution.main.testclasses.InvalidSdcReceptionHandler",
+ "receptionHandlerConfigurationName":"dummyReceptionHandlerConfiguration",
+ "pluginHandlerParameters":{
+ "policyDecoders":{
+ "DummyDecoder":{
+ "decoderType":"DummyDecoder",
+ "decoderClassName":"org.onap.policy.distribution.main.testclasses.DummyDecoder"
+ }
+ },
+ "policyForwarders":{
+ "DummyForwarder":{
+ "forwarderType":"DummyForwarder",
+ "forwarderClassName":"org.onap.policy.distribution.main.testclasses.DummyPolicyForwarder",
+ "forwarderConfigurationName": "dummyConfiguration"
+ }
+ }
+ }
+ }
+ },
+ "receptionHandlerConfigurationParameters":{
+ "dummyReceptionHandlerConfiguration":{
+ "parameterClassName":"org.onap.policy.distribution.main.testclasses.InvalidReceptionHandlerParameterGroup",
+ "parameters":{
+ "myStringParameter": "stringValue",
+ "myIntegerParameter":20,
+ "myBooleanParameter": true
+ }
+ }
+ },
+ "policyForwarderConfigurationParameters":{
+ "dummyConfiguration":{
+ "parameterClassName":"org.onap.policy.distribution.main.testclasses.DummyPolicyForwarderParameterGroup",
+ "parameters":{
+ "useHttps": false,
+ "hostname": "192.168.99.100",
+ "port": 8081,
+ "userName": "user",
+ "password": "pw123",
+ "isManaged": true
+ }
+ }
+ }
+}
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 0601f4b2..14b0f1ec 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
@@ -66,7 +66,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
@Override
protected void initializeReception(final String parameterGroupName) throws PluginInitializationException {
- handlerParameters = (SdcReceptionHandlerConfigurationParameterGroup) ParameterService.get(parameterGroupName);
+ handlerParameters = ParameterService.get(parameterGroupName);
initializeSdcClient();
startSdcClient();
}
@@ -108,12 +108,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
sdcReceptionHandlerStatus = newStatus;
break;
case IDLE:
- if (nbOfNotificationsOngoing > 1) {
- --nbOfNotificationsOngoing;
- } else {
- nbOfNotificationsOngoing = 0;
- sdcReceptionHandlerStatus = newStatus;
- }
+ handleIdleStatusChange(newStatus);
break;
case BUSY:
++nbOfNotificationsOngoing;
@@ -286,27 +281,24 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
private void sendDistributionStatus(final DistributionStatusType statusType, final String artifactUrl,
final String distributionId, final DistributionStatusEnum status, final String errorReason) {
- IDistributionClientResult clientResult = null;
+ IDistributionClientResult clientResult;
final DistributionStatusMessageBuilder messageBuilder = new DistributionStatusMessageBuilder()
.setArtifactUrl(artifactUrl).setConsumerId(sdcConfig.getConsumerID()).setDistributionId(distributionId)
.setDistributionStatus(status).setTimestamp(System.currentTimeMillis());
final IDistributionStatusMessage message = new DistributionStatusMessage(messageBuilder);
- switch (statusType) {
- case DOWNLOAD:
- if (errorReason != null) {
- clientResult = distributionClient.sendDownloadStatus(message, errorReason);
- } else {
- clientResult = distributionClient.sendDownloadStatus(message);
- }
- break;
- case DEPLOY:
- if (errorReason != null) {
- clientResult = distributionClient.sendDeploymentStatus(message, errorReason);
- } else {
- clientResult = distributionClient.sendDeploymentStatus(message);
- }
+ if (DistributionStatusType.DOWNLOAD.equals(statusType)) {
+ if (errorReason != null) {
+ clientResult = distributionClient.sendDownloadStatus(message, errorReason);
+ } else {
+ clientResult = distributionClient.sendDownloadStatus(message);
+ }
+ } else {
+ if (errorReason != null) {
+ clientResult = distributionClient.sendDeploymentStatus(message, errorReason);
+ } else {
+ clientResult = distributionClient.sendDeploymentStatus(message);
+ }
}
-
final StringBuilder loggerMessage = new StringBuilder();
loggerMessage.append("distribution status to SDC with values - ").append("DistributionId")
.append(distributionId).append(" Artifact: ").append(artifactUrl).append(" StatusType: ")
@@ -332,7 +324,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
*/
private void sendComponentDoneStatus(final String distributionId, final DistributionStatusEnum status,
final String errorReason) {
- IDistributionClientResult clientResult = null;
+ IDistributionClientResult clientResult;
final ComponentDoneStatusMessageBuilder messageBuilder = new ComponentDoneStatusMessageBuilder()
.setConsumerId(sdcConfig.getConsumerID()).setDistributionId(distributionId)
.setDistributionStatus(status).setTimestamp(System.currentTimeMillis());
@@ -357,4 +349,18 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
LOGGER.debug(loggerMessage);
}
}
+
+ /**
+ * Handle the status change of {@link SdcReceptionHandler} to Idle.
+ *
+ * @param newStatus the new status
+ */
+ private void handleIdleStatusChange(final SdcReceptionHandlerStatus newStatus) {
+ if (nbOfNotificationsOngoing > 1) {
+ --nbOfNotificationsOngoing;
+ } else {
+ nbOfNotificationsOngoing = 0;
+ sdcReceptionHandlerStatus = newStatus;
+ }
+ }
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterBuilder.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterBuilder.java
new file mode 100644
index 00000000..34eaf33e
--- /dev/null
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterBuilder.java
@@ -0,0 +1,337 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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=========================================================
+ */
+
+package org.onap.policy.distribution.reception.handling.sdc;
+
+import java.util.List;
+
+/**
+ * This class builds an instance of {@link SdcReceptionHandlerConfigurationParameterGroup} class.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
+ */
+public class SdcReceptionHandlerConfigurationParameterBuilder {
+
+ private boolean activeserverTlsAuth;
+ private boolean filterinEmptyResources;
+ private boolean useHttpsWithDmaap;
+ private int pollingTimeout;
+ private int pollingInterval;
+ private String user;
+ private String password;
+ private String consumerId;
+ private String consumerGroup;
+ private String asdcAddress;
+ private String environmentName;
+ private String keystorePath;
+ private String keystorePassword;
+ private List<String> messageBusAddress;
+ private List<String> artifactTypes;
+
+ /**
+ * Set activeserverTlsAuth to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param activeserverTlsAuth the activeserverTlsAuth
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setActiveserverTlsAuth(final boolean activeserverTlsAuth) {
+ this.activeserverTlsAuth = activeserverTlsAuth;
+ return this;
+ }
+
+ /**
+ * Set filterinEmptyResources to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param filterinEmptyResources the filterinEmptyResources
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setFilterinEmptyResources(
+ final boolean filterinEmptyResources) {
+ this.filterinEmptyResources = filterinEmptyResources;
+ return this;
+ }
+
+ /**
+ * Set useHttpsWithDmaap to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param useHttpsWithDmaap the useHttpsWithDmaap
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setUseHttpsWithDmaap(final Boolean useHttpsWithDmaap) {
+ this.useHttpsWithDmaap = useHttpsWithDmaap;
+ return this;
+ }
+
+ /**
+ * Set pollingInterval to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param pollingInterval the pollingInterval
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setPollingInterval(final int pollingInterval) {
+ this.pollingInterval = pollingInterval;
+ return this;
+ }
+
+ /**
+ * Set pollingTimeout to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param pollingTimeout the pollingTimeout
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setPollingTimeout(final int pollingTimeout) {
+ this.pollingTimeout = pollingTimeout;
+ return this;
+ }
+
+ /**
+ * Set asdcAddress to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param asdcAddress the asdcAddress
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setAsdcAddress(final String asdcAddress) {
+ this.asdcAddress = asdcAddress;
+ return this;
+ }
+
+ /**
+ * Set user to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param user the user
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setUser(final String user) {
+ this.user = user;
+ return this;
+ }
+
+ /**
+ * Set password to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param password the password
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setPassword(final String password) {
+ this.password = password;
+ return this;
+ }
+
+ /**
+ * Set consumerId to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param consumerId the consumerId
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setConsumerId(final String consumerId) {
+ this.consumerId = consumerId;
+ return this;
+ }
+
+ /**
+ * Set consumerGroup to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param consumerGroup the consumerGroup
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setConsumerGroup(final String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ return this;
+ }
+
+ /**
+ * Set environmentName to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param environmentName the environmentName
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setEnvironmentName(final String environmentName) {
+ this.environmentName = environmentName;
+ return this;
+ }
+
+ /**
+ * Set keystorePath to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param keystorePath the keystorePath
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setKeystorePath(final String keystorePath) {
+ this.keystorePath = keystorePath;
+ return this;
+ }
+
+ /**
+ * Set keystorePassword to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param keystorePassword the keystorePassword
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setKeystorePassword(final String keystorePassword) {
+ this.keystorePassword = keystorePassword;
+ return this;
+ }
+
+ /**
+ * Set messageBusAddress to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param messageBusAddress the messageBusAddress
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setMessageBusAddress(final List<String> messageBusAddress) {
+ this.messageBusAddress = messageBusAddress;
+ return this;
+ }
+
+ /**
+ * Set artifactTypes to this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @param artifactTypes the artifactTypes
+ */
+ public SdcReceptionHandlerConfigurationParameterBuilder setArtifactTypes(final List<String> artifactTypes) {
+ this.artifactTypes = artifactTypes;
+ return this;
+ }
+
+ /**
+ * Returns the active server TlsAuth of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the activeserverTlsAuth
+ */
+ public boolean isActiveserverTlsAuth() {
+ return activeserverTlsAuth;
+ }
+
+ /**
+ * Returns the isFilterinEmptyResources flag of this {@link SdcReceptionHandlerConfigurationParameterBuilder}
+ * instance.
+ *
+ * @return the isFilterinEmptyResources
+ */
+ public boolean isFilterinEmptyResources() {
+ return filterinEmptyResources;
+ }
+
+ /**
+ * Returns the isUseHttpsWithDmaap flag of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the isUseHttpsWithDmaap
+ */
+ public Boolean getIsUseHttpsWithDmaap() {
+ return useHttpsWithDmaap;
+ }
+
+ /**
+ * Returns the polling interval of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the pollingInterval
+ */
+ public int getPollingInterval() {
+ return pollingInterval;
+ }
+
+ /**
+ * Returns the polling timeout of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the pollingTimeout
+ */
+ public int getPollingTimeout() {
+ return pollingTimeout;
+ }
+
+ /**
+ * Returns the asdc address of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the asdcAddress
+ */
+ public String getAsdcAddress() {
+ return asdcAddress;
+ }
+
+ /**
+ * Returns the user of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the user
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /**
+ * Returns the password of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * Returns the consumer id of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the consumerId
+ */
+ public String getConsumerId() {
+ return consumerId;
+ }
+
+ /**
+ * Returns the consumer group of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the consumerGroup
+ */
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+ /**
+ * Returns the environment name of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the environmentName
+ */
+ public String getEnvironmentName() {
+ return environmentName;
+ }
+
+ /**
+ * Returns the keystore path of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the keystorePath
+ */
+ public String getKeystorePath() {
+ return keystorePath;
+ }
+
+ /**
+ * Returns the keystore password of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the keystorePassword
+ */
+ public String getKeystorePassword() {
+ return keystorePassword;
+ }
+
+ /**
+ * Returns the message bus address of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the messageBusAddress
+ */
+ public List<String> getMessageBusAddress() {
+ return messageBusAddress;
+ }
+
+ /**
+ * Returns the artifact types of this {@link SdcReceptionHandlerConfigurationParameterBuilder} instance.
+ *
+ * @return the artifactTypes
+ */
+ public List<String> getArtifactTypes() {
+ return artifactTypes;
+ }
+
+}
+
+
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java
index 08fd707c..bbee652a 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandlerConfigurationParameterGroup.java
@@ -34,7 +34,6 @@ import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigu
*/
public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHandlerConfigurationParameterGroup {
- // Interface of IConfiguration item
private String asdcAddress;
private List<String> messageBusAddress;
private String user;
@@ -56,22 +55,23 @@ public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHan
*
* @param builder the SDC configuration builder
*/
- private SdcReceptionHandlerConfigurationParameterGroup(final SdcConfigurationBuilder builder) {
- asdcAddress = builder.asdcAddress;
- messageBusAddress = builder.messageBusAddress;
- user = builder.user;
- password = builder.password;
- pollingInterval = builder.pollingInterval;
- pollingTimeout = builder.pollingTimeout;
- consumerId = builder.consumerId;
- artifactTypes = builder.artifactTypes;
- consumerGroup = builder.consumerGroup;
- environmentName = builder.environmentName;
- keyStorePath = builder.keystorePath;
- keyStorePassword = builder.keystorePassword;
- activeServerTlsAuth = builder.activeserverTlsAuth;
- isFilterInEmptyResources = builder.isFilterinEmptyResources;
- isUseHttpsWithDmaap = builder.isUseHttpsWithDmaap;
+ public SdcReceptionHandlerConfigurationParameterGroup(
+ final SdcReceptionHandlerConfigurationParameterBuilder builder) {
+ asdcAddress = builder.getAsdcAddress();
+ messageBusAddress = builder.getMessageBusAddress();
+ user = builder.getUser();
+ password = builder.getPassword();
+ pollingInterval = builder.getPollingInterval();
+ pollingTimeout = builder.getPollingTimeout();
+ consumerId = builder.getConsumerId();
+ artifactTypes = builder.getArtifactTypes();
+ consumerGroup = builder.getConsumerGroup();
+ environmentName = builder.getEnvironmentName();
+ keyStorePath = builder.getKeystorePath();
+ keyStorePassword = builder.getKeystorePassword();
+ activeServerTlsAuth = builder.isActiveserverTlsAuth();
+ isFilterInEmptyResources = builder.isFilterinEmptyResources();
+ isUseHttpsWithDmaap = builder.getIsUseHttpsWithDmaap();
}
@@ -146,119 +146,6 @@ public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHan
}
/**
- * Inner static class is to used as a Builder.
- *
- */
- public static class SdcConfigurationBuilder {
- private String asdcAddress;
- private List<String> messageBusAddress;
- private String user;
- private String password;
- private int pollingInterval;
- private int pollingTimeout;
- private String consumerId;
- private List<String> artifactTypes;
- private String consumerGroup;
- private String environmentName;
- private String keystorePath;
- private String keystorePassword;
- private boolean activeserverTlsAuth;
- private boolean isFilterinEmptyResources;
- private Boolean isUseHttpsWithDmaap;
-
- public SdcConfigurationBuilder setAsdcAddress(final String val) {
- asdcAddress = val;
- return this;
- }
-
- public SdcConfigurationBuilder setMessageBusAddress(final List<String> val) {
- messageBusAddress = val;
- return this;
- }
-
- public SdcConfigurationBuilder setUser(final String val) {
- user = val;
- return this;
- }
-
- public SdcConfigurationBuilder setPassword(final String val) {
- password = val;
- return this;
- }
-
- public SdcConfigurationBuilder setPollingInterval(final int val) {
- pollingInterval = val;
- return this;
- }
-
- public SdcConfigurationBuilder setPollingTimeout(final int val) {
- pollingTimeout = val;
- return this;
- }
-
- public SdcConfigurationBuilder setConsumerId(final String val) {
- consumerId = val;
- return this;
- }
-
- public SdcConfigurationBuilder setArtifactTypes(final List<String> val) {
- artifactTypes = val;
- return this;
- }
-
- public SdcConfigurationBuilder setConsumerGroup(final String val) {
- consumerGroup = val;
- return this;
- }
-
- public SdcConfigurationBuilder setEnvironmentName(final String val) {
- environmentName = val;
- return this;
- }
-
- public SdcConfigurationBuilder setKeystorePath(final String val) {
- keystorePath = val;
- return this;
- }
-
- public SdcConfigurationBuilder setKeystorePassword(final String val) {
- keystorePassword = val;
- return this;
- }
-
- public SdcConfigurationBuilder setActiveserverTlsAuth(final boolean val) {
- activeserverTlsAuth = val;
- return this;
- }
-
- public SdcConfigurationBuilder setIsFilterinEmptyResources(final boolean val) {
- isFilterinEmptyResources = val;
- return this;
- }
-
- public SdcConfigurationBuilder setIsUseHttpsWithDmaap(final Boolean val) {
- isUseHttpsWithDmaap = val;
- return this;
- }
-
- /**
- * Creates an instance of {@link SdcReceptionHandlerConfigurationParameterGroup}.
- */
- public SdcReceptionHandlerConfigurationParameterGroup build() {
- return new SdcReceptionHandlerConfigurationParameterGroup(this);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "name =" + getName() + ",TestParameters:[asdcAddress = " + asdcAddress + ", messageBusAddress = "
- + messageBusAddress + ", user = " + user + "]";
- }
-
- /**
* {@inheritDoc}
*/
@Override
@@ -301,15 +188,10 @@ public class SdcReceptionHandlerConfigurationParameterGroup extends ReceptionHan
*/
private void validateStringListElement(final GroupValidationResult validationResult, final List<String> element,
final String elementName) {
- if (element == null) {
- validationResult.setResult(elementName, ValidationStatus.INVALID,
- elementName + " must be a list of non-blank string");
- } else {
- for (final String temp : element) {
- if (!ParameterValidationUtils.validateStringParameter(temp)) {
- validationResult.setResult(elementName, ValidationStatus.INVALID,
- "the string of " + elementName + "must be a non-blank string");
- }
+ for (final String temp : element) {
+ if (!ParameterValidationUtils.validateStringParameter(temp)) {
+ validationResult.setResult(elementName, ValidationStatus.INVALID,
+ "the string of " + elementName + "must be a non-blank string");
}
}
}
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcConfiguration.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcConfiguration.java
deleted file mode 100644
index 65d7ca10..00000000
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcConfiguration.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Intel. 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=========================================================
- */
-
-package org.onap.policy.distribution.reception.handling.sdc;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.junit.Test;
-import org.onap.policy.common.parameters.GroupValidationResult;
-
-/**
- * Class to perform unit test of {@link SdcConfiguration}.
- *
- */
-public class TestSdcConfiguration {
-
- @Test
- public void testSdcConfiguration() throws IOException {
- SdcReceptionHandlerConfigurationParameterGroup configParameters = null;
- try {
- final Gson gson = new GsonBuilder().create();
- configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"),
- SdcReceptionHandlerConfigurationParameterGroup.class);
- } catch (final Exception e) {
- fail("test should not thrown an exception here: " + e.getMessage());
- }
- final GroupValidationResult validationResult = configParameters.validate();
- assertTrue(validationResult.isValid());
- final SdcConfiguration config = new SdcConfiguration(configParameters);
- assertEquals(Arrays.asList("a.com", "b.com", "c.com"), config.getMsgBusAddress());
- assertEquals(Arrays.asList("TOSCA_CSAR", "HEAT"), config.getRelevantArtifactTypes());
- assertEquals("localhost", config.getAsdcAddress());
- assertEquals("policy", config.getUser());
- assertEquals("policy", config.getPassword());
- assertEquals(20, config.getPollingInterval());
- assertEquals(30, config.getPollingTimeout());
- assertEquals("policy-id", config.getConsumerID());
- assertEquals("policy-group", config.getConsumerGroup());
- assertEquals("TEST", config.getEnvironmentName());
- assertEquals("null", config.getKeyStorePath());
- assertEquals("null", config.getKeyStorePassword());
- assertEquals(false, config.activateServerTLSAuth());
- assertEquals(true, config.isFilterInEmptyResources());
- assertEquals(false, config.isUseHttpsWithDmaap());
- }
-
- @Test
- public void testInvalidSdcConfiguration() throws IOException {
- SdcReceptionHandlerConfigurationParameterGroup configParameters = null;
- try {
- final Gson gson = new GsonBuilder().create();
- configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"),
- SdcReceptionHandlerConfigurationParameterGroup.class);
- } catch (final Exception e) {
- fail("test should not thrown an exception here: " + e.getMessage());
- }
- final GroupValidationResult validationResult = configParameters.validate();
- assertFalse(validationResult.isValid());
-
- }
-}
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java
new file mode 100644
index 00000000..df72d45c
--- /dev/null
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java
@@ -0,0 +1,159 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Intel. 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=========================================================
+ */
+
+package org.onap.policy.distribution.reception.handling.sdc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.junit.Test;
+import org.onap.policy.common.parameters.GroupValidationResult;
+
+/**
+ * Class to perform unit test of {@link SdcConfiguration}.
+ *
+ */
+public class TestSdcReceptionHandlerConfigurationParameterGroup {
+
+ @Test
+ public void testSdcConfiguration() throws IOException {
+ SdcReceptionHandlerConfigurationParameterGroup configParameters = null;
+ try {
+ final Gson gson = new GsonBuilder().create();
+ configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"),
+ SdcReceptionHandlerConfigurationParameterGroup.class);
+ } catch (final Exception e) {
+ fail("test should not thrown an exception here: " + e.getMessage());
+ }
+ final GroupValidationResult validationResult = configParameters.validate();
+ assertTrue(validationResult.isValid());
+ final SdcConfiguration config = new SdcConfiguration(configParameters);
+ assertEquals(Arrays.asList("a.com", "b.com", "c.com"), config.getMsgBusAddress());
+ assertEquals(Arrays.asList("TOSCA_CSAR", "HEAT"), config.getRelevantArtifactTypes());
+ assertEquals("localhost", config.getAsdcAddress());
+ assertEquals("policy", config.getUser());
+ assertEquals("policy", config.getPassword());
+ assertEquals(20, config.getPollingInterval());
+ assertEquals(30, config.getPollingTimeout());
+ assertEquals("policy-id", config.getConsumerID());
+ assertEquals("policy-group", config.getConsumerGroup());
+ assertEquals("TEST", config.getEnvironmentName());
+ assertEquals("null", config.getKeyStorePath());
+ assertEquals("null", config.getKeyStorePassword());
+ assertEquals(false, config.activateServerTLSAuth());
+ assertEquals(true, config.isFilterInEmptyResources());
+ assertEquals(false, config.isUseHttpsWithDmaap());
+ }
+
+ @Test
+ public void testInvalidSdcConfiguration() throws IOException {
+ SdcReceptionHandlerConfigurationParameterGroup configParameters = null;
+ try {
+ final Gson gson = new GsonBuilder().create();
+ configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"),
+ SdcReceptionHandlerConfigurationParameterGroup.class);
+ } catch (final Exception e) {
+ fail("test should not thrown an exception here: " + e.getMessage());
+ }
+ final GroupValidationResult validationResult = configParameters.validate();
+ assertFalse(validationResult.isValid());
+ }
+
+ @Test
+ public void testSdcConfigurationBuilder() {
+
+ final SdcReceptionHandlerConfigurationParameterBuilder builder =
+ new SdcReceptionHandlerConfigurationParameterBuilder().setAsdcAddress("localhost")
+ .setConsumerGroup("policy-group").setConsumerId("policy-id").setEnvironmentName("TEST")
+ .setKeystorePassword("password").setKeystorePath("dummyPath").setPassword("policy")
+ .setPollingInterval(10).setPollingTimeout(20).setUser("policy").setUseHttpsWithDmaap(false)
+ .setActiveserverTlsAuth(false).setFilterinEmptyResources(true)
+ .setArtifactTypes(Arrays.asList("TOSCA_CSAR")).setMessageBusAddress(Arrays.asList("localhost"));
+ final SdcReceptionHandlerConfigurationParameterGroup configParameters =
+ new SdcReceptionHandlerConfigurationParameterGroup(builder);
+ configParameters.setName("SDCConfiguration");
+
+ assertEquals(Arrays.asList("localhost"), configParameters.getMessageBusAddress());
+ assertEquals(Arrays.asList("TOSCA_CSAR"), configParameters.getArtifactTypes());
+ assertEquals("localhost", configParameters.getAsdcAddress());
+ assertEquals("policy", configParameters.getUser());
+ assertEquals("policy", configParameters.getPassword());
+ assertEquals(10, configParameters.getPollingInterval());
+ assertEquals(20, configParameters.getPollingTimeout());
+ assertEquals("policy-id", configParameters.getConsumerId());
+ assertEquals("policy-group", configParameters.getConsumerGroup());
+ assertEquals("TEST", configParameters.getEnvironmentName());
+ assertEquals("dummyPath", configParameters.getKeyStorePath());
+ assertEquals("password", configParameters.getKeyStorePassword());
+ assertEquals(false, configParameters.isActiveServerTlsAuth());
+ assertEquals(true, configParameters.isFilterInEmptyResources());
+ assertEquals(false, configParameters.isUseHttpsWithDmaap());
+ }
+
+ @Test
+ public void testSdcConfigurationWithNullList() {
+
+ final SdcReceptionHandlerConfigurationParameterBuilder builder =
+ new SdcReceptionHandlerConfigurationParameterBuilder().setAsdcAddress("localhost")
+ .setConsumerGroup("policy-group").setConsumerId("policy-id").setEnvironmentName("TEST")
+ .setKeystorePassword("password").setKeystorePath("dummyPath").setPassword("policy")
+ .setPollingInterval(10).setPollingTimeout(20).setUser("policy").setUseHttpsWithDmaap(false)
+ .setActiveserverTlsAuth(false).setFilterinEmptyResources(true)
+ .setArtifactTypes(Arrays.asList("TOSCA_CSAR")).setMessageBusAddress(null);
+ final SdcReceptionHandlerConfigurationParameterGroup configParameters =
+ new SdcReceptionHandlerConfigurationParameterGroup(builder);
+ configParameters.setName("SDCConfiguration");
+
+ try {
+ configParameters.validate();
+ fail("Test must throw an exception");
+ } catch (final Exception exp) {
+ assertTrue(exp.getMessage().contains("collection parameter \"messageBusAddress\" is null"));
+ }
+ }
+
+ @Test
+ public void testSdcConfigurationWithEmptyStringList() {
+
+ final SdcReceptionHandlerConfigurationParameterBuilder builder =
+ new SdcReceptionHandlerConfigurationParameterBuilder().setAsdcAddress("localhost")
+ .setConsumerGroup("policy-group").setConsumerId("policy-id").setEnvironmentName("TEST")
+ .setKeystorePassword("password").setKeystorePath("dummyPath").setPassword("policy")
+ .setPollingInterval(10).setPollingTimeout(20).setUser("policy").setUseHttpsWithDmaap(false)
+ .setActiveserverTlsAuth(false).setFilterinEmptyResources(true)
+ .setArtifactTypes(Arrays.asList("")).setMessageBusAddress(Arrays.asList("localhost"));
+ final SdcReceptionHandlerConfigurationParameterGroup configParameters =
+ new SdcReceptionHandlerConfigurationParameterGroup(builder);
+ configParameters.setName("SDCConfiguration");
+
+ final GroupValidationResult validationResult = configParameters.validate();
+ assertFalse(validationResult.isValid());
+ assertTrue(validationResult.getResult().contains("must be a non-blank string"));
+ }
+}
diff --git a/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json b/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json
index 112879f4..803fc412 100644
--- a/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json
+++ b/plugins/reception-plugins/src/test/resources/handling-sdcInvalid.json
@@ -1,6 +1,6 @@
{
"name" : "parameterConfig1",
- "asdcAddress": "localhost",
+ "asdcAddress": "",
"messageBusAddress": [
"a.com",
"b.com",