aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/reception-plugins/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/reception-plugins/src/test/java')
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/CommonTestData.java53
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java25
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxConfigurationParameterGroup.java31
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroupTest.java32
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyTest.java21
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java22
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java77
7 files changed, 124 insertions, 137 deletions
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/CommonTestData.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/CommonTestData.java
new file mode 100644
index 00000000..5006e078
--- /dev/null
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/CommonTestData.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.decoding.pdpx;
+
+import java.io.File;
+
+import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+
+/**
+ * Class to create parameters for test cases.
+ *
+ * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
+ */
+public class CommonTestData {
+
+ public static final Coder coder = new StandardCoder();
+
+ /**
+ * Returns PolicyDecoderParameters for test cases.
+ *
+ * @param fileName the file name to load the parameters
+ * @param clazz the parameter class to be returned
+ * @return the specific PolicyDecoderParameters object
+ */
+ public static <T> T getPolicyDecoderParameters(final String fileName, final Class<T> clazz) {
+ final StandardCoder coder = new StandardCoder();
+ try {
+ return coder.decode(new File(fileName), clazz);
+ } catch (final CoderException exp) {
+ throw new RuntimeException("cannot read/decode " + fileName, exp);
+ }
+ }
+}
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java
index 0cd8b6f4..9cfbaf80 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpx.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,17 +42,15 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
*/
public class TestPolicyDecoderCsarPdpx {
- private static final String CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION = "csarToOptimizationPolicyConfiguration";
-
/**
* Set up for test cases.
*/
@BeforeClass
public static void setUp() {
- final ParameterGroup parameterGroup = new PolicyDecoderCsarPdpxConfigurationParameterBuilder()
- .setOnapName("onapName").setPolicyNamePrefix("OOF").setPriority("5").setRiskLevel("2")
- .setRiskType("Test").setVersion("1.0").build();
- parameterGroup.setName(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
+ final ParameterGroup parameterGroup = CommonTestData.getPolicyDecoderParameters(
+ "src/test/resources/parameters/PdpxPolicyDecoderParameters.json",
+ PolicyDecoderCsarPdpxConfigurationParameterGroup.class);
+ parameterGroup.setName(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
ParameterService.register(parameterGroup);
}
@@ -60,14 +59,14 @@ public class TestPolicyDecoderCsarPdpx {
*/
@AfterClass
public static void tearDown() {
- ParameterService.deregister(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
+ ParameterService.deregister(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
}
@Test
public void testHpaPolicy2Vnf() throws IOException, PolicyDecodingException {
final Csar csar = new Csar("src/test/resources/service-TestNs8-csar.csar");
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
- policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
+ policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
final Collection<ToscaServiceTemplate> ret = policyDecoderCsarPdpx.decode(csar);
@@ -98,7 +97,7 @@ public class TestPolicyDecoderCsarPdpx {
public void testHpaPolicySriov() throws IOException, PolicyDecodingException {
final Csar csar = new Csar("src/test/resources/hpaPolicySriov.csar");
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
- policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
+ policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
final ToscaServiceTemplate policy = (ToscaServiceTemplate) policies.toArray()[0];
@@ -138,7 +137,7 @@ public class TestPolicyDecoderCsarPdpx {
public void testHpaPolicyPciePassthrough() throws IOException, PolicyDecodingException {
final Csar csar = new Csar("src/test/resources/hpaPolicyPciePassthrough.csar");
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
- policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
+ policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
assertEquals(2, policies.size());
@@ -181,7 +180,7 @@ public class TestPolicyDecoderCsarPdpx {
public void testHpaPolicyHugePage() throws IOException, PolicyDecodingException {
final Csar csar = new Csar("src/test/resources/hpaPolicyHugePage.csar");
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
- policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
+ policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
assertEquals(2, policies.size());
@@ -214,7 +213,7 @@ public class TestPolicyDecoderCsarPdpx {
public void testS3p0PciVendorId() throws IOException, PolicyDecodingException {
final Csar csar = new Csar("src/test/resources/s3p_0_pciVendorId.csar");
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
- policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
+ policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
assertEquals(1, policies.size());
@@ -248,7 +247,7 @@ public class TestPolicyDecoderCsarPdpx {
public void testserviceVcpeWithAll() throws IOException, PolicyDecodingException {
final Csar csar = new Csar("src/test/resources/service-VcpeWithAll-csar.csar");
final PolicyDecoderCsarPdpx policyDecoderCsarPdpx = new PolicyDecoderCsarPdpx();
- policyDecoderCsarPdpx.configure(CSAR_TO_OPTIMIZATION_POLICY_CONFIGURATION);
+ policyDecoderCsarPdpx.configure(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName());
final Collection<ToscaServiceTemplate> policies = policyDecoderCsarPdpx.decode(csar);
assertEquals(5, policies.size());
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxConfigurationParameterGroup.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxConfigurationParameterGroup.java
index bebb8459..d0de432a 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxConfigurationParameterGroup.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/pdpx/TestPolicyDecoderCsarPdpxConfigurationParameterGroup.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,17 +33,13 @@ import org.onap.policy.common.parameters.ValidationStatus;
*/
public class TestPolicyDecoderCsarPdpxConfigurationParameterGroup {
- private static final String OPTIMIZATION_POLICY_CONFIGURATION = "optimizationPolicyConfiguration";
-
@Test
- public void testBuilderAndGetters() {
- final PolicyDecoderCsarPdpxConfigurationParameterGroup parameterGroup =
- new PolicyDecoderCsarPdpxConfigurationParameterBuilder().setOnapName("onapName")
- .setPolicyNamePrefix("OOF").setPriority("5").setRiskLevel("2").setRiskType("Test")
- .setVersion("1.0").build();
- parameterGroup.setName(OPTIMIZATION_POLICY_CONFIGURATION);
+ public void testValidParameters() {
+ final PolicyDecoderCsarPdpxConfigurationParameterGroup parameterGroup = CommonTestData
+ .getPolicyDecoderParameters("src/test/resources/parameters/PdpxPolicyDecoderParameters.json",
+ PolicyDecoderCsarPdpxConfigurationParameterGroup.class);
- assertEquals(OPTIMIZATION_POLICY_CONFIGURATION, parameterGroup.getName());
+ assertEquals(PolicyDecoderCsarPdpxConfigurationParameterGroup.class.getSimpleName(), parameterGroup.getName());
assertEquals("onapName", parameterGroup.getOnapName());
assertEquals("OOF", parameterGroup.getPolicyNamePrefix());
assertEquals("5", parameterGroup.getPriority());
@@ -54,11 +51,19 @@ public class TestPolicyDecoderCsarPdpxConfigurationParameterGroup {
@Test
public void testInvalidParameters() {
- final PolicyDecoderCsarPdpxConfigurationParameterGroup parameterGroup =
- new PolicyDecoderCsarPdpxConfigurationParameterBuilder().setOnapName("").setPolicyNamePrefix("")
- .setPriority("").setRiskLevel("").setRiskType("").setVersion("").build();
- parameterGroup.setName(OPTIMIZATION_POLICY_CONFIGURATION);
+ final PolicyDecoderCsarPdpxConfigurationParameterGroup parameterGroup = CommonTestData
+ .getPolicyDecoderParameters("src/test/resources/parameters/PdpxPolicyDecoderParametersInvalid.json",
+ PolicyDecoderCsarPdpxConfigurationParameterGroup.class);
assertEquals(ValidationStatus.INVALID, parameterGroup.validate().getStatus());
}
+
+ @Test
+ public void testEmptyParameters() {
+ final PolicyDecoderCsarPdpxConfigurationParameterGroup configurationParameters =
+ CommonTestData.getPolicyDecoderParameters("src/test/resources/parameters/EmptyParameters.json",
+ PolicyDecoderCsarPdpxConfigurationParameterGroup.class);
+
+ assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
+ }
}
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroupTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroupTest.java
index 2dd09985..56ddc406 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroupTest.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroupTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +25,7 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.distribution.reception.decoding.pdpx.CommonTestData;
/**
* Class to perform unit test of {@link PolicyDecoderFileInCsarToPolicyParameterGroup}.
@@ -33,32 +35,34 @@ import org.onap.policy.common.parameters.ValidationStatus;
public class PolicyDecoderFileInCsarToPolicyParameterGroupTest {
@Test
- public void testConstructorAndGetters() {
- final PolicyDecoderFileInCsarToPolicyParameterGroup configurationParameters =
- new PolicyDecoderFileInCsarToPolicyParameterGroup("SamplePolicy", "SamplePolicyType");
- configurationParameters.setName("myConfiguration");
+ public void testValidParameters() {
+ final PolicyDecoderFileInCsarToPolicyParameterGroup configurationParameters = CommonTestData
+ .getPolicyDecoderParameters("src/test/resources/parameters/FileInCsarPolicyDecoderParameters.json",
+ PolicyDecoderFileInCsarToPolicyParameterGroup.class);
- assertEquals("myConfiguration", configurationParameters.getName());
- assertEquals("SamplePolicy", configurationParameters.getPolicyFileName());
- assertEquals("SamplePolicyType", configurationParameters.getPolicyTypeFileName());
+ assertEquals(PolicyDecoderFileInCsarToPolicyParameterGroup.class.getSimpleName(),
+ configurationParameters.getName());
+ assertEquals("apex_ddf_policy", configurationParameters.getPolicyFileName());
+ assertEquals("apex_ddf_policy_type", configurationParameters.getPolicyTypeFileName());
assertEquals(ValidationStatus.CLEAN, configurationParameters.validate().getStatus());
}
@Test
- public void testInvalidPolicyFileName() {
+ public void testInvalidParameters() {
final PolicyDecoderFileInCsarToPolicyParameterGroup configurationParameters =
- new PolicyDecoderFileInCsarToPolicyParameterGroup("", "SamplePolicyType");
- configurationParameters.setName("myConfiguration");
+ CommonTestData.getPolicyDecoderParameters(
+ "src/test/resources/parameters/FileInCsarPolicyDecoderParametersInvalid.json",
+ PolicyDecoderFileInCsarToPolicyParameterGroup.class);
assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
}
@Test
- public void testEmptyPolicyType() {
+ public void testEmptyParameters() {
final PolicyDecoderFileInCsarToPolicyParameterGroup configurationParameters =
- new PolicyDecoderFileInCsarToPolicyParameterGroup("SamplePolicy", "");
- configurationParameters.setName("myConfiguration");
+ CommonTestData.getPolicyDecoderParameters("src/test/resources/parameters/EmptyParameters.json",
+ PolicyDecoderFileInCsarToPolicyParameterGroup.class);
- assertEquals(ValidationStatus.CLEAN, configurationParameters.validate().getStatus());
+ assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
}
}
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyTest.java
index 2d0ba3ba..451e4f1b 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyTest.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +37,7 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.distribution.model.Csar;
+import org.onap.policy.distribution.reception.decoding.pdpx.CommonTestData;
import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
/**
@@ -46,18 +48,15 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
@RunWith(MockitoJUnitRunner.class)
public class PolicyDecoderFileInCsarToPolicyTest {
- private static final String POLICY_FILE_NAME = "apex_ddf_policy";
- private static final String POLICY_TYPE_FILE_NAME = "apex_ddf_policy_type";
- private static final String GROUP_NAME = "apexPdpDecoderConfiguration";
-
/**
* Set up.
*/
@BeforeClass
public static void setUp() {
- final PolicyDecoderFileInCsarToPolicyParameterGroup configurationParameters =
- new PolicyDecoderFileInCsarToPolicyParameterGroup(POLICY_FILE_NAME, POLICY_TYPE_FILE_NAME);
- configurationParameters.setName(GROUP_NAME);
+ final PolicyDecoderFileInCsarToPolicyParameterGroup configurationParameters = CommonTestData
+ .getPolicyDecoderParameters("src/test/resources/parameters/FileInCsarPolicyDecoderParameters.json",
+ PolicyDecoderFileInCsarToPolicyParameterGroup.class);
+ configurationParameters.setName(PolicyDecoderFileInCsarToPolicyParameterGroup.class.getSimpleName());
ParameterService.register(configurationParameters);
}
@@ -66,14 +65,14 @@ public class PolicyDecoderFileInCsarToPolicyTest {
*/
@AfterClass
public static void tearDown() {
- ParameterService.deregister(GROUP_NAME);
+ ParameterService.deregister(PolicyDecoderFileInCsarToPolicyParameterGroup.class.getSimpleName());
}
@Test
public void testDecodePolicy() {
final PolicyDecoderFileInCsarToPolicy decoder = new PolicyDecoderFileInCsarToPolicy();
- decoder.configure(GROUP_NAME);
+ decoder.configure(PolicyDecoderFileInCsarToPolicyParameterGroup.class.getSimpleName());
final File file = new File("src/test/resources/service-Sampleservice.csar");
final Csar csar = new Csar(file.getAbsolutePath());
@@ -91,7 +90,7 @@ public class PolicyDecoderFileInCsarToPolicyTest {
public void testDecodePolicyZipError() {
final PolicyDecoderFileInCsarToPolicy decoder = new PolicyDecoderFileInCsarToPolicy();
- decoder.configure(GROUP_NAME);
+ decoder.configure(PolicyDecoderFileInCsarToPolicyParameterGroup.class.getSimpleName());
final File file = new File("unknown.csar");
final Csar csar = new Csar(file.getAbsolutePath());
@@ -111,7 +110,7 @@ public class PolicyDecoderFileInCsarToPolicyTest {
public void testDecodePolicyCoderError() {
final PolicyDecoderFileInCsarToPolicy decoder = new PolicyDecoderFileInCsarToPolicy();
- decoder.configure(GROUP_NAME);
+ decoder.configure(PolicyDecoderFileInCsarToPolicyParameterGroup.class.getSimpleName());
final File file = new File("src/test/resources/service-Sampleservice-test.csar");
final Csar csar = new Csar(file.getAbsolutePath());
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java
index 1d32b191..dab97ec3 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java
@@ -52,9 +52,9 @@ public class TestFileSystemReceptionHandlerConfigurationParameterGroup {
try {
validPath = tempFolder.getRoot().getAbsolutePath();
- final FileSystemReceptionHandlerConfigurationParameterBuilder builder =
- new FileSystemReceptionHandlerConfigurationParameterBuilder().setWatchPath(validPath).setMaxThread(2);
- configParameters = new FileSystemReceptionHandlerConfigurationParameterGroup(builder);
+ configParameters = new FileSystemReceptionHandlerConfigurationParameterGroup();
+ configParameters.setWatchPath(validPath);
+ configParameters.setMaxThread(2);
} catch (final Exception e) {
fail("test should not thrown an exception here: " + e.getMessage());
}
@@ -79,24 +79,12 @@ public class TestFileSystemReceptionHandlerConfigurationParameterGroup {
}
@Test
- public void testFileSystemReceptionHandlerConfigurationParameterBuilder() {
-
- final FileSystemReceptionHandlerConfigurationParameterBuilder builder =
- new FileSystemReceptionHandlerConfigurationParameterBuilder().setWatchPath("/foo/bar");
- final FileSystemReceptionHandlerConfigurationParameterGroup configParameters =
- new FileSystemReceptionHandlerConfigurationParameterGroup(builder);
-
- assertEquals("/foo/bar", configParameters.getWatchPath());
- }
-
- @Test
public void testFileSystemReceptionHandlerConfigurationParameterBuilderWithInvalidPath() throws IOException {
final String invalidPath = tempFolder.newFile("foobar").getAbsolutePath();
- final FileSystemReceptionHandlerConfigurationParameterBuilder builder =
- new FileSystemReceptionHandlerConfigurationParameterBuilder().setWatchPath(invalidPath);
final FileSystemReceptionHandlerConfigurationParameterGroup configParameters =
- new FileSystemReceptionHandlerConfigurationParameterGroup(builder);
+ new FileSystemReceptionHandlerConfigurationParameterGroup();
+ configParameters.setWatchPath(invalidPath);
final GroupValidationResult validateResult = configParameters.validate();
assertFalse(validateResult.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
index f9a65c54..30bcdf11 100644
--- 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
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +35,8 @@ import java.util.Arrays;
import org.junit.Test;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
+import org.onap.policy.distribution.reception.decoding.pdpx.CommonTestData;
/**
* Class to perform unit test of {@link SdcConfiguration}.
@@ -86,75 +89,11 @@ public class TestSdcReceptionHandlerConfigurationParameterGroup {
}
@Test
- public void testSdcConfigurationBuilder() {
+ public void testEmptyParameters() {
+ final SdcReceptionHandlerConfigurationParameterGroup configurationParameters =
+ CommonTestData.getPolicyDecoderParameters("src/test/resources/parameters/EmptyParameters.json",
+ SdcReceptionHandlerConfigurationParameterGroup.class);
- 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).setRetryDelay(30).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(30, configParameters.getRetryDelay());
- 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"));
+ assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
}
}