summaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org
diff options
context:
space:
mode:
authorliboNet <libo.zhu@intel.com>2018-08-18 03:15:59 +0800
committerliboNet <libo.zhu@intel.com>2018-08-22 09:57:45 +0800
commit742c4b2ed82860e2a74f3db3b2048173fbc530d8 (patch)
treec663025f715682863056730c7dbccd8fd522ded7 /main/src/test/java/org
parent612196451afe9b16b8914858dd58f3bb0dae8579 (diff)
integrate PSSDConfiguration to distribution
* 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>
Diffstat (limited to 'main/src/test/java/org')
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java33
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyDecoderParameters.java3
-rw-r--r--main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java47
3 files changed, 70 insertions, 13 deletions
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java
index 54716fc8..0903b070 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/CommonTestData.java
@@ -20,10 +20,13 @@
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;
@@ -61,15 +64,43 @@ public class CommonTestData {
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.
*
* @param isEmpty boolean value to represent that object created should be empty or not
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyDecoderParameters.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyDecoderParameters.java
index 35acdf2e..c2ab38d8 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyDecoderParameters.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyDecoderParameters.java
@@ -84,7 +84,8 @@ public class TestPolicyDecoderParameters {
@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());
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java
index 10faed8c..c902c9b5 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestReceptionHandlerParameters.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
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;
@@ -41,11 +42,15 @@ public class TestReceptionHandlerParameters {
@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());
}
@@ -53,11 +58,15 @@ public class TestReceptionHandlerParameters {
@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()
@@ -68,11 +77,15 @@ public class TestReceptionHandlerParameters {
@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()
@@ -83,9 +96,11 @@ public class TestReceptionHandlerParameters {
@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());
@@ -99,11 +114,14 @@ public class TestReceptionHandlerParameters {
@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()
@@ -115,8 +133,11 @@ public class TestReceptionHandlerParameters {
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) {
@@ -127,12 +148,16 @@ public class TestReceptionHandlerParameters {
@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"));