diff options
13 files changed, 694 insertions, 0 deletions
diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPluginHandlerParameters.java b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPluginHandlerParameters.java new file mode 100644 index 00000000..9d6a78d0 --- /dev/null +++ b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPluginHandlerParameters.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 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.parameters; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import org.onap.policy.common.parameters.GroupValidationResult; +import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters; + +/** + * Class for unit testing PluginHandlerParameters class. + * + * @author Adheli Tavares (adheli.tavares@est.tech) + * + */ +public class TestPluginHandlerParameters { + + @Test + public void testValidate_PolicyDecodersEmpty() { + PluginHandlerParameters emptyDecoder = new PluginHandlerParameters(new HashMap<>(), getPolicyForwarders()); + + GroupValidationResult result = emptyDecoder.validate(); + + assertThat(result.getResult()) + .contains("parameter group map \"policyDecoders\" INVALID, must have at least one policy decoder"); + assertThat(result.getResult()).doesNotContain( + "parameter group map \"policyForwarders\" INVALID, must have at least one policy forwarder"); + } + + @Test + public void testValidate_PolicyForwardersNullEmpty() { + PluginHandlerParameters emptyDecoder = new PluginHandlerParameters(getPolicyDecoders(), new HashMap<>()); + + GroupValidationResult result = emptyDecoder.validate(); + + assertThat(result.getResult()) + .contains("parameter group map \"policyForwarders\" INVALID, must have at least one policy forwarder"); + assertThat(result.getResult()).doesNotContain( + "parameter group map \"policyDecoders\" INVALID, must have at least one policy decoder"); + } + + private Map<String, PolicyDecoderParameters> getPolicyDecoders() { + final Map<String, PolicyDecoderParameters> policyDecoders = new HashMap<>(); + final PolicyDecoderParameters pDParameters = + new PolicyDecoderParameters("DummyDecoder", "DummyDecoder", "dummyDecoderConfiguration"); + policyDecoders.put("DummyDecoder", pDParameters); + + return policyDecoders; + } + + private Map<String, PolicyForwarderParameters> getPolicyForwarders() { + final Map<String, PolicyForwarderParameters> policyForwarders = new HashMap<>(); + final PolicyForwarderParameters pFParameters = + new PolicyForwarderParameters("DummyForwarder", "DummyForwarder", "dummyForwarderConfiguration"); + policyForwarders.put("DummyForwarder", pFParameters); + + return policyForwarders; + } + +} diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPolicyDecoderConfigurationParametersJsonAdapter.java b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPolicyDecoderConfigurationParametersJsonAdapter.java new file mode 100644 index 00000000..127f1223 --- /dev/null +++ b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPolicyDecoderConfigurationParametersJsonAdapter.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 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.parameters; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import org.junit.Test; +import org.onap.policy.distribution.reception.testclasses.DummyPolicyDecoderParameterGroup; + +/** + * Class for unit testing PolicyDecoderConfigurationParametersJsonAdapter class. + * + * @author Adheli Tavares (adheli.tavares@est.tech) + * + */ +public class TestPolicyDecoderConfigurationParametersJsonAdapter { + + @Test + public void testDeserialize() throws JsonSyntaxException, IOException { + final String validJsonFile = "src/test/resources/PolicyDecoderConfiguration.json"; + final JsonElement mockJsonElement = JsonParser.parseString(getJsonValues(validJsonFile)); + + Gson gson = new GsonBuilder().registerTypeAdapter(PolicyDecoderConfigurationParameterGroup.class, + new PolicyDecoderConfigurationParametersJsonAdapter()).create(); + + PolicyDecoderConfigurationParameterGroup result = + gson.fromJson(mockJsonElement, PolicyDecoderConfigurationParameterGroup.class); + + assertNotNull(result); + assertEquals(result.getClass(), DummyPolicyDecoderParameterGroup.class); + } + + @Test + public void testDeserialize_shouldThrowExceptionEmptyClassName() throws JsonSyntaxException, IOException { + final String jsonFile = "src/test/resources/EmptyClassName.json"; + String expectedErrorMsg = "parameter \"parameterClassName\" value \"\" invalid in JSON file"; + + validateParsing(jsonFile, expectedErrorMsg); + } + + @Test + public void testDeserialize_shouldThrowExceptionNullClassName() throws JsonSyntaxException, IOException { + final String jsonFile = "src/test/resources/NullClassName.json"; + String expectedErrorMsg = "parameter \"parameterClassName\" value \"null\" invalid in JSON file"; + + validateParsing(jsonFile, expectedErrorMsg); + } + + @Test + public void testDeserialize_shouldThrowExceptionWrongClassName() throws JsonSyntaxException, IOException { + final String jsonFile = "src/test/resources/WrongClassName.json"; + String expectedErrorMsg = "parameter \"parameterClassName\" value " + + "\"org.onap.policy.distribution.reception.testclasses.NotExistentClass\", could not find class"; + + validateParsing(jsonFile, expectedErrorMsg); + } + + private void validateParsing(final String jsonFile, String expectedErrorMsg) throws IOException { + final JsonElement mockJsonElement = JsonParser.parseString(getJsonValues(jsonFile)); + + Gson gson = new GsonBuilder().registerTypeAdapter(PolicyDecoderConfigurationParameterGroup.class, + new PolicyDecoderConfigurationParametersJsonAdapter()).create(); + + assertThatThrownBy(() -> gson.fromJson(mockJsonElement, PolicyDecoderConfigurationParameterGroup.class)) + .isInstanceOf(IllegalArgumentException.class).hasMessage(expectedErrorMsg); + } + + private String getJsonValues(String path) throws IOException { + return new String(Files.readAllBytes(new File(path).toPath()), StandardCharsets.UTF_8); + } + +} diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPolicyDecoderParameters.java b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPolicyDecoderParameters.java new file mode 100644 index 00000000..d1d0b421 --- /dev/null +++ b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestPolicyDecoderParameters.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 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.parameters; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +/** + * Class for unit testing PolicyDecoderParameters class. + * + * @author Adheli Tavares (adheli.tavares@est.tech) + * + */ +public class TestPolicyDecoderParameters { + + static final String DECODER_CLASS_NAME = "org.onap.policy.distribution.reception.handling.DummyDecoder"; + static final String DECODER_CONFIG = "decoderConfigName"; + static final String DECODER_TYPE = "DummyDecoder"; + + @Test + public void testValidate_DecoderTypeEmptyNull() { + PolicyDecoderParameters sutParams = new PolicyDecoderParameters(null, DECODER_CLASS_NAME, DECODER_CONFIG); + + assertThat(sutParams.validate().getResult()).contains( + "field \"decoderType\" type \"java.lang.String\" value \"null\" INVALID, must be a non-blank string"); + + sutParams.setName(""); + + assertThat(sutParams.validate().getResult()).contains( + "field \"decoderType\" type \"java.lang.String\" value \"\" INVALID, must be a non-blank string"); + assertThat(sutParams.validate().getResult()).doesNotContain("policy decoder class not found in classpath"); + } + + @Test + public void testValidate_ClassNameEmptyNull() { + PolicyDecoderParameters nullClassName = new PolicyDecoderParameters(DECODER_TYPE, null, DECODER_CONFIG); + + assertThat(nullClassName.validate().getResult()) + .contains("field \"decoderClassName\" type \"java.lang.String\" value \"null\" INVALID, " + + "must be a non-blank string containing full class name of the decoder"); + + PolicyDecoderParameters emptyClassName = new PolicyDecoderParameters(DECODER_TYPE, "", DECODER_CONFIG); + + assertThat(emptyClassName.validate().getResult()) + .contains("field \"decoderClassName\" type \"java.lang.String\" value \"\" INVALID, " + + "must be a non-blank string containing full class name of the decoder"); + } +} diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestReceptionHandlerConfigurationParametersJsonAdapter.java b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestReceptionHandlerConfigurationParametersJsonAdapter.java new file mode 100644 index 00000000..ae85e0dc --- /dev/null +++ b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestReceptionHandlerConfigurationParametersJsonAdapter.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 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.parameters; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import org.junit.Test; +import org.onap.policy.distribution.reception.testclasses.DummyReceptionHandlerParameterGroup; + +/** + * Class for unit testing ReceptionHandlerConfigurationParametersJsonAdapter class. + * + * @author Adheli Tavares (adheli.tavares@est.tech) + * + */ +public class TestReceptionHandlerConfigurationParametersJsonAdapter { + + @Test + public void testDeserialize() throws JsonSyntaxException, IOException { + final String validJsonFile = "src/test/resources/ReceptionHandlerConfiguration.json"; + final JsonElement mockJsonElement = JsonParser.parseString(getJsonValues(validJsonFile)); + + Gson gson = new GsonBuilder().registerTypeAdapter(ReceptionHandlerConfigurationParameterGroup.class, + new ReceptionHandlerConfigurationParametersJsonAdapter()).create(); + + ReceptionHandlerConfigurationParameterGroup result = + gson.fromJson(mockJsonElement, ReceptionHandlerConfigurationParameterGroup.class); + + assertNotNull(result); + assertEquals(result.getClass(), DummyReceptionHandlerParameterGroup.class); + } + + @Test + public void testDeserialize_shouldThrowExceptionEmptyClassName() throws JsonSyntaxException, IOException { + final String jsonFile = "src/test/resources/EmptyClassName.json"; + String expectedErrorMsg = "parameter \"parameterClassName\" value \"\" invalid in JSON file"; + + validateParsing(jsonFile, expectedErrorMsg); + } + + @Test + public void testDeserialize_shouldThrowExceptionNullClassName() throws JsonSyntaxException, IOException { + final String jsonFile = "src/test/resources/NullClassName.json"; + String expectedErrorMsg = "parameter \"parameterClassName\" value \"null\" invalid in JSON file"; + + validateParsing(jsonFile, expectedErrorMsg); + } + + @Test + public void testDeserialize_shouldThrowExceptionWrongClassName() throws JsonSyntaxException, IOException { + final String jsonFile = "src/test/resources/WrongClassName.json"; + String expectedErrorMsg = "parameter \"parameterClassName\" value " + + "\"org.onap.policy.distribution.reception.testclasses.NotExistentClass\", could not find class"; + + validateParsing(jsonFile, expectedErrorMsg); + } + + private void validateParsing(final String jsonFile, String expectedErrorMsg) throws IOException { + final JsonElement mockJsonElement = JsonParser.parseString(getJsonValues(jsonFile)); + + Gson gson = new GsonBuilder().registerTypeAdapter(ReceptionHandlerConfigurationParameterGroup.class, + new ReceptionHandlerConfigurationParametersJsonAdapter()).create(); + + assertThatThrownBy(() -> gson.fromJson(mockJsonElement, ReceptionHandlerConfigurationParameterGroup.class)) + .isInstanceOf(IllegalArgumentException.class).hasMessage(expectedErrorMsg); + } + + private String getJsonValues(String path) throws IOException { + return new String(Files.readAllBytes(new File(path).toPath()), StandardCharsets.UTF_8); + } + +} diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestReceptionHandlerParameters.java b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestReceptionHandlerParameters.java new file mode 100644 index 00000000..e2ef01db --- /dev/null +++ b/reception/src/test/java/org/onap/policy/distribution/reception/parameters/TestReceptionHandlerParameters.java @@ -0,0 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 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.parameters; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters; + +/** + * Class for unit testing ReceptionHandlerParameters class. + * + * @author Adheli Tavares (adheli.tavares@est.tech) + * + */ +public class TestReceptionHandlerParameters { + + @Test + public void testValidate_ClassNotFound() { + final String className = "org.onap.policy.distribution.reception.testclasses.NotExistent"; + + ReceptionHandlerParameters sutParams = getReceptionHandlerParameters(className); + sutParams.setName(className); + + assertThat(sutParams.validate().getResult()).contains("reception handler class not found in classpath"); + } + + @Test + public void testValidate_ReceptionHandlerTypeNullEmpty() { + final String className = "org.onap.policy.distribution.reception.handling.DummyReceptionHandler"; + final PluginHandlerParameters pHParameters = + new PluginHandlerParameters(getPolicyDecoders(), getPolicyForwarders()); + + ReceptionHandlerParameters nullType = new ReceptionHandlerParameters(null, className, className, pHParameters); + + assertThat(nullType.validate().getResult()).contains("field \"receptionHandlerType\" type \"java.lang.String\"" + + " value \"null\" INVALID, must be a non-blank string"); + + ReceptionHandlerParameters emptyType = new ReceptionHandlerParameters("", className, className, pHParameters); + + assertThat(emptyType.validate().getResult()).contains("field \"receptionHandlerType\" type \"java.lang.String\"" + + " value \"\" INVALID, must be a non-blank string"); + assertThat(emptyType.validate().getResult()).doesNotContain("reception handler class not found in classpath"); + } + + @Test + public void testValidate_ReceptionHandlerClassNameNullEmpty() { + final PluginHandlerParameters pHParameters = + new PluginHandlerParameters(getPolicyDecoders(), getPolicyForwarders()); + + ReceptionHandlerParameters nullType = new ReceptionHandlerParameters("DummyReceptionHandler", null, + "dummyReceptionHandlerConfiguration", pHParameters); + + assertThat(nullType.validate().getResult()) + .contains("field \"receptionHandlerClassName\" type \"java.lang.String\" value " + + "\"null\" INVALID, must be a non-blank string containing full class name " + + "of the reception handler"); + + ReceptionHandlerParameters emptyType = new ReceptionHandlerParameters("DummyReceptionHandler", "", + "dummyReceptionHandlerConfiguration", pHParameters); + + assertThat(emptyType.validate().getResult()) + .contains("field \"receptionHandlerClassName\" type \"java.lang.String\" value " + + "\"\" INVALID, must be a non-blank string containing full class name of " + + "the reception handler"); + } + + @Test + public void testValidate_PluginHandlerParametersNull() { + final String className = "org.onap.policy.distribution.reception.testclasses.DummyReceptionHandler"; + + ReceptionHandlerParameters sutParams = new ReceptionHandlerParameters("DummyReceptionHandler", className, + "dummyReceptionHandlerConfiguration", null); + + assertThat(sutParams.validate().getResult()) + .contains("parameter group \"UNDEFINED\" INVALID, must have a plugin handler"); + } + + private ReceptionHandlerParameters getReceptionHandlerParameters(String className) { + final Map<String, PolicyDecoderParameters> policyDecoders = getPolicyDecoders(); + final Map<String, PolicyForwarderParameters> policyForwarders = getPolicyForwarders(); + final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders); + final ReceptionHandlerParameters rhParameters = new ReceptionHandlerParameters("DummyReceptionHandler", + className, "dummyReceptionHandlerConfiguration", pHParameters); + return rhParameters; + } + + private Map<String, PolicyDecoderParameters> getPolicyDecoders() { + final Map<String, PolicyDecoderParameters> policyDecoders = new HashMap<>(); + + final PolicyDecoderParameters pDParameters = + new PolicyDecoderParameters("DummyDecoder", "DummyDecoder", "dummyDecoderConfiguration"); + policyDecoders.put("DummyDecoder", pDParameters); + + return policyDecoders; + } + + private Map<String, PolicyForwarderParameters> getPolicyForwarders() { + final Map<String, PolicyForwarderParameters> policyForwarders = new HashMap<>(); + + final PolicyForwarderParameters pFParameters = + new PolicyForwarderParameters("DummyForwarder", "DummyForwarder", "dummyForwarderConfiguration"); + policyForwarders.put("DummyForwarder", pFParameters); + + return policyForwarders; + } + +} diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/statistics/TestDistributionStatisticsManager.java b/reception/src/test/java/org/onap/policy/distribution/reception/statistics/TestDistributionStatisticsManager.java new file mode 100644 index 00000000..3c14da33 --- /dev/null +++ b/reception/src/test/java/org/onap/policy/distribution/reception/statistics/TestDistributionStatisticsManager.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 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.statistics; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +/** + * Class to perform unit test of DistributionStatisticsManager. + * + * @author Adheli Tavares (adheli.tavares@est.tech) + * */ +public class TestDistributionStatisticsManager { + + + @Before + public void reset() { + DistributionStatisticsManager.resetAllStatistics(); + } + + @Test + public void testUpdateTotalDistributionCount() { + DistributionStatisticsManager.updateTotalDistributionCount(); + assertEquals(1L, DistributionStatisticsManager.getTotalDistributionCount()); + } + + @Test + public void testUpdateDistributionSuccessCount() { + DistributionStatisticsManager.updateDistributionSuccessCount(); + assertEquals(1L, DistributionStatisticsManager.getDistributionSuccessCount()); + } + + @Test + public void testUpdateDistributionFailureCount() { + DistributionStatisticsManager.updateDistributionFailureCount(); + assertEquals(1L, DistributionStatisticsManager.getDistributionFailureCount()); + } + + @Test + public void testUpdateTotalDownloadCount() { + DistributionStatisticsManager.updateTotalDownloadCount(); + assertEquals(1L, DistributionStatisticsManager.getTotalDownloadCount()); + } + + @Test + public void testUpdateDownloadSuccessCount() { + DistributionStatisticsManager.updateDownloadSuccessCount(); + assertEquals(1L, DistributionStatisticsManager.getDownloadSuccessCount()); + } + + @Test + public void testUpdateDownloadFailureCount() { + DistributionStatisticsManager.updateDownloadFailureCount(); + assertEquals(1L, DistributionStatisticsManager.getDownloadFailureCount()); + } + + @Test + public void testGetTotalDistributionCount() { + assertEquals(0L, DistributionStatisticsManager.getTotalDistributionCount()); + } + + @Test + public void testGetDistributionSuccessCount() { + assertEquals(0L, DistributionStatisticsManager.getDistributionSuccessCount()); + } + + @Test + public void testGetDistributionFailureCount() { + assertEquals(0L, DistributionStatisticsManager.getDistributionFailureCount()); + } + + @Test + public void testGetTotalDownloadCount() { + assertEquals(0L, DistributionStatisticsManager.getTotalDownloadCount()); + } + + @Test + public void testGetDownloadSuccessCount() { + assertEquals(0L, DistributionStatisticsManager.getDownloadSuccessCount()); + } + + @Test + public void testGetDownloadFailureCount() { + assertEquals(0L, DistributionStatisticsManager.getDownloadFailureCount()); + } +} diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/testclasses/DummyPolicyDecoderParameterGroup.java b/reception/src/test/java/org/onap/policy/distribution/reception/testclasses/DummyPolicyDecoderParameterGroup.java new file mode 100644 index 00000000..0b3fc013 --- /dev/null +++ b/reception/src/test/java/org/onap/policy/distribution/reception/testclasses/DummyPolicyDecoderParameterGroup.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 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.testclasses; + +import lombok.Getter; +import lombok.Setter; +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; +import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParameterGroup; + +@Getter +@Setter +@NotNull +@NotBlank +public class DummyPolicyDecoderParameterGroup extends PolicyDecoderConfigurationParameterGroup { + + private String policyName; + private String policyType; + + public DummyPolicyDecoderParameterGroup() { + super(DummyPolicyDecoderParameterGroup.class.getSimpleName()); + } +} diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/testclasses/DummyReceptionHandlerParameterGroup.java b/reception/src/test/java/org/onap/policy/distribution/reception/testclasses/DummyReceptionHandlerParameterGroup.java new file mode 100644 index 00000000..a8d6819e --- /dev/null +++ b/reception/src/test/java/org/onap/policy/distribution/reception/testclasses/DummyReceptionHandlerParameterGroup.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 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.testclasses; + +import lombok.Getter; +import lombok.Setter; +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; +import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigurationParameterGroup; + +@Getter +@Setter +@NotNull +@NotBlank +public class DummyReceptionHandlerParameterGroup extends ReceptionHandlerConfigurationParameterGroup { + + private String myStringParameter; + private int myIntegerParameter; + private boolean myBooleanParameter; + + public DummyReceptionHandlerParameterGroup() { + super(DummyReceptionHandlerParameterGroup.class.getSimpleName()); + } +} + diff --git a/reception/src/test/resources/EmptyClassName.json b/reception/src/test/resources/EmptyClassName.json new file mode 100644 index 00000000..11ef5c4c --- /dev/null +++ b/reception/src/test/resources/EmptyClassName.json @@ -0,0 +1,3 @@ +{ + "parameterClassName": "" +} diff --git a/reception/src/test/resources/NullClassName.json b/reception/src/test/resources/NullClassName.json new file mode 100644 index 00000000..fc65c1bd --- /dev/null +++ b/reception/src/test/resources/NullClassName.json @@ -0,0 +1,5 @@ +{ + "parameters": { + "param1": "value" + } +} diff --git a/reception/src/test/resources/PolicyDecoderConfiguration.json b/reception/src/test/resources/PolicyDecoderConfiguration.json new file mode 100644 index 00000000..80a6dcab --- /dev/null +++ b/reception/src/test/resources/PolicyDecoderConfiguration.json @@ -0,0 +1,7 @@ +{ + "parameterClassName": "org.onap.policy.distribution.reception.testclasses.DummyPolicyDecoderParameterGroup", + "parameters": { + "policyName": "SamplePolicy", + "policyType": "DUMMY" + } +} diff --git a/reception/src/test/resources/ReceptionHandlerConfiguration.json b/reception/src/test/resources/ReceptionHandlerConfiguration.json new file mode 100644 index 00000000..75d157b2 --- /dev/null +++ b/reception/src/test/resources/ReceptionHandlerConfiguration.json @@ -0,0 +1,8 @@ +{ + "parameterClassName": "org.onap.policy.distribution.reception.testclasses.DummyReceptionHandlerParameterGroup", + "parameters": { + "myStringParameter": "stringValue", + "myIntegerParameter": 20, + "myBooleanParameter": true + } +} diff --git a/reception/src/test/resources/WrongClassName.json b/reception/src/test/resources/WrongClassName.json new file mode 100644 index 00000000..98beb411 --- /dev/null +++ b/reception/src/test/resources/WrongClassName.json @@ -0,0 +1,3 @@ +{ + "parameterClassName": "org.onap.policy.distribution.reception.testclasses.NotExistentClass" +} |