* Integrate the PSSDConfiguration to distribution config parameter.
* Moved related PSSDConfigurationParameterGroup classes from "handling"
to "parameters" to avoid specified sdc dependency.
* Modify all the test case since the distribution config parameter
has been changed, update CommonTestData to wrap it.
* Add neccessnary SDC handling exceptions which to be used for
SDC handler integration.
* update the PSSDCOnfiguraitonParameterGroup to add UUID to the setName
function to generate unique name for each instance.
* use builder to create PSSDConfigurationParametersGroup instead of using
many parameters
Change-Id: I3c78bc2a51ebc84761bc9458096d6ffa18070b47
Issue-ID: POLICY-956
Signed-off-by: liboNet <libo.zhu@intel.com>
for (final ReceptionHandlerParameters params : distributionParameterGroup.getReceptionHandlerParameters()
.values()) {
params.setName(distributionParameterGroup.getName());
+ params.getPSSDConfigurationParametersGroup().setName(distributionParameterGroup.getName());
params.getPluginHandlerParameters().setName(distributionParameterGroup.getName());
ParameterService.register(params);
+ ParameterService.register(params.getPSSDConfigurationParametersGroup());
ParameterService.register(params.getPluginHandlerParameters());
}
}
params.setName(distributionParameterGroup.getName());
params.getPluginHandlerParameters().setName(distributionParameterGroup.getName());
ParameterService.deregister((params.getName()));
+ ParameterService.deregister((params.getPSSDConfigurationParametersGroup().getName()));
ParameterService.deregister((params.getPluginHandlerParameters().getName()));
}
}
package org.onap.policy.distribution.main.parameters;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
+import org.onap.policy.distribution.reception.parameters.PSSDConfigurationParametersGroup;
import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
if (!isEmpty) {
final Map<String, PolicyDecoderParameters> policyDecoders = getPolicyDecoders(isEmpty);
final Map<String, PolicyForwarderParameters> policyForwarders = getPolicyForwarders(isEmpty);
+ final PSSDConfigurationParametersGroup pssdConfiguration = getPSSDConfigurationParametersGroup(isEmpty);;
final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
final ReceptionHandlerParameters rhParameters =
- new ReceptionHandlerParameters(RECEPTION_HANDLER_TYPE, RECEPTION_HANDLER_CLASS_NAME, pHParameters);
+ new ReceptionHandlerParameters(RECEPTION_HANDLER_TYPE, RECEPTION_HANDLER_CLASS_NAME,
+ pssdConfiguration, pHParameters);
receptionHandlerParameters.put(SDC_RECEPTION_HANDLER_KEY, rhParameters);
}
return receptionHandlerParameters;
}
+ /**
+ * Returns an instance of PSSDConfigurationParametersGroup for test cases.
+ *
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @return the PSSDConfigurationParametersGroup object
+ */
+ public PSSDConfigurationParametersGroup getPSSDConfigurationParametersGroup(final boolean isEmpty) {
+ final PSSDConfigurationParametersGroup pssdConfiguration;
+ if (!isEmpty) {
+ final List<String> messageBusAddress = new ArrayList<>();
+ messageBusAddress.add("localhost");
+ final List<String> artifactTypes = new ArrayList<>();
+ artifactTypes.add("TOSCA_CSAR");
+ pssdConfiguration = new PSSDConfigurationParametersGroup.PSSDConfigurationBuilder()
+ .setAsdcAddress("localhost").setMessageBusAddress(messageBusAddress)
+ .setUser("policy").setPassword("policy").setPollingInterval(20)
+ .setPollingTimeout(30).setConsumerId("policy-id").setArtifactTypes(artifactTypes)
+ .setConsumerGroup("policy-group").setEnvironmentName("TEST").setKeystorePath("")
+ .setKeystorePassword("").setActiveserverTlsAuth(false)
+ .setIsFilterinEmptyResources(true).setIsUseHttpsWithDmaap(false).build();
+ } else {
+ pssdConfiguration = new PSSDConfigurationParametersGroup.PSSDConfigurationBuilder().build();
+ }
+ return pssdConfiguration;
+ }
+
/**
* Returns an instance of PluginHandlerParameters for test cases.
*
@Test
public void testPolicyDecoderParameters_NullDecoderType() {
- final PolicyDecoderParameters pDParameters = new PolicyDecoderParameters(null, CommonTestData.DECODER_CLASS_NAME);
+ final PolicyDecoderParameters pDParameters =
+ new PolicyDecoderParameters(null, CommonTestData.DECODER_CLASS_NAME);
final GroupValidationResult validationResult = pDParameters.validate();
assertEquals(null, pDParameters.getDecoderType());
assertEquals(CommonTestData.DECODER_CLASS_NAME, pDParameters.getDecoderClassName());
import org.junit.Test;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.distribution.reception.parameters.PSSDConfigurationParametersGroup;
import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
@Test
public void testReceptionHandlerParameters() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
- CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pHParameters);
+ final PSSDConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPSSDConfigurationParametersGroup(false);
+ final ReceptionHandlerParameters rHParameters =
+ new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE,
+ CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
+ assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertTrue(validationResult.isValid());
}
@Test
public void testReceptionHandlerParameters_NullReceptionHandlerType() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
+ final PSSDConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPSSDConfigurationParametersGroup(false);
final ReceptionHandlerParameters rHParameters =
- new ReceptionHandlerParameters(null, CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pHParameters);
+ new ReceptionHandlerParameters(null, CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
+ pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(null, rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
+ assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
@Test
public void testReceptionHandlerParameters_NullReceptionHandlerClassName() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
+ final PSSDConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPSSDConfigurationParametersGroup(false);
final ReceptionHandlerParameters rHParameters =
- new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE, null, pHParameters);
+ new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE, null,
+ pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals(null, rHParameters.getReceptionHandlerClassName());
+ assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
@Test
public void testReceptionHandlerParameters_EmptyReceptionHandlerType() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
-
+ final PSSDConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPSSDConfigurationParametersGroup(false);
final ReceptionHandlerParameters rHParameters =
- new ReceptionHandlerParameters("", CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pHParameters);
+ new ReceptionHandlerParameters("", CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
+ pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals("", rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
@Test
public void testReceptionHandlerParameters_EmptyReceptionHandlerClassName() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final ReceptionHandlerParameters rHParameters =
- new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE, "", pHParameters);
+ final PSSDConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPSSDConfigurationParametersGroup(false);
+ final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
+ CommonTestData.RECEPTION_HANDLER_TYPE, "", pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals("", rHParameters.getReceptionHandlerClassName());
+ assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult()
public void testReceptionHandlerParameters_EmptyPluginHandler() {
try {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(true);
+ final PSSDConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPSSDConfigurationParametersGroup(false);
final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
- CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME, pHParameters);
+ CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
+ pssdConfiguration, pHParameters);
rHParameters.validate();
fail("test should throw an exception here");
} catch (final Exception e) {
@Test
public void testReceptionHandlerParameters_InvalidReceptionHandlerClass() {
final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
+ final PSSDConfigurationParametersGroup pssdConfiguration =
+ commonTestData.getPSSDConfigurationParametersGroup(false);
final ReceptionHandlerParameters rHParameters =
new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE,
- CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid", pHParameters);
+ CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid", pssdConfiguration, pHParameters);
final GroupValidationResult validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
- assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid", rHParameters.getReceptionHandlerClassName());
+ assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid",
+ rHParameters.getReceptionHandlerClassName());
+ assertEquals(pssdConfiguration, rHParameters.getPSSDConfigurationParametersGroup());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
assertFalse(validationResult.isValid());
assertTrue(validationResult.getResult().contains("reception handler class not found in classpath"));
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyDecoders":{
"TOSCADecoder":{
}
}
}
-}
\ No newline at end of file
+}
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyDecoders":{
},
}
}
}
-}
\ No newline at end of file
+}
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyDecoders":{
"TOSCADecoder":{
}
}
}
-}
\ No newline at end of file
+}
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyDecoders":{
"TOSCADecoder":{
}
}
}
-}
\ No newline at end of file
+}
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyDecoders":{
"TOSCADecoder":{
}
}
}
-}
\ No newline at end of file
+}
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyDecoders":{
"TOSCADecoder":{
}
}
}
-}
\ No newline at end of file
+}
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyDecoders":{
"TOSCADecoder":{
}
}
}
-}
\ No newline at end of file
+}
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyDecoders":{
"TOSCADecoder":{
}
}
}
-}
\ No newline at end of file
+}
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.InvalidSdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyDecoders":{
"TOSCADecoder":{
}
}
}
-}
\ No newline at end of file
+}
"SDCReceptionHandler":{
"receptionHandlerType":" ",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyDecoders":{
"TOSCADecoder":{
}
}
}
-}
\ No newline at end of file
+}
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyForwarders":{
"PAPEngineForwarder":{
}
}
}
-}
\ No newline at end of file
+}
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyDecoders":{
"TOSCADecoder":{
}
}
}
-}
\ No newline at end of file
+}
"SDCReceptionHandler":{
"receptionHandlerType":"SDC",
"receptionHandlerClassName":"org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandler",
+ "pssdConfiguration":{
+ "asdcAddress": "localhost",
+ "messageBusAddress": [
+ "a.com",
+ "b.com",
+ "c.com"
+ ],
+ "user": "tbdsdc-1480",
+ "password": "tbdsdc-1480",
+ "pollingInterval":20,
+ "pollingTimeout":30,
+ "consumerId": "policy-id",
+ "artifactTypes": [
+ "TOSCA_CSAR",
+ "HEAT"
+ ],
+ "consumerGroup": "policy-group",
+ "environmentName": "environmentName",
+ "keystorePath": "null",
+ "keystorePassword": "null",
+ "activeserverTlsAuth": false,
+ "isFilterinEmptyResources": true,
+ "isUseHttpsWithDmaap": false
+ },
"pluginHandlerParameters":{
"policyDecoders":{
"TOSCADecoder":{
}
}
}
-}
\ No newline at end of file
+}
import java.util.List;
import org.onap.sdc.api.consumer.IConfiguration;
+import org.onap.policy.distribution.reception.parameters.PSSDConfigurationParametersGroup;
/**
* Properties for the handling Sdc
--- /dev/null
+/*-
+ * ============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.exceptions;
+
+
+/**
+ * Exception during artifact installation.
+ */
+public class ArtifactInstallerException extends Exception {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = -8507246953751956974L;
+
+ /**
+ * Constructor for creating ArtifactInstallerException using message.
+ *
+ * @param message The message to dump
+ */
+ public ArtifactInstallerException (final String message) {
+ super (message);
+
+ }
+
+ /**
+ * Constructor for creating ArtifactInstallerException using message and exception.
+ *
+ * @param message The message to dump
+ * @param e the exception that caused this exception to be thrown
+ */
+ public ArtifactInstallerException (final String message, final Exception e) {
+ super (message, e);
+
+ }
+}
--- /dev/null
+/*-
+ * ============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.exceptions;
+
+
+/**
+ * Exception of the PSSD controller.
+ */
+public class PSSDControllerException extends Exception {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = -8507246953751956974L;
+
+ /**
+ * Constructor for creating PSSDControllerException using message.
+ *
+ * @param message The message to dump
+ */
+ public PSSDControllerException (final String message) {
+ super (message);
+
+ }
+
+ /**
+ * Constructor for creating PSSDControllerException using message and exception.
+ *
+ * @param message The message to dump
+ * @param e the exception that caused this exception to be thrown
+ */
+ public PSSDControllerException (final String message, final Exception e) {
+ super (message, e);
+
+ }
+}
--- /dev/null
+/*-
+ * ============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.exceptions;
+
+
+/**
+ * Exception during download from PSSD.
+ */
+public class PSSDDownloadException extends Exception {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = -8507246953751956974L;
+
+ /**
+ * Constructor for creating PSSDDownloadException using message.
+ *
+ * @param message The message to dump
+ */
+ public PSSDDownloadException (final String message) {
+ super (message);
+
+ }
+
+ /**
+ * Constructor for creating PSSDDownloadException using message and exception.
+ *
+ * @param message The message to dump
+ * @param e the exception that caused this exception to be thrown
+ */
+ public PSSDDownloadException (final String message, final Exception e) {
+ super (message, e);
+
+ }
+}
--- /dev/null
+/*-
+ * ============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.exceptions;
+
+
+/**
+ * Exception of the PSSD controller.
+ */
+public class PSSDParametersException extends Exception {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = -8507246953751956974L;
+
+ /**
+ * Constructor for creating PSSDParametersException using message.
+ *
+ * @param message The message to dump
+ */
+ public PSSDParametersException (final String message) {
+ super (message);
+
+ }
+
+ /**
+ * Constructor for creating PSSDParametersException using message and exception.
+ *
+ * @param message The message to dump
+ * @param e the exception that caused this exception to be thrown
+ */
+ public PSSDParametersException (final String message, final Exception e) {
+ super (message, e);
+
+ }
+}
import java.io.IOException;
import org.junit.Test;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.distribution.reception.parameters.PSSDConfigurationParametersGroup;
/*-
* Tests for PSSDConfiguration class
}
final GroupValidationResult validationResult = configParameters.validate();
assertTrue(validationResult.isValid());
- assertEquals("parameterConfig1", configParameters.getName());
-
PSSDConfiguration config = new PSSDConfiguration(configParameters);
assertEquals(20, config.getPollingInterval());
assertEquals(30,config.getPollingTimeout());
}
final GroupValidationResult validationResult = configParameters.validate();
assertFalse(validationResult.isValid());
- assertEquals("parameterConfig1", configParameters.getName());
}
}
--- /dev/null
+/*-
+ * ============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.exceptions;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+public class ArtifactInstallerExceptionTest {
+
+ @Test
+ public void test() {
+ assertNotNull(new ArtifactInstallerException("Message"));
+ assertNotNull(new ArtifactInstallerException("Message", new IOException()));
+ }
+}
--- /dev/null
+/*-
+ * ============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.exceptions;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+public class PSSDControllerExceptionTest {
+
+ @Test
+ public void test() {
+ assertNotNull(new PSSDControllerException("Message"));
+ assertNotNull(new PSSDControllerException("Message", new IOException()));
+ }
+}
--- /dev/null
+/*-
+ * ============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.exceptions;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+public class PSSDDownloadExceptionTest {
+
+ @Test
+ public void test() {
+ assertNotNull(new PSSDDownloadException("Message"));
+ assertNotNull(new PSSDDownloadException("Message", new IOException()));
+ }
+}
--- /dev/null
+/*-
+ * ============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.exceptions;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+public class PSSDParametersExceptionTest {
+
+ @Test
+ public void test() {
+ assertNotNull(new PSSDParametersException("Message"));
+ assertNotNull(new PSSDParametersException("Message", new IOException()));
+ }
+}
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
+package org.onap.policy.distribution.reception.parameters;
-package org.onap.policy.distribution.reception.handling.sdc;
-
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterGroup;
* format, which strictly adheres to the interface:IConfiguration, defined by SDC SDK.
*/
public class PSSDConfigurationParametersGroup implements ParameterGroup {
+
// Policy SDC Service Distribution specified field.
private String name;
private boolean isFilterinEmptyResources;
private Boolean isUseHttpsWithDmaap;
+ /**
+ *Inner static class is to used as a Builder
+ *
+ */
+ public static class PSSDConfigurationBuilder {
+ 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 PSSDConfigurationBuilder setAsdcAddress(String val)
+ { asdcAddress = val; return this; }
+ public PSSDConfigurationBuilder setMessageBusAddress(List<String> val)
+ { messageBusAddress = val; return this; }
+ public PSSDConfigurationBuilder setUser(String val)
+ { user = val; return this; }
+ public PSSDConfigurationBuilder setPassword(String val)
+ { password = val; return this; }
+ public PSSDConfigurationBuilder setPollingInterval(int val)
+ { pollingInterval = val; return this; }
+ public PSSDConfigurationBuilder setPollingTimeout(int val)
+ { pollingTimeout = val; return this; }
+ public PSSDConfigurationBuilder setConsumerId(String val)
+ { consumerId = val; return this; }
+ public PSSDConfigurationBuilder setArtifactTypes(List<String> val)
+ { artifactTypes = val; return this; }
+ public PSSDConfigurationBuilder setConsumerGroup(String val)
+ { consumerGroup = val; return this; }
+ public PSSDConfigurationBuilder setEnvironmentName(String val)
+ { environmentName = val; return this; }
+ public PSSDConfigurationBuilder setKeystorePath(String val)
+ { keystorePath = val; return this; }
+ public PSSDConfigurationBuilder setKeystorePassword(String val)
+ { keystorePassword = val; return this; }
+ public PSSDConfigurationBuilder setActiveserverTlsAuth(boolean val)
+ { activeserverTlsAuth = val; return this; }
+ public PSSDConfigurationBuilder setIsFilterinEmptyResources(boolean val)
+ { isFilterinEmptyResources = val; return this; }
+ public PSSDConfigurationBuilder setIsUseHttpsWithDmaap(Boolean val)
+ { isUseHttpsWithDmaap = val; return this; }
+
+
+ /**
+ * it is to create a new PSSDConfigurationParametersGroup instance.
+ */
+ public PSSDConfigurationParametersGroup build() {
+ return new PSSDConfigurationParametersGroup(this);
+ }
+ }
+
+ /**
+ * The constructor for instantiating PSSDConfigurationParametersGroup it is a private
+ * so that it could ONLY be instantiated by PSSDConfigurationBuilder
+ *
+ * @param builder stores all the values used by PSSDConfigurationParametersGroup
+ */
+ private PSSDConfigurationParametersGroup(PSSDConfigurationBuilder 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 String getAsdcAddress() {
return asdcAddress;
}
@Override
public String getName() {
- return name;
+ return name ;
}
@Override
public GroupValidationResult validate() {
final GroupValidationResult validationResult = new GroupValidationResult(this);
- if (name == null || name.trim().length() == 0) {
- validationResult.setResult("name", ValidationStatus.INVALID, "name must be a non-blank string");
- }
-
if (asdcAddress == null || asdcAddress.trim().length() == 0) {
validationResult.setResult("asdcAddress", ValidationStatus.INVALID,
"asdcAddress must be a non-blank string");
return validationResult;
}
+ /**
+ * Set the name of this group.
+ *
+ * @param name the name to set.
+ */
+ public void setName(final String name) {
+ this.name = name + "_" + UUID.randomUUID().toString();
+ }
}
private String name;
private String receptionHandlerType;
private String receptionHandlerClassName;
+ private PSSDConfigurationParametersGroup pssdConfiguration;
private PluginHandlerParameters pluginHandlerParameters;
/**
* @param receptionHandlerClassName the reception handler class name
* @param pluginHandlerParameters the plugin handler parameters
*/
- public ReceptionHandlerParameters(final String receptionHandlerType, final String receptionHandlerClassName,
- final PluginHandlerParameters pluginHandlerParameters) {
+ public ReceptionHandlerParameters(final String receptionHandlerType, final String receptionHandlerClassName,
+ final PSSDConfigurationParametersGroup pssdConfiguration,
+ final PluginHandlerParameters pluginHandlerParameters) {
this.receptionHandlerType = receptionHandlerType;
this.receptionHandlerClassName = receptionHandlerClassName;
+ this.pssdConfiguration = pssdConfiguration;
this.pluginHandlerParameters = pluginHandlerParameters;
}
return receptionHandlerClassName;
}
+ /**
+ * Return the PSSDConfigurationParametersGroup of this ReceptionHandlerParameters instance.
+ *
+ * @return the PSSDConfigurationParametersGroup
+ */
+ public PSSDConfigurationParametersGroup getPSSDConfigurationParametersGroup() {
+ return pssdConfiguration;
+ }
+
/**
* Return the pluginHandlerParameters of this ReceptionHandlerParameters instance.
*