Upgrade Java 17
Issue-ID: POLICY-4803
Change-Id: Iad0d08ee6f8ab18eb177b458d8edbba4002bcc73
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
diff --git a/forwarding/pom.xml b/forwarding/pom.xml
index de9c721..2ef6d75 100644
--- a/forwarding/pom.xml
+++ b/forwarding/pom.xml
@@ -17,12 +17,13 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>policy-distribution</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>forwarding</artifactId>
diff --git a/forwarding/src/test/java/org/onap/policy/distribution/forwarding/TestExceptions.java b/forwarding/src/test/java/org/onap/policy/distribution/forwarding/TestExceptions.java
index 66e1665..eaa74cf 100644
--- a/forwarding/src/test/java/org/onap/policy/distribution/forwarding/TestExceptions.java
+++ b/forwarding/src/test/java/org/onap/policy/distribution/forwarding/TestExceptions.java
@@ -20,13 +20,13 @@
package org.onap.policy.distribution.forwarding;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class TestExceptions {
+class TestExceptions {
@Test
- public void test() {
+ void test() {
new ExceptionsTester().test(PolicyForwardingException.class);
}
}
diff --git a/main/pom.xml b/main/pom.xml
index 37a889b..1bb1b80 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -18,18 +18,20 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>policy-distribution</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>distribution-main</artifactId>
<name>${project.artifactId}</name>
- <description>The main module of Policy Distribution that handles startup, lifecycle management, and parameters.</description>
+ <description>The main module of Policy Distribution that handles startup, lifecycle management, and parameters.
+ </description>
<dependencies>
<dependency>
@@ -51,6 +53,11 @@
<artifactId>gson</artifactId>
</dependency>
<dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-annotations</artifactId>
+ <version>1.6.11</version>
+ </dependency>
+ <dependency>
<groupId>org.onap.policy.common</groupId>
<artifactId>utils-test</artifactId>
<version>${policy.common.version}</version>
diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java b/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java
index 702f8a2..e9e4b04 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/rest/DistributionRestController.java
@@ -26,11 +26,11 @@
import io.swagger.annotations.Info;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.annotations.Tag;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
/**
diff --git a/main/src/test/java/org/onap/policy/distribution/main/TestExceptions.java b/main/src/test/java/org/onap/policy/distribution/main/TestExceptions.java
index 0f5e502..4a15506 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/TestExceptions.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/TestExceptions.java
@@ -20,19 +20,19 @@
package org.onap.policy.distribution.main;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class TestExceptions {
+class TestExceptions {
@Test
- public void test() {
- assertNotNull(new PolicyDistributionException("Message"));
- assertNotNull(new PolicyDistributionException("Message", new IOException()));
+ void test() {
+ assertDoesNotThrow(() -> new PolicyDistributionException("Message"));
+ assertDoesNotThrow(() -> new PolicyDistributionException("Message", new IOException()));
- assertNotNull(new PolicyDistributionRuntimeException("Message"));
- assertNotNull(new PolicyDistributionRuntimeException("Message", new IOException()));
+ assertDoesNotThrow(() -> new PolicyDistributionRuntimeException("Message"));
+ assertDoesNotThrow(() -> new PolicyDistributionRuntimeException("Message", new IOException()));
}
}
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 9f6fab5..57fa97d 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
@@ -133,6 +133,22 @@
/**
* Returns an instance of ReceptionHandlerParameters for test cases.
*
+ * @param port the port
+ * @return the restServerParameters object
+ */
+ public RestServerParameters getRestServerParameters(final int port) {
+ final var fileName = "src/test/resources/parameters/RestServerParameters.json";
+ try {
+ var json = Files.readString(new File(fileName).toPath());
+ return coder.decode(json.replace("6969", String.valueOf(port)), RestServerParameters.class);
+ } catch (final Exception exp) {
+ throw new RuntimeException("cannot read/decode " + fileName, exp);
+ }
+ }
+
+ /**
+ * Returns an instance of ReceptionHandlerParameters for test cases.
+ *
* @param isEmpty boolean value to represent that object created should be empty or not
* @return the receptionHandlerParameters object
*/
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java
old mode 100644
new mode 100755
index 0b5bfcb..a48b0bd
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterGroup.java
@@ -23,12 +23,12 @@
package org.onap.policy.distribution.main.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.distribution.main.testclasses.DummyPolicyForwarderParameterGroup;
@@ -42,25 +42,24 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class TestDistributionParameterGroup {
+class TestDistributionParameterGroup {
CommonTestData commonTestData = new CommonTestData();
@Test
- public void testDistributionParameterGroup() {
- final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
- final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
- commonTestData.getReceptionHandlerParameters(false);
- final Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurations =
+ void testDistributionParameterGroup() {
+ final var restServerParameters = commonTestData.getRestServerParameters(false);
+ final var receptionHandlerParameters = commonTestData.getReceptionHandlerParameters(false);
+ final var receptionHandlerConfigurations =
commonTestData.getReceptionHandlerConfigurationParameters(false);
- final Map<String, PolicyForwarderConfigurationParameterGroup> forwarderConfigurations =
+ final var forwarderConfigurations =
commonTestData.getPolicyForwarderConfigurationParameters(false);
- final Map<String, PolicyDecoderConfigurationParameterGroup> decoderConfigurations =
+ final var decoderConfigurations =
commonTestData.getPolicyDecoderConfigurationParameters(false);
- final DistributionParameterGroup distributionParameters = new DistributionParameterGroup(
+ final var distributionParameters = new DistributionParameterGroup(
CommonTestData.DISTRIBUTION_GROUP_NAME, restServerParameters, receptionHandlerParameters,
receptionHandlerConfigurations, forwarderConfigurations, decoderConfigurations);
- final ValidationResult validationResult = distributionParameters.validate();
+ final var validationResult = distributionParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(restServerParameters.getHost(), distributionParameters.getRestServerParameters().getHost());
assertEquals(restServerParameters.getPort(), distributionParameters.getRestServerParameters().getPort());
@@ -100,9 +99,9 @@
}
@Test
- public void testDistributionParameterGroup_NullName() {
- final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
- final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
+ void testDistributionParameterGroup_NullName() {
+ final var restServerParameters = commonTestData.getRestServerParameters(false);
+ final var receptionHandlerParameters =
commonTestData.getReceptionHandlerParameters(false);
final Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurations =
commonTestData.getReceptionHandlerConfigurationParameters(false);
@@ -116,7 +115,7 @@
receptionHandlerConfigurations, forwarderConfigurations, decoderConfigurations);
final ValidationResult validationResult = distributionParameters.validate();
assertFalse(validationResult.isValid());
- assertEquals(null, distributionParameters.getName());
+ assertThat(distributionParameters.getName()).isNull();
assertEquals(
receptionHandlerParameters.get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY).getReceptionHandlerType(),
distributionParameters.getReceptionHandlerParameters().get(CommonTestData.DUMMY_RECEPTION_HANDLER_KEY)
@@ -134,7 +133,7 @@
}
@Test
- public void testDistributionParameterGroup_EmptyName() {
+ void testDistributionParameterGroup_EmptyName() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
commonTestData.getReceptionHandlerParameters(false);
@@ -168,7 +167,7 @@
}
@Test
- public void testDistributionParameterGroup_NullReceptionHandlerParameters() {
+ void testDistributionParameterGroup_NullReceptionHandlerParameters() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
final Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurations =
commonTestData.getReceptionHandlerConfigurationParameters(false);
@@ -184,7 +183,7 @@
}
@Test
- public void testDistributionParameterGroup_EmptyReceptionHandlerParameters() {
+ void testDistributionParameterGroup_EmptyReceptionHandlerParameters() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(false);
final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
commonTestData.getReceptionHandlerParameters(true);
@@ -204,7 +203,7 @@
}
@Test
- public void testDistributionParameterGroup_EmptyRestServerParameters() {
+ void testDistributionParameterGroup_EmptyRestServerParameters() {
final RestServerParameters restServerParameters = commonTestData.getRestServerParameters(true);
final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
commonTestData.getReceptionHandlerParameters(false);
@@ -224,7 +223,7 @@
}
@Test
- public void testDistributionParameterGroup_NullRestServerParameters() {
+ void testDistributionParameterGroup_NullRestServerParameters() {
final RestServerParameters restServerParameters = null;
final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
commonTestData.getReceptionHandlerParameters(false);
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java
old mode 100644
new mode 100755
index b83b3fc..697cdd6
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestDistributionParameterHandler.java
@@ -23,13 +23,13 @@
package org.onap.policy.distribution.main.parameters;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.cmd.CommandLineException;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.startstop.DistributionCommandLineArguments;
@@ -41,20 +41,20 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class TestDistributionParameterHandler {
+class TestDistributionParameterHandler {
@Test
- public void testParameterHandlerNoParameterFile() throws PolicyDistributionException, CommandLineException {
+ void testParameterHandlerNoParameterFile() throws PolicyDistributionException, CommandLineException {
verifyFailure("NoParameterFile.json", PolicyDistributionException.class, "FileNotFoundException");
}
@Test
- public void testParameterHandlerEmptyParameters() throws PolicyDistributionException, CommandLineException {
+ void testParameterHandlerEmptyParameters() throws PolicyDistributionException, CommandLineException {
verifyFailure("EmptyParameters.json", PolicyDistributionException.class,
"no parameters found in \"parameters/EmptyParameters.json\"");
}
@Test
- public void testParameterHandlerBadParameters() throws PolicyDistributionException, CommandLineException {
+ void testParameterHandlerBadParameters() throws PolicyDistributionException, CommandLineException {
verifyFailure("BadParameters.json", PolicyDistributionException.class,
"error reading parameters from \"parameters/BadParameters.json\"\n"
+ "(JsonSyntaxException):java.lang.IllegalStateException: "
@@ -62,7 +62,7 @@
}
@Test
- public void testParameterHandlerInvalidParameters() throws PolicyDistributionException, CommandLineException {
+ void testParameterHandlerInvalidParameters() throws PolicyDistributionException, CommandLineException {
verifyFailure("InvalidParameters.json", PolicyDistributionException.class,
"error reading parameters from \"parameters/InvalidParameters.json\"\n"
+ "(JsonSyntaxException):java.lang.IllegalStateException: "
@@ -70,30 +70,30 @@
}
@Test
- public void testParameterHandlerNoParameters() throws PolicyDistributionException, CommandLineException {
+ void testParameterHandlerNoParameters() throws PolicyDistributionException, CommandLineException {
verifyFailure("NoParameters.json", PolicyDistributionException.class,
"\"receptionHandlerParameters\" value \"null\" INVALID, is null");
}
@Test
- public void testParameterHandlerMinumumParameters() throws PolicyDistributionException, CommandLineException {
+ void testParameterHandlerMinumumParameters() throws PolicyDistributionException, CommandLineException {
final String[] minArgumentString = {"-c", "parameters/MinimumParameters.json"};
- final DistributionCommandLineArguments minArguments = new DistributionCommandLineArguments();
+ final var minArguments = new DistributionCommandLineArguments();
minArguments.parse(minArgumentString);
- final DistributionParameterGroup parGroup = new DistributionParameterHandler().getParameters(minArguments);
+ final var parGroup = new DistributionParameterHandler().getParameters(minArguments);
assertEquals(CommonTestData.DISTRIBUTION_GROUP_NAME, parGroup.getName());
}
@Test
- public void testDistributionParameterGroup() throws PolicyDistributionException, CommandLineException {
+ void testDistributionParameterGroup() throws PolicyDistributionException, CommandLineException {
final String[] distributionConfigParameters = {"-c", "parameters/DistributionConfigParameters.json"};
- final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
+ final var arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
- final DistributionParameterGroup parGroup = new DistributionParameterHandler().getParameters(arguments);
+ final var parGroup = new DistributionParameterHandler().getParameters(arguments);
assertTrue(arguments.checkSetConfigurationFilePath());
assertEquals(CommonTestData.DISTRIBUTION_GROUP_NAME, parGroup.getName());
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, parGroup.getReceptionHandlerParameters()
@@ -118,14 +118,14 @@
}
@Test
- public void testDistributionParameterGroup_InvalidForwarderConfigurationClassName()
+ void testDistributionParameterGroup_InvalidForwarderConfigurationClassName()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_InvalidForwarderConfigurationClassName.json",
PolicyDistributionException.class, "parameter \"parameterClassName\" value \"\" invalid in JSON file");
}
@Test
- public void testDistributionParameterGroup_UnknownForwarderConfigurationClassName()
+ void testDistributionParameterGroup_UnknownForwarderConfigurationClassName()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_UnknownForwarderConfigurationClassName.json",
PolicyDistributionException.class,
@@ -133,58 +133,58 @@
}
@Test
- public void testDistributionParameterGroup_InvalidName() throws PolicyDistributionException, CommandLineException {
+ void testDistributionParameterGroup_InvalidName() throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_InvalidName.json", PolicyDistributionException.class,
"\"name\" value \" \" INVALID, is blank");
}
@Test
- public void testDistributionParameterGroup_NoReceptionHandler()
+ void testDistributionParameterGroup_NoReceptionHandler()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_NoReceptionHandler.json", PolicyDistributionException.class,
"\"receptionHandlerParameters\" value \"null\" INVALID, is null");
}
@Test
- public void testDistributionParameterGroup_EmptyReceptionHandler()
+ void testDistributionParameterGroup_EmptyReceptionHandler()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_EmptyReceptionHandler.json", PolicyDistributionException.class,
"\"receptionHandlerParameters\" value \"{}\" INVALID, minimum number of elements: 1");
}
@Test
- public void testDistributionParameterGroup_NoPolicyDecoder()
+ void testDistributionParameterGroup_NoPolicyDecoder()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_NoPolicyDecoder.json", PolicyDistributionException.class,
"\"policyDecoders\" value \"null\" INVALID, is null");
}
@Test
- public void testDistributionParameterGroup_NoPolicyForwarder()
+ void testDistributionParameterGroup_NoPolicyForwarder()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_NoPolicyForwarder.json", PolicyDistributionException.class,
"\"policyForwarderConfigurationParameters\" value \"null\" INVALID, is null");
}
@Test
- public void testDistributionParameterGroup_EmptyPolicyDecoder()
+ void testDistributionParameterGroup_EmptyPolicyDecoder()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_EmptyPolicyDecoder.json", PolicyDistributionException.class,
"\"policyDecoders\" value \"{}\" INVALID, minimum number of elements: 1");
}
@Test
- public void testDistributionParameterGroup_EmptyPolicyForwarder()
+ void testDistributionParameterGroup_EmptyPolicyForwarder()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_EmptyPolicyForwarder.json", PolicyDistributionException.class,
"\"policyForwarders\" value \"{}\" INVALID, minimum number of elements: 1");
}
@Test
- public void testDistributionParameterGroup_InvalidReceptionHandlerParameters()
+ void testDistributionParameterGroup_InvalidReceptionHandlerParameters()
throws PolicyDistributionException, IOException, CommandLineException {
- String resultString = Files
+ var resultString = Files
.readString(
Paths.get("src/test/resources/expectedValidationResults/InvalidReceptionHandlerParameters.txt"))
.trim().replaceAll("\\r\\n", "\\\n");
@@ -194,77 +194,77 @@
}
@Test
- public void testDistributionParameterGroup_InvalidDecoderAndForwarderParameters()
+ void testDistributionParameterGroup_InvalidDecoderAndForwarderParameters()
throws PolicyDistributionException, IOException, CommandLineException {
- String resultString = new String(Files
+ var resultString = Files
.readString(Paths
.get("src/test/resources/expectedValidationResults/InvalidDecoderAndForwarderParameters.txt"))
- .trim().replaceAll("\\r\\n", "\\\n"));
+ .trim().replaceAll("\\r\\n", "\\\n");
verifyFailure("DistributionConfigParameters_InvalidDecoderAndForwarderParameters.json",
PolicyDistributionException.class, resultString);
}
@Test
- public void testDistributionParameterGroup_InvalidRestServerParameters()
+ void testDistributionParameterGroup_InvalidRestServerParameters()
throws PolicyDistributionException, IOException, CommandLineException {
- String resultString = new String(Files
+ var resultString = Files
.readString(Paths.get("src/test/resources/expectedValidationResults/InvalidRestServerParameters.txt"))
- .trim().replaceAll("\\r\\n", "\\\n"));
+ .trim().replaceAll("\\r\\n", "\\\n");
verifyFailure("DistributionConfigParameters_InvalidRestServerParameters.json",
PolicyDistributionException.class, resultString);
}
@Test
- public void testDistributionVersion() throws PolicyDistributionException, CommandLineException {
+ void testDistributionVersion() throws PolicyDistributionException, CommandLineException {
final String[] distributionConfigParameters = {"-v"};
- final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
- final String version = arguments.parse(distributionConfigParameters);
+ final var arguments = new DistributionCommandLineArguments();
+ final var version = arguments.parse(distributionConfigParameters);
assertTrue(version.startsWith("ONAP Policy Framework Distribution Service"));
}
@Test
- public void testDistributionHelp() throws PolicyDistributionException, CommandLineException {
+ void testDistributionHelp() throws PolicyDistributionException, CommandLineException {
final String[] distributionConfigParameters = {"-h"};
- final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
- final String help = arguments.parse(distributionConfigParameters);
+ final var arguments = new DistributionCommandLineArguments();
+ final var help = arguments.parse(distributionConfigParameters);
assertTrue(help.startsWith("usage:"));
}
@Test
- public void testDistributionInvalidOption() throws PolicyDistributionException {
+ void testDistributionInvalidOption() throws PolicyDistributionException {
final String[] distributionConfigParameters = {"-d"};
- final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
+ final var arguments = new DistributionCommandLineArguments();
assertThatThrownBy(() -> arguments.parse(distributionConfigParameters))
.hasMessageContaining("invalid command line arguments specified");
}
@Test
- public void testDistributionParameterGroup_InvalidReceptionHandlerClass()
+ void testDistributionParameterGroup_InvalidReceptionHandlerClass()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_InvalidReceptionHandlerClass.json",
PolicyDistributionException.class, "could not find class");
}
@Test
- public void testDistributionParameterGroup_EmptyReceptionHandlerClass()
+ void testDistributionParameterGroup_EmptyReceptionHandlerClass()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_EmptyReceptionHandlerClass.json", PolicyDistributionException.class,
"invalid in JSON file");
}
@Test
- public void testDistributionParameterGroup_InvalidDecoderConfigurationClassName()
+ void testDistributionParameterGroup_InvalidDecoderConfigurationClassName()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_InvalidDecoderConfigurationClassName.json",
PolicyDistributionException.class, "parameter \"parameterClassName\" value \"\" invalid in JSON file");
}
@Test
- public void testDistributionParameterGroup_UnknownDecoderConfigurationClassName()
+ void testDistributionParameterGroup_UnknownDecoderConfigurationClassName()
throws PolicyDistributionException, CommandLineException {
verifyFailure("DistributionConfigParameters_UnknownDecoderConfigurationClassName.json",
PolicyDistributionException.class,
@@ -275,10 +275,10 @@
throws PolicyDistributionException, CommandLineException {
final String[] distributionConfigParameters = {"-c", "parameters/" + fileName};
- final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments();
+ final var arguments = new DistributionCommandLineArguments();
arguments.parse(distributionConfigParameters);
- DistributionParameterHandler paramHandler = new DistributionParameterHandler();
+ var paramHandler = new DistributionParameterHandler();
assertThatThrownBy(() -> paramHandler.getParameters(arguments)).isInstanceOf(clazz)
.hasMessageContaining(expectedMessage);
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPluginHandlerParameters.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPluginHandlerParameters.java
index 9def403..e7a1590 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPluginHandlerParameters.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPluginHandlerParameters.java
@@ -23,31 +23,27 @@
package org.onap.policy.distribution.main.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.util.Map;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
+import org.junit.jupiter.api.Test;
import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
-import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters;
/**
* Class to perform unit test of PluginHandlerParameters.
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class TestPluginHandlerParameters {
+class TestPluginHandlerParameters {
CommonTestData commonTestData = new CommonTestData();
@Test
- public void testPluginHandlerParameters() {
- final Map<String, PolicyDecoderParameters> policyDecoders = commonTestData.getPolicyDecoders(false);
- final Map<String, PolicyForwarderParameters> policyForwarders = commonTestData.getPolicyForwarders(false);
- final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
- final ValidationResult validationResult = pHParameters.validate();
+ void testPluginHandlerParameters() {
+ final var policyDecoders = commonTestData.getPolicyDecoders(false);
+ final var policyForwarders = commonTestData.getPolicyForwarders(false);
+ final var pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
+ final var validationResult = pHParameters.validate();
assertEquals(policyDecoders.get(CommonTestData.DUMMY_DECODER_KEY),
pHParameters.getPolicyDecoders().get(CommonTestData.DUMMY_DECODER_KEY));
assertEquals(policyForwarders.get(CommonTestData.DUMMY_ENGINE_FORWARDER_KEY),
@@ -56,36 +52,36 @@
}
@Test
- public void testPluginHandlerParameters_NullPolicyDecoders() {
- final Map<String, PolicyForwarderParameters> policyForwarders = commonTestData.getPolicyForwarders(false);
- final PluginHandlerParameters pHParameters = new PluginHandlerParameters(null, policyForwarders);
+ void testPluginHandlerParameters_NullPolicyDecoders() {
+ final var policyForwarders = commonTestData.getPolicyForwarders(false);
+ final var pHParameters = new PluginHandlerParameters(null, policyForwarders);
assertThat(pHParameters.validate().getResult()).contains("\"policyDecoders\" value \"null\" INVALID, is null");
}
@Test
- public void testPluginHandlerParameters_NullPolicyForwarders() {
- final Map<String, PolicyDecoderParameters> policyDecoders = commonTestData.getPolicyDecoders(false);
- final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, null);
+ void testPluginHandlerParameters_NullPolicyForwarders() {
+ final var policyDecoders = commonTestData.getPolicyDecoders(false);
+ final var pHParameters = new PluginHandlerParameters(policyDecoders, null);
assertThat(pHParameters.validate().getResult())
.contains("\"policyForwarders\" value \"null\" INVALID, is null");
}
@Test
- public void testPluginHandlerParameters_EmptyPolicyDecoders() {
- final Map<String, PolicyDecoderParameters> policyDecoders = commonTestData.getPolicyDecoders(true);
- final Map<String, PolicyForwarderParameters> policyForwarders = commonTestData.getPolicyForwarders(false);
- final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
- ValidationResult result = pHParameters.validate();
+ void testPluginHandlerParameters_EmptyPolicyDecoders() {
+ final var policyDecoders = commonTestData.getPolicyDecoders(true);
+ final var policyForwarders = commonTestData.getPolicyForwarders(false);
+ final var pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
+ var result = pHParameters.validate();
assertFalse(result.isValid());
assertThat(pHParameters.validate().getResult()).contains("\"policyDecoders\"", "minimum");
}
@Test
- public void testPluginHandlerParameters_EmptyPolicyForwarders() {
- final Map<String, PolicyForwarderParameters> policyForwarders = commonTestData.getPolicyForwarders(true);
- final Map<String, PolicyDecoderParameters> policyDecoders = commonTestData.getPolicyDecoders(false);
- final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
- ValidationResult result = pHParameters.validate();
+ void testPluginHandlerParameters_EmptyPolicyForwarders() {
+ final var policyForwarders = commonTestData.getPolicyForwarders(true);
+ final var policyDecoders = commonTestData.getPolicyDecoders(false);
+ final var pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
+ var result = pHParameters.validate();
assertFalse(result.isValid());
assertThat(pHParameters.validate().getResult()).contains("\"policyForwarders\"", "minimum");
}
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 4195f1b..74b8c21 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
@@ -22,15 +22,14 @@
package org.onap.policy.distribution.main.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.onap.policy.distribution.main.parameters.CommonTestData.DECODER_CLASS_NAME;
import static org.onap.policy.distribution.main.parameters.CommonTestData.DECODER_CONFIGURATION_PARAMETERS;
import static org.onap.policy.distribution.main.parameters.CommonTestData.DECODER_TYPE;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ValidationResult;
+import org.junit.jupiter.api.Test;
import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters;
/**
@@ -38,13 +37,13 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class TestPolicyDecoderParameters {
+class TestPolicyDecoderParameters {
@Test
- public void testPolicyDecoderParameters() {
- final PolicyDecoderParameters pDParameters =
+ void testPolicyDecoderParameters() {
+ final var pDParameters =
new PolicyDecoderParameters(DECODER_TYPE, DECODER_CLASS_NAME, DECODER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pDParameters.validate();
+ final var validationResult = pDParameters.validate();
assertEquals(DECODER_TYPE, pDParameters.getDecoderType());
assertEquals(DECODER_CLASS_NAME, pDParameters.getDecoderClassName());
assertEquals(DECODER_CONFIGURATION_PARAMETERS, pDParameters.getDecoderConfigurationName());
@@ -52,10 +51,10 @@
}
@Test
- public void testPolicyDecoderParameters_InvalidDecoderType() {
- final PolicyDecoderParameters pDParameters =
+ void testPolicyDecoderParameters_InvalidDecoderType() {
+ final var pDParameters =
new PolicyDecoderParameters("", DECODER_CLASS_NAME, DECODER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pDParameters.validate();
+ final var validationResult = pDParameters.validate();
assertEquals("", pDParameters.getDecoderType());
assertEquals(DECODER_CLASS_NAME, pDParameters.getDecoderClassName());
assertFalse(validationResult.isValid());
@@ -63,10 +62,10 @@
}
@Test
- public void testPolicyDecoderParameters_InvalidDecoderClassName() {
- final PolicyDecoderParameters pDParameters =
+ void testPolicyDecoderParameters_InvalidDecoderClassName() {
+ final var pDParameters =
new PolicyDecoderParameters(DECODER_TYPE, "", DECODER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pDParameters.validate();
+ final var validationResult = pDParameters.validate();
assertEquals(DECODER_TYPE, pDParameters.getDecoderType());
assertEquals("", pDParameters.getDecoderClassName());
assertFalse(validationResult.isValid());
@@ -74,10 +73,10 @@
}
@Test
- public void testPolicyDecoderParameters_InvalidDecoderTypeAndClassName() {
- final PolicyDecoderParameters pDParameters =
+ void testPolicyDecoderParameters_InvalidDecoderTypeAndClassName() {
+ final var pDParameters =
new PolicyDecoderParameters("", "", DECODER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pDParameters.validate();
+ final var validationResult = pDParameters.validate();
assertEquals("", pDParameters.getDecoderType());
assertEquals("", pDParameters.getDecoderClassName());
assertFalse(validationResult.isValid());
@@ -86,32 +85,32 @@
}
@Test
- public void testPolicyDecoderParameters_NullDecoderType() {
- final PolicyDecoderParameters pDParameters =
+ void testPolicyDecoderParameters_NullDecoderType() {
+ final var pDParameters =
new PolicyDecoderParameters(null, DECODER_CLASS_NAME, DECODER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pDParameters.validate();
- assertEquals(null, pDParameters.getDecoderType());
+ final var validationResult = pDParameters.validate();
+ assertThat(pDParameters.getDecoderType()).isNull();
assertEquals(DECODER_CLASS_NAME, pDParameters.getDecoderClassName());
assertFalse(validationResult.isValid());
assertThat(validationResult.getResult()).contains("\"decoderType\" value \"null\" INVALID, is null");
}
@Test
- public void testPolicyDecoderParameters_NullDecoderClassName() {
- final PolicyDecoderParameters pDParameters =
+ void testPolicyDecoderParameters_NullDecoderClassName() {
+ final var pDParameters =
new PolicyDecoderParameters(DECODER_TYPE, null, DECODER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pDParameters.validate();
+ final var validationResult = pDParameters.validate();
assertEquals(DECODER_TYPE, pDParameters.getDecoderType());
- assertEquals(null, pDParameters.getDecoderClassName());
+ assertThat(pDParameters.getDecoderClassName()).isNull();
assertFalse(validationResult.isValid());
assertThat(validationResult.getResult()).contains("\"decoderClassName\" value \"null\" INVALID, is null");
}
@Test
- public void testPolicyDecoderParameters_InvalidDecoderClass() {
- final PolicyDecoderParameters pDParameters = new PolicyDecoderParameters(DECODER_TYPE,
+ void testPolicyDecoderParameters_InvalidDecoderClass() {
+ final var pDParameters = new PolicyDecoderParameters(DECODER_TYPE,
DECODER_CLASS_NAME + "Invalid", DECODER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pDParameters.validate();
+ final var validationResult = pDParameters.validate();
assertEquals(DECODER_TYPE, pDParameters.getDecoderType());
assertEquals(DECODER_CLASS_NAME + "Invalid", pDParameters.getDecoderClassName());
assertFalse(validationResult.isValid());
diff --git a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyForwarderParameters.java b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyForwarderParameters.java
index 5dc1b44..b088194 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyForwarderParameters.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/parameters/TestPolicyForwarderParameters.java
@@ -22,14 +22,14 @@
package org.onap.policy.distribution.main.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.onap.policy.distribution.main.parameters.CommonTestData.FORWARDER_CLASS_NAME;
import static org.onap.policy.distribution.main.parameters.CommonTestData.FORWARDER_CONFIGURATION_PARAMETERS;
import static org.onap.policy.distribution.main.parameters.CommonTestData.FORWARDER_TYPE;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
@@ -38,23 +38,23 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class TestPolicyForwarderParameters {
+class TestPolicyForwarderParameters {
@Test
- public void testPolicyForwarderParameters() {
- final PolicyForwarderParameters pFParameters =
+ void testPolicyForwarderParameters() {
+ final var pFParameters =
new PolicyForwarderParameters(FORWARDER_TYPE, FORWARDER_CLASS_NAME, FORWARDER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pFParameters.validate();
+ final var validationResult = pFParameters.validate();
assertEquals(FORWARDER_TYPE, pFParameters.getForwarderType());
assertEquals(FORWARDER_CLASS_NAME, pFParameters.getForwarderClassName());
assertTrue(validationResult.isValid());
}
@Test
- public void testPolicyForwarderParameters_InvalidForwarderType() {
- final PolicyForwarderParameters pFParameters =
+ void testPolicyForwarderParameters_InvalidForwarderType() {
+ final var pFParameters =
new PolicyForwarderParameters("", FORWARDER_CLASS_NAME, FORWARDER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pFParameters.validate();
+ final var validationResult = pFParameters.validate();
assertEquals("", pFParameters.getForwarderType());
assertEquals(FORWARDER_CLASS_NAME, pFParameters.getForwarderClassName());
assertFalse(validationResult.isValid());
@@ -62,10 +62,10 @@
}
@Test
- public void testPolicyForwarderParameters_InvalidForwarderClassName() {
- final PolicyForwarderParameters pFParameters =
+ void testPolicyForwarderParameters_InvalidForwarderClassName() {
+ final var pFParameters =
new PolicyForwarderParameters(FORWARDER_TYPE, "", FORWARDER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pFParameters.validate();
+ final var validationResult = pFParameters.validate();
assertEquals(CommonTestData.FORWARDER_TYPE, pFParameters.getForwarderType());
assertEquals("", pFParameters.getForwarderClassName());
assertFalse(validationResult.isValid());
@@ -73,10 +73,10 @@
}
@Test
- public void testPolicyForwarderParameters_InvalidForwarderTypeAndClassName() {
- final PolicyForwarderParameters pFParameters =
+ void testPolicyForwarderParameters_InvalidForwarderTypeAndClassName() {
+ final var pFParameters =
new PolicyForwarderParameters("", "", FORWARDER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pFParameters.validate();
+ final var validationResult = pFParameters.validate();
assertEquals("", pFParameters.getForwarderType());
assertEquals("", pFParameters.getForwarderClassName());
assertFalse(validationResult.isValid());
@@ -85,32 +85,32 @@
}
@Test
- public void testPolicyForwarderParameters_NullForwarderType() {
- final PolicyForwarderParameters pFParameters =
+ void testPolicyForwarderParameters_NullForwarderType() {
+ final var pFParameters =
new PolicyForwarderParameters(null, FORWARDER_CLASS_NAME, FORWARDER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pFParameters.validate();
- assertEquals(null, pFParameters.getForwarderType());
+ final var validationResult = pFParameters.validate();
+ assertThat(pFParameters.getForwarderType()).isNull();
assertEquals(FORWARDER_CLASS_NAME, pFParameters.getForwarderClassName());
assertFalse(validationResult.isValid());
assertThat(validationResult.getResult()).contains("\"forwarderType\" value \"null\" INVALID, is null");
}
@Test
- public void testPolicyForwarderParameters_NullForwarderClassName() {
- final PolicyForwarderParameters pFParameters =
+ void testPolicyForwarderParameters_NullForwarderClassName() {
+ final var pFParameters =
new PolicyForwarderParameters(FORWARDER_TYPE, null, FORWARDER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pFParameters.validate();
+ final var validationResult = pFParameters.validate();
assertEquals(FORWARDER_TYPE, pFParameters.getForwarderType());
- assertEquals(null, pFParameters.getForwarderClassName());
+ assertThat(pFParameters.getForwarderClassName()).isNull();
assertFalse(validationResult.isValid());
assertThat(validationResult.getResult()).contains("\"forwarderClassName\" value \"null\" INVALID, is null");
}
@Test
- public void testPolicyForwarderParameters_InvalidForwarderClass() {
- final PolicyForwarderParameters pFParameters = new PolicyForwarderParameters(FORWARDER_TYPE,
+ void testPolicyForwarderParameters_InvalidForwarderClass() {
+ final var pFParameters = new PolicyForwarderParameters(FORWARDER_TYPE,
FORWARDER_CLASS_NAME + "Invalid", FORWARDER_CONFIGURATION_PARAMETERS);
- final ValidationResult validationResult = pFParameters.validate();
+ final var validationResult = pFParameters.validate();
assertEquals(FORWARDER_TYPE, pFParameters.getForwarderType());
assertEquals(FORWARDER_CLASS_NAME + "Invalid", pFParameters.getForwarderClassName());
assertFalse(validationResult.isValid());
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 c02b96b..41a82bc 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
@@ -22,13 +22,11 @@
package org.onap.policy.distribution.main.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
+import org.junit.jupiter.api.Test;
import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
/**
@@ -36,16 +34,16 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class TestReceptionHandlerParameters {
+class TestReceptionHandlerParameters {
CommonTestData commonTestData = new CommonTestData();
@Test
- public void testReceptionHandlerParameters() {
- final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
+ void testReceptionHandlerParameters() {
+ final var pHParameters = commonTestData.getPluginHandlerParameters(false);
+ final var rHParameters = new ReceptionHandlerParameters(
CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- final ValidationResult validationResult = rHParameters.validate();
+ final var validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
assertEquals(CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS,
@@ -55,13 +53,13 @@
}
@Test
- public void testReceptionHandlerParameters_NullReceptionHandlerType() {
- final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final ReceptionHandlerParameters rHParameters =
+ void testReceptionHandlerParameters_NullReceptionHandlerType() {
+ final var pHParameters = commonTestData.getPluginHandlerParameters(false);
+ final var rHParameters =
new ReceptionHandlerParameters(null, CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- final ValidationResult validationResult = rHParameters.validate();
- assertEquals(null, rHParameters.getReceptionHandlerType());
+ final var validationResult = rHParameters.validate();
+ assertThat(rHParameters.getReceptionHandlerType()).isNull();
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
assertEquals(CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS,
rHParameters.getReceptionHandlerConfigurationName());
@@ -71,14 +69,14 @@
}
@Test
- public void testReceptionHandlerParameters_NullReceptionHandlerClassName() {
- final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final ReceptionHandlerParameters rHParameters =
+ void testReceptionHandlerParameters_NullReceptionHandlerClassName() {
+ final var pHParameters = commonTestData.getPluginHandlerParameters(false);
+ final var rHParameters =
new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE, null,
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- final ValidationResult validationResult = rHParameters.validate();
+ final var validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
- assertEquals(null, rHParameters.getReceptionHandlerClassName());
+ assertThat(rHParameters.getReceptionHandlerClassName()).isNull();
assertEquals(CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS,
rHParameters.getReceptionHandlerConfigurationName());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
@@ -88,12 +86,12 @@
}
@Test
- public void testReceptionHandlerParameters_EmptyReceptionHandlerType() {
- final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final ReceptionHandlerParameters rHParameters =
+ void testReceptionHandlerParameters_EmptyReceptionHandlerType() {
+ final var pHParameters = commonTestData.getPluginHandlerParameters(false);
+ final var rHParameters =
new ReceptionHandlerParameters("", CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- final ValidationResult validationResult = rHParameters.validate();
+ final var validationResult = rHParameters.validate();
assertEquals("", rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME, rHParameters.getReceptionHandlerClassName());
assertEquals(pHParameters, rHParameters.getPluginHandlerParameters());
@@ -102,12 +100,12 @@
}
@Test
- public void testReceptionHandlerParameters_EmptyReceptionHandlerClassName() {
- final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
- final ReceptionHandlerParameters rHParameters =
+ void testReceptionHandlerParameters_EmptyReceptionHandlerClassName() {
+ final var pHParameters = commonTestData.getPluginHandlerParameters(false);
+ final var rHParameters =
new ReceptionHandlerParameters(CommonTestData.RECEPTION_HANDLER_TYPE, "",
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- final ValidationResult validationResult = rHParameters.validate();
+ final var validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals("", rHParameters.getReceptionHandlerClassName());
assertEquals(CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS,
@@ -118,24 +116,24 @@
}
@Test
- public void testReceptionHandlerParameters_EmptyPluginHandler() {
- final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(true);
- final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
+ void testReceptionHandlerParameters_EmptyPluginHandler() {
+ final var pHParameters = commonTestData.getPluginHandlerParameters(true);
+ final var rHParameters = new ReceptionHandlerParameters(
CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME,
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- ValidationResult result = rHParameters.validate();
+ var result = rHParameters.validate();
assertFalse(result.isValid());
assertThat(result.getResult()).contains("\"policyForwarders\"", "minimum");
}
@Test
- public void testReceptionHandlerParameters_InvalidReceptionHandlerClass() {
- final PluginHandlerParameters pHParameters = commonTestData.getPluginHandlerParameters(false);
+ void testReceptionHandlerParameters_InvalidReceptionHandlerClass() {
+ final var pHParameters = commonTestData.getPluginHandlerParameters(false);
- final ReceptionHandlerParameters rHParameters = new ReceptionHandlerParameters(
+ final var rHParameters = new ReceptionHandlerParameters(
CommonTestData.RECEPTION_HANDLER_TYPE, CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid",
CommonTestData.RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
- final ValidationResult validationResult = rHParameters.validate();
+ final var validationResult = rHParameters.validate();
assertEquals(CommonTestData.RECEPTION_HANDLER_TYPE, rHParameters.getReceptionHandlerType());
assertEquals(CommonTestData.RECEPTION_HANDLER_CLASS_NAME + "Invalid",
rHParameters.getReceptionHandlerClassName());
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
index ce4cda2..4673f38 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
@@ -25,22 +25,17 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.core.MediaType;
import java.io.IOException;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.internal.util.reflection.Whitebox;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.http.server.RestServer;
-import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.network.NetworkUtil;
@@ -53,7 +48,7 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class TestDistributionRestServer {
+class TestDistributionRestServer {
private static final String NOT_ALIVE = "not alive";
private static final String ALIVE = "alive";
@@ -62,32 +57,31 @@
private int port;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
ParameterService.clear();
}
@Test
- public void testHealthCheckSuccess() throws IOException, InterruptedException {
- final String reportString =
+ void testHealthCheckSuccess() throws IOException, InterruptedException {
+ final var reportString =
"HealthCheckReport(name=Policy SSD, url=" + SELF + ", healthy=true, code=200, message=alive)";
- final Main main = startDistributionService();
- final HealthCheckReport report = performHealthCheck();
+ final var main = startDistributionService();
+ final var report = performHealthCheck();
validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
assertThatCode(() -> stopDistributionService(main)).doesNotThrowAnyException();
}
@Test
- public void testHealthCheckFailure() throws IOException, InterruptedException {
+ void testHealthCheckFailure() throws IOException, InterruptedException {
port = NetworkUtil.allocPort();
- final String reportString =
+ final var reportString =
"HealthCheckReport(name=Policy SSD, url=" + SELF + ", healthy=false, code=500, message=not alive)";
- final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false);
- Whitebox.setInternalState(restServerParams, "port", port);
+ final var restServerParams = new CommonTestData().getRestServerParameters(port);
restServerParams.setName(CommonTestData.DISTRIBUTION_GROUP_NAME);
- final RestServer restServer = new RestServer(restServerParams, null, DistributionRestController.class);
+ final var restServer = new RestServer(restServerParams, null, DistributionRestController.class);
restServer.start();
- final HealthCheckReport report = performHealthCheck();
+ final var report = performHealthCheck();
validateReport(NAME, SELF, false, 500, NOT_ALIVE, reportString, report);
assertTrue(restServer.isAlive());
assertThat(restServer.toString()).startsWith("RestServer(servers=");
@@ -104,16 +98,16 @@
main.shutdown();
}
- private HealthCheckReport performHealthCheck() throws InterruptedException, IOException {
- final ClientConfig clientConfig = new ClientConfig();
+ private HealthCheckReport performHealthCheck() throws InterruptedException {
+ final var clientConfig = new ClientConfig();
- final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
+ final var feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
clientConfig.register(feature);
- final Client client = ClientBuilder.newClient(clientConfig);
- final WebTarget webTarget = client.target("http://localhost:" + port + "/healthcheck");
+ final var client = ClientBuilder.newClient(clientConfig);
+ final var webTarget = client.target("http://localhost:" + port + "/healthcheck");
- final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
+ final var invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
CommonTestData.awaitServer(port);
return invocationBuilder.get(HealthCheckReport.class);
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java
index 82e40cc..ffe0c8d 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java
@@ -23,21 +23,16 @@
package org.onap.policy.distribution.main.rest;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.core.MediaType;
import java.io.IOException;
import java.security.SecureRandom;
-import java.util.Properties;
import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.network.NetworkUtil;
@@ -51,7 +46,7 @@
*
* @author Libo Zhu (libo.zhu@intel.com)
*/
-public class TestHttpsDistributionRestServer {
+class TestHttpsDistributionRestServer {
private static final String ALIVE = "alive";
private static final String SELF = NetworkUtil.getHostname();
@@ -59,23 +54,23 @@
private int port;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
ParameterService.clear();
}
@Test
- public void testHttpsHealthCheckSuccess() throws Exception {
- final String reportString =
+ void testHttpsHealthCheckSuccess() throws Exception {
+ final var reportString =
"HealthCheckReport(name=Policy SSD, url=" + SELF + ", healthy=true, code=200, message=alive)";
- final Main main = startDistributionService();
- final HealthCheckReport report = performHealthCheck();
+ final var main = startDistributionService();
+ final var report = performHealthCheck();
validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
assertThatCode(() -> stopDistributionService(main)).doesNotThrowAnyException();
}
private Main startDistributionService() throws IOException, InterruptedException {
- final Properties systemProps = System.getProperties();
+ final var systemProps = System.getProperties();
systemProps.put("javax.net.ssl.keyStore", new SelfSignedKeyStore().getKeystoreName());
systemProps.put("javax.net.ssl.keyStorePassword", SelfSignedKeyStore.KEYSTORE_PASSWORD);
System.setProperties(systemProps);
@@ -91,19 +86,19 @@
private HealthCheckReport performHealthCheck() throws Exception {
- final TrustManager[] noopTrustManager = NetworkUtil.getAlwaysTrustingManager();
+ final var noopTrustManager = NetworkUtil.getAlwaysTrustingManager();
- final SSLContext sc = SSLContext.getInstance("TLSv1.2");
+ final var sc = SSLContext.getInstance("TLSv1.2");
sc.init(null, noopTrustManager, new SecureRandom());
- final ClientBuilder clientBuilder =
+ final var clientBuilder =
ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
- final Client client = clientBuilder.build();
- final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
+ final var client = clientBuilder.build();
+ final var feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
client.register(feature);
- final WebTarget webTarget = client.target("https://localhost:" + port + "/healthcheck");
+ final var webTarget = client.target("https://localhost:" + port + "/healthcheck");
- final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
+ final var invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
CommonTestData.awaitServer(port);
return invocationBuilder.get(HealthCheckReport.class);
diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java
index dd498bf..af0b58e 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionActivator.java
@@ -22,17 +22,16 @@
package org.onap.policy.distribution.main.startstop;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.main.PolicyDistributionException;
import org.onap.policy.distribution.main.parameters.CommonTestData;
-import org.onap.policy.distribution.main.parameters.DistributionParameterGroup;
import org.onap.policy.distribution.main.parameters.DistributionParameterHandler;
import org.onap.policy.distribution.main.testclasses.DummyPolicyForwarderParameterGroup;
@@ -41,24 +40,24 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class TestDistributionActivator {
+class TestDistributionActivator {
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
ParameterService.clear();
}
@Test
- public void testDistributionActivator() throws PolicyDistributionException, IOException {
+ void testDistributionActivator() throws PolicyDistributionException, IOException {
CommonTestData.makeConfigFile("parameters/DistributionConfigParameters.json");
final String[] distributionConfigParameters = { "-c", CommonTestData.CONFIG_FILE };
- final DistributionCommandLineArguments arguments =
+ final var arguments =
new DistributionCommandLineArguments(distributionConfigParameters);
- final DistributionParameterGroup parGroup = new DistributionParameterHandler().getParameters(arguments);
+ final var parGroup = new DistributionParameterHandler().getParameters(arguments);
- final DistributionActivator activator = new DistributionActivator(parGroup);
+ final var activator = new DistributionActivator(parGroup);
activator.initialize();
assertTrue(activator.getDistributionParameterGroup().isValid());
assertTrue(DistributionActivator.isAlive());
diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionCommandLineArguments.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionCommandLineArguments.java
index 0a0e5fa..09ab131 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionCommandLineArguments.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestDistributionCommandLineArguments.java
@@ -24,7 +24,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertThrows;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.distribution.main.PolicyDistributionRuntimeException;
/**
@@ -33,49 +33,49 @@
* @author Adheli Tavares (adheli.tavares@est.tech)
*
*/
-public class TestDistributionCommandLineArguments {
+class TestDistributionCommandLineArguments {
@Test
- public void testDistributionOnlyFileName() {
+ void testDistributionOnlyFileName() {
String[] testArgs = {"src/test/resources/parameters/DistributionConfigParameters.json"};
assertThrows(PolicyDistributionRuntimeException.class, () -> new DistributionCommandLineArguments(testArgs));
}
@Test
- public void testDistributionCommandLineArgumentsException() {
+ void testDistributionCommandLineArgumentsException() {
String[] wrongParams = {"arg1", "nothing", "{\"someJson\":1}"};
assertThrows(PolicyDistributionRuntimeException.class, () -> new DistributionCommandLineArguments(wrongParams));
}
@Test
- public void testValidateFileNameEmpty() {
+ void testValidateFileNameEmpty() {
String[] argsOnlyKeyNoValue = {"-c", ""};
assertValidate(argsOnlyKeyNoValue, "policy-distribution configuration file was not specified as an argument");
}
@Test
- public void testValidateFileNameDoesNotExist() {
+ void testValidateFileNameDoesNotExist() {
String[] fileNameNotExistentArgs = {"-c", "someFileName.json"};
assertValidate(fileNameNotExistentArgs,
"policy-distribution configuration file \"someFileName.json\" does not exist");
}
@Test
- public void testValidateFileNameIsNotFile() {
+ void testValidateFileNameIsNotFile() {
String[] folderAsFileNameArgs = {"-c", "src/test/resources/parameters"};
assertValidate(folderAsFileNameArgs,
"policy-distribution configuration file \"src/test/resources/parameters\" is not a normal file");
}
@Test
- public void testDistributionVersion() {
+ void testDistributionVersion() {
String[] testArgs = {"-v"};
- DistributionCommandLineArguments sutArgs = new DistributionCommandLineArguments(testArgs);
+ var sutArgs = new DistributionCommandLineArguments(testArgs);
assertThat(sutArgs.version()).startsWith("ONAP Policy Framework Distribution Service");
}
private void assertValidate(String[] testArgs, String expectedErrorMsg) {
- DistributionCommandLineArguments sutArgs = new DistributionCommandLineArguments(testArgs);
- assertThatThrownBy(() -> sutArgs.validate()).hasMessage(expectedErrorMsg);
+ var sutArgs = new DistributionCommandLineArguments(testArgs);
+ assertThatThrownBy(sutArgs::validate).hasMessage(expectedErrorMsg);
}
}
diff --git a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
index bdb2ba7..831b337 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/startstop/TestMain.java
@@ -25,12 +25,12 @@
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.resources.MessageConstants;
import org.onap.policy.distribution.main.PolicyDistributionException;
@@ -42,25 +42,25 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class TestMain {
+class TestMain {
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
ParameterService.clear();
}
@Test
- public void testMain() throws PolicyDistributionException, IOException {
+ void testMain() throws PolicyDistributionException, IOException {
CommonTestData.makeConfigFile("parameters/DistributionConfigParameters.json");
final String[] distributionConfigParameters = { "-c", CommonTestData.CONFIG_FILE };
- final Main main = new Main(distributionConfigParameters);
+ final var main = new Main(distributionConfigParameters);
assertTrue(main.getDistributionParameterGroup().isValid());
assertEquals(CommonTestData.DISTRIBUTION_GROUP_NAME, main.getDistributionParameterGroup().getName());
main.shutdown();
}
@Test
- public void testMain_NoArguments() {
+ void testMain_NoArguments() {
final String[] distributionConfigParameters = {};
assertThatThrownBy(() -> new Main(distributionConfigParameters))
.isInstanceOf(PolicyDistributionRuntimeException.class)
@@ -68,7 +68,7 @@
}
@Test
- public void testMain_InvalidArguments() {
+ void testMain_InvalidArguments() {
final String[] distributionConfigParameters = {"parameters/DistributionConfigParameters.json"};
assertThatThrownBy(() -> new Main(distributionConfigParameters))
.isInstanceOf(PolicyDistributionRuntimeException.class)
@@ -76,7 +76,7 @@
}
@Test
- public void testMain_Help() {
+ void testMain_Help() {
assertThatCode(() -> {
final String[] distributionConfigParameters =
{ "-h" };
@@ -85,7 +85,7 @@
}
@Test
- public void testMain_InvalidParameters() {
+ void testMain_InvalidParameters() {
final String[] distributionConfigParameters =
{"-c", "parameters/DistributionConfigParameters_InvalidName.json"};
assertThatThrownBy(() -> new Main(distributionConfigParameters))
diff --git a/model/pom.xml b/model/pom.xml
index a9635de..3a7f0c6 100644
--- a/model/pom.xml
+++ b/model/pom.xml
@@ -18,12 +18,13 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>policy-distribution</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>distribution-model</artifactId>
diff --git a/model/src/test/java/org/onap/policy/distribution/model/TestModels.java b/model/src/test/java/org/onap/policy/distribution/model/TestModels.java
index e573302..3aea3ef 100644
--- a/model/src/test/java/org/onap/policy/distribution/model/TestModels.java
+++ b/model/src/test/java/org/onap/policy/distribution/model/TestModels.java
@@ -21,22 +21,21 @@
package org.onap.policy.distribution.model;
import com.openpojo.reflection.filters.FilterPackageInfo;
-import com.openpojo.validation.Validator;
import com.openpojo.validation.ValidatorBuilder;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Class to perform unit testing of all policy models.
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class TestModels {
+class TestModels {
@Test
- public void testAllModels() {
- final Validator validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester()).build();
+ void testAllModels() {
+ final var validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester()).build();
validator.validate(PolicyInput.class.getPackage().getName(), new FilterPackageInfo());
}
}
diff --git a/packages/policy-distribution-docker/pom.xml b/packages/policy-distribution-docker/pom.xml
index 0ebabfc..5559455 100644
--- a/packages/policy-distribution-docker/pom.xml
+++ b/packages/policy-distribution-docker/pom.xml
@@ -22,14 +22,14 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>distribution-packages</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<packaging>pom</packaging>
@@ -99,10 +99,12 @@
<dependencySets>
<dependencySet>
<includes>
- <include>org.onap.policy.distribution:policy-distribution-tarball</include>
+ <include>org.onap.policy.distribution:policy-distribution-tarball
+ </include>
</includes>
<outputDirectory>/lib</outputDirectory>
- <outputFileNameMapping>policy-distribution.tar.gz</outputFileNameMapping>
+ <outputFileNameMapping>policy-distribution.tar.gz
+ </outputFileNameMapping>
</dependencySet>
</dependencySets>
</inline>
diff --git a/packages/policy-distribution-docker/src/main/docker/Dockerfile b/packages/policy-distribution-docker/src/main/docker/Dockerfile
index 1d04c19..f6ba62e 100644
--- a/packages/policy-distribution-docker/src/main/docker/Dockerfile
+++ b/packages/policy-distribution-docker/src/main/docker/Dockerfile
@@ -25,7 +25,7 @@
COPY /maven/lib/policy-distribution.tar.gz /packages/
RUN tar xvzf /packages/policy-distribution.tar.gz --directory /extracted/
-FROM onap/policy-jre-alpine:3.0.0-SNAPSHOT
+FROM onap/policy-jre-alpine:3.0.1-SNAPSHOT
LABEL maintainer="Policy Team"
LABEL org.opencontainers.image.title="Policy SDC Service Distribution"
diff --git a/packages/policy-distribution-tarball/pom.xml b/packages/policy-distribution-tarball/pom.xml
index c5028a0..9659e69 100644
--- a/packages/policy-distribution-tarball/pom.xml
+++ b/packages/policy-distribution-tarball/pom.xml
@@ -20,12 +20,12 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>distribution-packages</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>policy-distribution-tarball</artifactId>
diff --git a/packages/pom.xml b/packages/pom.xml
index 79e4bcc..24a7932 100644
--- a/packages/pom.xml
+++ b/packages/pom.xml
@@ -21,12 +21,13 @@
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>policy-distribution</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>distribution-packages</artifactId>
@@ -34,7 +35,7 @@
<name>${project.artifactId}</name>
<properties>
- <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. -->
+ <!-- There is no code in this submodule, only holds interfaces. So skip sonar. -->
<sonar.skip>true</sonar.skip>
</properties>
diff --git a/plugins/forwarding-plugins/pom.xml b/plugins/forwarding-plugins/pom.xml
index 3b44f55..a1741b8 100644
--- a/plugins/forwarding-plugins/pom.xml
+++ b/plugins/forwarding-plugins/pom.xml
@@ -19,12 +19,13 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>distribution-plugins</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>forwarding-plugins</artifactId>
@@ -42,15 +43,5 @@
<artifactId>distribution-main</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarder.java
index c9ca500..5aabde7 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarder.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarder.java
@@ -20,14 +20,14 @@
package org.onap.policy.distribution.forwarding.lifecycle.api;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java
index 9be6a0b..df2e36e 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java
@@ -22,15 +22,15 @@
package org.onap.policy.distribution.forwarding.lifecycle.api;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderParameterGroupTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderParameterGroupTest.java
index d8ebb4e..f160d1b 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderParameterGroupTest.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderParameterGroupTest.java
@@ -22,20 +22,20 @@
package org.onap.policy.distribution.forwarding.file;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationStatus;
/**
* Class to perform unit test of {@link FilePolicyForwarderParameterGroup}.
*/
-public class FilePolicyForwarderParameterGroupTest {
+class FilePolicyForwarderParameterGroupTest {
@Test
- public void testBuilderAndGetters() {
- final FilePolicyForwarderParameterGroup configurationParameters = new FilePolicyForwarderParameterGroup();
+ void testBuilderAndGetters() {
+ final var configurationParameters = new FilePolicyForwarderParameterGroup();
configurationParameters.setPath("/tmp");
configurationParameters.setVerbose(true);
configurationParameters.setName("myConfiguration");
@@ -47,8 +47,8 @@
}
@Test
- public void testInvalidPath() {
- final FilePolicyForwarderParameterGroup configurationParameters = new FilePolicyForwarderParameterGroup();
+ void testInvalidPath() {
+ final var configurationParameters = new FilePolicyForwarderParameterGroup();
configurationParameters.setPath("");
configurationParameters.setVerbose(false);
configurationParameters.setName("myConfiguration");
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderTest.java
index fb00dae..dbc5804 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderTest.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarderTest.java
@@ -23,7 +23,7 @@
package org.onap.policy.distribution.forwarding.file;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.nio.file.Files;
@@ -31,14 +31,11 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.forwarding.PolicyForwardingException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
@@ -49,10 +46,9 @@
* Class to perform unit test of {@link FilePolicyForwarder}.
*
*/
-@RunWith(MockitoJUnitRunner.class)
-public class FilePolicyForwarderTest {
- @ClassRule
- public static TemporaryFolder tempFolder = new TemporaryFolder();
+class FilePolicyForwarderTest {
+
+ private static Path tempFolder;
private static final boolean VERBOSE = true;
private static final String GROUP_NAME = "fileConfiguration";
@@ -60,10 +56,11 @@
/**
* Set up.
*/
- @BeforeClass
- public static void setUp() {
+ @BeforeAll
+ static void setUp(@TempDir Path tempDir) {
+ tempFolder = tempDir;
final FilePolicyForwarderParameterGroup configurationParameters = new FilePolicyForwarderParameterGroup();
- configurationParameters.setPath(tempFolder.getRoot().getAbsolutePath().toString());
+ configurationParameters.setPath(tempFolder.toFile().getAbsolutePath());
configurationParameters.setVerbose(VERBOSE);
configurationParameters.setName(GROUP_NAME);
ParameterService.register(configurationParameters);
@@ -72,36 +69,36 @@
/**
* Tear down.
*/
- @AfterClass
- public static void tearDown() {
+ @AfterAll
+ static void tearDown() {
ParameterService.deregister(GROUP_NAME);
}
@Test
- public void testForwardPolicy() throws PolicyForwardingException {
+ void testForwardPolicy() throws PolicyForwardingException {
final Collection<ToscaEntity> policies = new ArrayList<>();
- final ToscaPolicy policy = createPolicy(policies, "test", "test");
+ final var policy = createPolicy(policies);
- final FilePolicyForwarder forwarder = new FilePolicyForwarder();
+ final var forwarder = new FilePolicyForwarder();
forwarder.configure(GROUP_NAME);
forwarder.forward(policies);
- final Path path = Paths.get(tempFolder.getRoot().getAbsolutePath().toString(), policy.getName());
+ final var path = Paths.get(tempFolder.toFile().getAbsolutePath(), policy.getName());
assertTrue(Files.exists(path));
}
@Test
- public void testForwardPolicyError() {
+ void testForwardPolicyError() {
final Collection<ToscaEntity> policies = new ArrayList<>();
- final ToscaPolicy policy = createPolicy(policies, "test", "test");
+ final var policy = createPolicy(policies);
- final ToscaPolicy spy = Mockito.spy(policy);
+ final var spy = Mockito.spy(policy);
Mockito.when(spy.toString()).thenAnswer(invocation -> {
throw new IOException();
});
policies.add(spy);
- final FilePolicyForwarder forwarder = new FilePolicyForwarder();
+ final var forwarder = new FilePolicyForwarder();
forwarder.configure(GROUP_NAME);
assertThatThrownBy(() -> forwarder.forward(policies)).isInstanceOf(PolicyForwardingException.class)
@@ -109,19 +106,19 @@
}
@Test
- public void testForwardUnsupportedPolicy() {
+ void testForwardUnsupportedPolicy() {
final Collection<ToscaEntity> policies = new ArrayList<>();
- final FilePolicyForwarder forwarder = new FilePolicyForwarder();
+ final var forwarder = new FilePolicyForwarder();
forwarder.configure(GROUP_NAME);
- final ToscaEntity policy = new UnsupportedPolicy();
+ final var policy = new UnsupportedPolicy();
policies.add(policy);
assertThatThrownBy(() -> forwarder.forward(policies)).isInstanceOf(PolicyForwardingException.class)
.hasMessageContaining("Cannot forward policy");
}
- class UnsupportedPolicy extends ToscaEntity {
+ static class UnsupportedPolicy extends ToscaEntity {
@Override
public String getName() {
@@ -129,8 +126,7 @@
}
}
- private ToscaPolicy createPolicy(final Collection<ToscaEntity> policies, final String name,
- final String description) {
+ private ToscaPolicy createPolicy(final Collection<ToscaEntity> policies) {
final ToscaPolicy policy = new ToscaPolicy();
policy.setName("test");
policy.setDescription("test");
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderParametersTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderParametersTest.java
index 1904edc..091b245 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderParametersTest.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderParametersTest.java
@@ -22,10 +22,10 @@
package org.onap.policy.distribution.forwarding.lifecycle.api;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.distribution.forwarding.testclasses.CommonTestData;
@@ -34,7 +34,7 @@
*
* @author Sirisha Manchikanti (sirisha.manchikanti@est.tech)
*/
-public class LifecycleApiAutomationCompositionForwarderParametersTest {
+class LifecycleApiAutomationCompositionForwarderParametersTest {
private static final String AUTOMATION_COMPOSITION_RUNTIME_HOST_NAME = "localhost";
private static final int AUTOMATION_COMPOSITION_RUNTIME_PORT = 6969;
@@ -43,8 +43,8 @@
@Test
- public void testValidParameters() {
- final LifecycleApiAutomationCompositionForwarderParameters configurationParameters =
+ void testValidParameters() {
+ final var configurationParameters =
CommonTestData.getPolicyForwarderParameters(
"src/test/resources/parameters/LifecycleApiAutomationCompositionForwarderParameters.json",
LifecycleApiAutomationCompositionForwarderParameters.class);
@@ -67,8 +67,8 @@
}
@Test
- public void testInvalidParameters() {
- final LifecycleApiForwarderParameters configurationParameters =
+ void testInvalidParameters() {
+ final var configurationParameters =
CommonTestData.getPolicyForwarderParameters(
"src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json",
LifecycleApiForwarderParameters.class);
@@ -77,8 +77,8 @@
}
@Test
- public void testEmptyParameters() {
- final LifecycleApiForwarderParameters configurationParameters =
+ void testEmptyParameters() {
+ final var configurationParameters =
CommonTestData.getPolicyForwarderParameters("src/test/resources/parameters/EmptyParameters.json",
LifecycleApiForwarderParameters.class);
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderTest.java
index 0c9a8f6..f28b52e 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderTest.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderTest.java
@@ -25,10 +25,9 @@
import java.util.ArrayList;
import java.util.Collection;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -45,7 +44,7 @@
*
* @author Sirisha Manchikanti (sirisha.manchikanti@est.tech)
*/
-public class LifecycleApiAutomationCompositionForwarderTest {
+class LifecycleApiAutomationCompositionForwarderTest {
private static final String AUTOMATION_COMPOSITION =
"src/test/resources/parameters/sample_automation_composition.json";
@@ -60,9 +59,9 @@
* @throws PolicyForwardingException if any error occurs
* @throws InterruptedException if any error occurs
*/
- @BeforeClass
- public static void setUp() throws PolicyForwardingException, CoderException, InterruptedException {
- final ParameterGroup parameterGroup = CommonTestData.getPolicyForwarderParameters(
+ @BeforeAll
+ static void setUp() throws PolicyForwardingException, CoderException, InterruptedException {
+ final var parameterGroup = CommonTestData.getPolicyForwarderParameters(
"src/test/resources/parameters/LifecycleApiAutomationCompositionForwarderParameters.json",
LifecycleApiAutomationCompositionForwarderParameters.class);
ParameterService.register(parameterGroup);
@@ -75,19 +74,19 @@
/**
* Tear down.
*/
- @AfterClass
- public static void tearDown() {
+ @AfterAll
+ static void tearDown() {
ParameterService.deregister(LifecycleApiAutomationCompositionForwarderParameters.class.getSimpleName());
simulator.stopLifecycycleApiSimulator();
}
@Test
- public void testForwardAutomationCompositionUsingSimulator() throws Exception {
+ void testForwardAutomationCompositionUsingSimulator() throws Exception {
assertThatCode(() -> {
- final ToscaServiceTemplate toscaServiceTemplate = standardCoder.decode(
+ final var toscaServiceTemplate = standardCoder.decode(
ResourceUtils.getResourceAsString(AUTOMATION_COMPOSITION), ToscaServiceTemplate.class);
- final LifecycleApiAutomationCompositionForwarder forwarder =
+ final var forwarder =
new LifecycleApiAutomationCompositionForwarder();
forwarder.configure(LifecycleApiAutomationCompositionForwarderParameters.class.getSimpleName());
@@ -100,12 +99,12 @@
}
@Test
- public void testForwardAutomationCompositionFailureUsingSimulator() throws Exception {
+ void testForwardAutomationCompositionFailureUsingSimulator() throws Exception {
- final ToscaEntity toscaEntity = new ToscaEntity();
+ final var toscaEntity = new ToscaEntity();
toscaEntity.setName("FailureCase");
- final LifecycleApiAutomationCompositionForwarder forwarder = new LifecycleApiAutomationCompositionForwarder();
+ final var forwarder = new LifecycleApiAutomationCompositionForwarder();
forwarder.configure(LifecycleApiAutomationCompositionForwarderParameters.class.getSimpleName());
final Collection<ToscaEntity> automationCompositionList = new ArrayList<>();
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParametersTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParametersTest.java
index 42602cf..2cee6e6 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParametersTest.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParametersTest.java
@@ -22,11 +22,11 @@
package org.onap.policy.distribution.forwarding.lifecycle.api;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.distribution.forwarding.testclasses.CommonTestData;
@@ -35,7 +35,7 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
-public class LifecycleApiForwarderParametersTest {
+class LifecycleApiForwarderParametersTest {
private static final String POLICY_API_HOST_NAME = "localhost";
private static final int POLICY_API_PORT = 6969;
@@ -48,8 +48,8 @@
@Test
- public void testValidParameters() {
- final LifecycleApiForwarderParameters configurationParameters =
+ void testValidParameters() {
+ final var configurationParameters =
CommonTestData.getPolicyForwarderParameters(
"src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json",
LifecycleApiForwarderParameters.class);
@@ -73,8 +73,8 @@
}
@Test
- public void testInvalidParameters() {
- final LifecycleApiForwarderParameters configurationParameters =
+ void testInvalidParameters() {
+ final var configurationParameters =
CommonTestData.getPolicyForwarderParameters(
"src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json",
LifecycleApiForwarderParameters.class);
@@ -83,8 +83,8 @@
}
@Test
- public void testEmptyParameters() {
- final LifecycleApiForwarderParameters configurationParameters =
+ void testEmptyParameters() {
+ final var configurationParameters =
CommonTestData.getPolicyForwarderParameters("src/test/resources/parameters/EmptyParameters.json",
LifecycleApiForwarderParameters.class);
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java
index 604445e..ba85505 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarderTest.java
@@ -26,10 +26,9 @@
import java.util.ArrayList;
import java.util.Collection;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -46,7 +45,7 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
-public class LifecycleApiPolicyForwarderTest {
+class LifecycleApiPolicyForwarderTest {
private static final String POLICY = "src/test/resources/parameters/sample_policy.json";
private static final String POLICY_ERROR = "src/test/resources/parameters/sample_policy_failure.json";
@@ -61,9 +60,9 @@
* @throws PolicyForwardingException if any error occurs
* @throws InterruptedException if any error occurs
*/
- @BeforeClass
- public static void setUp() throws PolicyForwardingException, CoderException, InterruptedException {
- final ParameterGroup parameterGroup = CommonTestData.getPolicyForwarderParameters(
+ @BeforeAll
+ static void setUp() throws PolicyForwardingException, CoderException, InterruptedException {
+ final var parameterGroup = CommonTestData.getPolicyForwarderParameters(
"src/test/resources/parameters/LifecycleApiPolicyForwarderParameters.json",
LifecycleApiForwarderParameters.class);
ParameterService.register(parameterGroup);
@@ -76,21 +75,21 @@
/**
* Tear down.
*/
- @AfterClass
- public static void tearDown() {
+ @AfterAll
+ static void tearDown() {
ParameterService.deregister(LifecycleApiForwarderParameters.class.getSimpleName());
simulator.stopLifecycycleApiSimulator();
}
@Test
- public void testForwardPolicyUsingSimulator() throws Exception {
+ void testForwardPolicyUsingSimulator() throws Exception {
assertThatCode(() -> {
- final ToscaServiceTemplate toscaServiceTemplate1 =
+ final var toscaServiceTemplate1 =
standardCoder.decode(ResourceUtils.getResourceAsString(POLICY_TYPE), ToscaServiceTemplate.class);
- final ToscaServiceTemplate toscaServiceTemplate2 =
+ final var toscaServiceTemplate2 =
standardCoder.decode(ResourceUtils.getResourceAsString(POLICY), ToscaServiceTemplate.class);
- final LifecycleApiPolicyForwarder forwarder = new LifecycleApiPolicyForwarder();
+ final var forwarder = new LifecycleApiPolicyForwarder();
forwarder.configure(LifecycleApiForwarderParameters.class.getSimpleName());
final Collection<ToscaEntity> policies = new ArrayList<>();
@@ -103,17 +102,17 @@
}
@Test
- public void testForwardPolicyFailureUsingSimulator() throws Exception {
+ void testForwardPolicyFailureUsingSimulator() throws Exception {
- final ToscaServiceTemplate toscaServiceTemplate1 =
+ final var toscaServiceTemplate1 =
standardCoder.decode(ResourceUtils.getResourceAsString(POLICY_TYPE), ToscaServiceTemplate.class);
- final ToscaServiceTemplate toscaServiceTemplate2 =
+ final var toscaServiceTemplate2 =
standardCoder.decode(ResourceUtils.getResourceAsString(POLICY), ToscaServiceTemplate.class);
- final ToscaServiceTemplate toscaServiceTemplate3 =
+ final var toscaServiceTemplate3 =
standardCoder.decode(ResourceUtils.getResourceAsString(POLICY_ERROR), ToscaServiceTemplate.class);
- final ToscaEntity unsupportedPolicy = new UnsupportedPolicy();
+ final var unsupportedPolicy = new UnsupportedPolicy();
- final LifecycleApiPolicyForwarder forwarder = new LifecycleApiPolicyForwarder();
+ final var forwarder = new LifecycleApiPolicyForwarder();
forwarder.configure(LifecycleApiForwarderParameters.class.getSimpleName());
final Collection<ToscaEntity> policies = new ArrayList<>();
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/testclasses/LifecycleApiAutomationCompositionSimulatorEndpoint.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/testclasses/LifecycleApiAutomationCompositionSimulatorEndpoint.java
index 00b017b..c50bf22 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/testclasses/LifecycleApiAutomationCompositionSimulatorEndpoint.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/testclasses/LifecycleApiAutomationCompositionSimulatorEndpoint.java
@@ -21,12 +21,12 @@
package org.onap.policy.distribution.forwarding.testclasses;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
diff --git a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/testclasses/LifecycycleApiSimulatorEndpoint.java b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/testclasses/LifecycycleApiSimulatorEndpoint.java
index 22aeff2..810ac84 100644
--- a/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/testclasses/LifecycycleApiSimulatorEndpoint.java
+++ b/plugins/forwarding-plugins/src/test/java/org/onap/policy/distribution/forwarding/testclasses/LifecycycleApiSimulatorEndpoint.java
@@ -22,13 +22,13 @@
package org.onap.policy.distribution.forwarding.testclasses;
import io.swagger.annotations.ApiParam;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
import org.onap.policy.models.pap.concepts.PdpDeployPolicies;
import org.onap.policy.models.pap.concepts.PdpGroupDeployResponse;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
diff --git a/plugins/pom.xml b/plugins/pom.xml
index e48c5c2..34f797d 100644
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -18,18 +18,20 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>policy-distribution</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>distribution-plugins</artifactId>
<name>${project.artifactId}</name>
- <description>The module of Policy Distribution that holds plugins for custom policy reception and forwarding.</description>
+ <description>The module of Policy Distribution that holds plugins for custom policy reception and forwarding.
+ </description>
<packaging>pom</packaging>
<properties>
diff --git a/plugins/reception-plugins/pom.xml b/plugins/reception-plugins/pom.xml
index acb5d30..09a6d25 100644
--- a/plugins/reception-plugins/pom.xml
+++ b/plugins/reception-plugins/pom.xml
@@ -19,12 +19,13 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>distribution-plugins</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>reception-plugins</artifactId>
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/AutomationCompositionDecoderFileInCsarParameterGroupTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/AutomationCompositionDecoderFileInCsarParameterGroupTest.java
index ea844e4..201133f 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/AutomationCompositionDecoderFileInCsarParameterGroupTest.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/AutomationCompositionDecoderFileInCsarParameterGroupTest.java
@@ -21,9 +21,9 @@
package org.onap.policy.distribution.reception.decoding.policy.file;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.distribution.reception.handling.sdc.CommonTestData;
@@ -32,11 +32,11 @@
*
* @author Sirisha Manchikanti (sirisha.manchikanti@est.tech)
*/
-public class AutomationCompositionDecoderFileInCsarParameterGroupTest {
+class AutomationCompositionDecoderFileInCsarParameterGroupTest {
@Test
- public void testValidParameters() {
- final AutomationCompositionDecoderFileInCsarParameterGroup configurationParameters = CommonTestData
+ void testValidParameters() {
+ final var configurationParameters = CommonTestData
.getPolicyDecoderParameters(
"src/test/resources/parameters/FileInCsarAutomationCompositionDecoderParameters.json",
AutomationCompositionDecoderFileInCsarParameterGroup.class);
@@ -48,8 +48,8 @@
}
@Test
- public void testInvalidParameters() {
- final AutomationCompositionDecoderFileInCsarParameterGroup configurationParameters =
+ void testInvalidParameters() {
+ final var configurationParameters =
CommonTestData.getPolicyDecoderParameters(
"src/test/resources/parameters/FileInCsarAutomationCompositionDecoderParametersInvalid.json",
AutomationCompositionDecoderFileInCsarParameterGroup.class);
@@ -58,8 +58,8 @@
}
@Test
- public void testEmptyParameters() {
- final AutomationCompositionDecoderFileInCsarParameterGroup configurationParameters =
+ void testEmptyParameters() {
+ final var configurationParameters =
CommonTestData.getPolicyDecoderParameters("src/test/resources/parameters/EmptyParameters.json",
AutomationCompositionDecoderFileInCsarParameterGroup.class);
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/AutomationCompositionDecoderFileInCsarTest.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/AutomationCompositionDecoderFileInCsarTest.java
index ac8a75d..eca893d 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/AutomationCompositionDecoderFileInCsarTest.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/AutomationCompositionDecoderFileInCsarTest.java
@@ -22,36 +22,31 @@
package org.onap.policy.distribution.reception.decoding.policy.file;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
-import java.util.Collection;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.model.Csar;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.handling.sdc.CommonTestData;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
/**
* Class to perform unit test of {@link AutomationCompositionDecoderFileInCsar}.
*
* @author Sirisha Manchikanti (sirisha.manchikanti@est.tech)
*/
-@RunWith(MockitoJUnitRunner.class)
-public class AutomationCompositionDecoderFileInCsarTest {
+class AutomationCompositionDecoderFileInCsarTest {
/**
* Set up.
*/
- @BeforeClass
- public static void setUp() {
- final AutomationCompositionDecoderFileInCsarParameterGroup configurationParameters = CommonTestData
+ @BeforeAll
+ static void setUp() {
+ final var configurationParameters = CommonTestData
.getPolicyDecoderParameters(
"src/test/resources/parameters/FileInCsarAutomationCompositionDecoderParameters.json",
AutomationCompositionDecoderFileInCsarParameterGroup.class);
@@ -62,33 +57,33 @@
/**
* Tear down.
*/
- @AfterClass
- public static void tearDown() {
+ @AfterAll
+ static void tearDown() {
ParameterService.deregister(AutomationCompositionDecoderFileInCsarParameterGroup.class.getSimpleName());
}
@Test
- public void testDecodeAutomationComposition() throws PolicyDecodingException {
+ void testDecodeAutomationComposition() throws PolicyDecodingException {
- final AutomationCompositionDecoderFileInCsar decoder = new AutomationCompositionDecoderFileInCsar();
+ final var decoder = new AutomationCompositionDecoderFileInCsar();
decoder.configure(AutomationCompositionDecoderFileInCsarParameterGroup.class.getSimpleName());
- final File file = new File("src/test/resources/service-Sampleservice-acm.csar");
- final Csar csar = new Csar(file.getAbsolutePath());
+ final var file = new File("src/test/resources/service-Sampleservice-acm.csar");
+ final var csar = new Csar(file.getAbsolutePath());
assertTrue(decoder.canHandle(csar));
- final Collection<ToscaEntity> automationCompositionHolders = decoder.decode(csar);
+ final var automationCompositionHolders = decoder.decode(csar);
assertEquals(1, automationCompositionHolders.size());
}
@Test
- public void testDecodeAutomationCompositionZipError() {
+ void testDecodeAutomationCompositionZipError() {
- final AutomationCompositionDecoderFileInCsar decoder = new AutomationCompositionDecoderFileInCsar();
+ final var decoder = new AutomationCompositionDecoderFileInCsar();
decoder.configure(AutomationCompositionDecoderFileInCsarParameterGroup.class.getSimpleName());
- final File file = new File("unknown.csar");
- final Csar csar = new Csar(file.getAbsolutePath());
+ final var file = new File("unknown.csar");
+ final var csar = new Csar(file.getAbsolutePath());
assertTrue(decoder.canHandle(csar));
assertThatThrownBy(() -> decoder.decode(csar)).isInstanceOf(PolicyDecodingException.class)
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 c3cf3f5..0164fe5 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
@@ -21,9 +21,9 @@
package org.onap.policy.distribution.reception.decoding.policy.file;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.distribution.reception.handling.sdc.CommonTestData;
@@ -32,11 +32,11 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class PolicyDecoderFileInCsarToPolicyParameterGroupTest {
+class PolicyDecoderFileInCsarToPolicyParameterGroupTest {
@Test
- public void testValidParameters() {
- final PolicyDecoderFileInCsarToPolicyParameterGroup configurationParameters = CommonTestData
+ void testValidParameters() {
+ final var configurationParameters = CommonTestData
.getPolicyDecoderParameters("src/test/resources/parameters/FileInCsarPolicyDecoderParameters.json",
PolicyDecoderFileInCsarToPolicyParameterGroup.class);
@@ -48,8 +48,8 @@
}
@Test
- public void testInvalidParameters() {
- final PolicyDecoderFileInCsarToPolicyParameterGroup configurationParameters =
+ void testInvalidParameters() {
+ final var configurationParameters =
CommonTestData.getPolicyDecoderParameters(
"src/test/resources/parameters/FileInCsarPolicyDecoderParametersInvalid.json",
PolicyDecoderFileInCsarToPolicyParameterGroup.class);
@@ -58,8 +58,8 @@
}
@Test
- public void testEmptyParameters() {
- final PolicyDecoderFileInCsarToPolicyParameterGroup configurationParameters =
+ void testEmptyParameters() {
+ final var configurationParameters =
CommonTestData.getPolicyDecoderParameters("src/test/resources/parameters/EmptyParameters.json",
PolicyDecoderFileInCsarToPolicyParameterGroup.class);
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 45dd167..88b4c86 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
@@ -22,35 +22,30 @@
package org.onap.policy.distribution.reception.decoding.policy.file;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
-import java.util.Collection;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.model.Csar;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.handling.sdc.CommonTestData;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
/**
* Class to perform unit test of {@link PolicyDecoderFileInCsarToPolicy}.
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-@RunWith(MockitoJUnitRunner.class)
-public class PolicyDecoderFileInCsarToPolicyTest {
+class PolicyDecoderFileInCsarToPolicyTest {
/**
* Set up.
*/
- @BeforeClass
- public static void setUp() {
+ @BeforeAll
+ static void setUp() {
final PolicyDecoderFileInCsarToPolicyParameterGroup configurationParameters = CommonTestData
.getPolicyDecoderParameters("src/test/resources/parameters/FileInCsarPolicyDecoderParameters.json",
PolicyDecoderFileInCsarToPolicyParameterGroup.class);
@@ -61,47 +56,47 @@
/**
* Tear down.
*/
- @AfterClass
- public static void tearDown() {
+ @AfterAll
+ static void tearDown() {
ParameterService.deregister(PolicyDecoderFileInCsarToPolicyParameterGroup.class.getSimpleName());
}
@Test
- public void testDecodePolicy() throws PolicyDecodingException {
+ void testDecodePolicy() throws PolicyDecodingException {
- final PolicyDecoderFileInCsarToPolicy decoder = new PolicyDecoderFileInCsarToPolicy();
+ final var decoder = new PolicyDecoderFileInCsarToPolicy();
decoder.configure(PolicyDecoderFileInCsarToPolicyParameterGroup.class.getSimpleName());
- final File file = new File("src/test/resources/service-Sampleservice.csar");
- final Csar csar = new Csar(file.getAbsolutePath());
+ final var file = new File("src/test/resources/service-Sampleservice.csar");
+ final var csar = new Csar(file.getAbsolutePath());
assertTrue(decoder.canHandle(csar));
- final Collection<ToscaEntity> policyHolders = decoder.decode(csar);
+ final var policyHolders = decoder.decode(csar);
assertEquals(2, policyHolders.size());
}
@Test
- public void testDecodeYamlPolicy() throws PolicyDecodingException {
+ void testDecodeYamlPolicy() throws PolicyDecodingException {
- final PolicyDecoderFileInCsarToPolicy decoder = new PolicyDecoderFileInCsarToPolicy();
+ final var decoder = new PolicyDecoderFileInCsarToPolicy();
decoder.configure(PolicyDecoderFileInCsarToPolicyParameterGroup.class.getSimpleName());
- final File file = new File("src/test/resources/service-Sampleservice-yaml.csar");
- final Csar csar = new Csar(file.getAbsolutePath());
+ final var file = new File("src/test/resources/service-Sampleservice-yaml.csar");
+ final var csar = new Csar(file.getAbsolutePath());
assertTrue(decoder.canHandle(csar));
- final Collection<ToscaEntity> policyHolders = decoder.decode(csar);
+ final var policyHolders = decoder.decode(csar);
assertEquals(2, policyHolders.size());
}
@Test
- public void testDecodePolicyZipError() {
+ void testDecodePolicyZipError() {
- final PolicyDecoderFileInCsarToPolicy decoder = new PolicyDecoderFileInCsarToPolicy();
+ final var decoder = new PolicyDecoderFileInCsarToPolicy();
decoder.configure(PolicyDecoderFileInCsarToPolicyParameterGroup.class.getSimpleName());
- final File file = new File("unknown.csar");
- final Csar csar = new Csar(file.getAbsolutePath());
+ final var file = new File("unknown.csar");
+ final var csar = new Csar(file.getAbsolutePath());
assertTrue(decoder.canHandle(csar));
assertThatThrownBy(() -> decoder.decode(csar)).isInstanceOf(PolicyDecodingException.class)
@@ -110,13 +105,13 @@
@Test
- public void testDecodePolicyCoderError() {
+ void testDecodePolicyCoderError() {
- final PolicyDecoderFileInCsarToPolicy decoder = new PolicyDecoderFileInCsarToPolicy();
+ final var decoder = new PolicyDecoderFileInCsarToPolicy();
decoder.configure(PolicyDecoderFileInCsarToPolicyParameterGroup.class.getSimpleName());
- final File file = new File("src/test/resources/service-Sampleservice-test.csar");
- final Csar csar = new Csar(file.getAbsolutePath());
+ final var file = new File("src/test/resources/service-Sampleservice-test.csar");
+ final var csar = new Csar(file.getAbsolutePath());
assertTrue(decoder.canHandle(csar));
assertThatThrownBy(() -> decoder.decode(csar)).isInstanceOf(PolicyDecodingException.class)
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java
index 7308018..c36cd36 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java
@@ -22,8 +22,9 @@
package org.onap.policy.distribution.reception.handling.file;
import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
-import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.io.FileReader;
@@ -31,14 +32,11 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
@@ -48,13 +46,12 @@
/**
* Class to perform unit test of {@link FileSystemReceptionHandler}.
*/
-@RunWith(MockitoJUnitRunner.class)
-public class TestFileSystemReceptionHandler {
+class TestFileSystemReceptionHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(TestFileSystemReceptionHandler.class);
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder();
+ @TempDir
+ public File tempFolder;
private FileSystemReceptionHandlerConfigurationParameterGroup pssdConfigParameters;
private FileSystemReceptionHandler fileSystemHandler;
@@ -67,25 +64,25 @@
* @throws SecurityException if it occurs
* @throws IllegalArgumentException if it occurs
*/
- @Before
- public final void init() throws IOException, SecurityException, IllegalArgumentException {
+ @BeforeEach
+ final void init() throws IOException, SecurityException, IllegalArgumentException {
DistributionStatisticsManager.resetAllStatistics();
- final Gson gson = new GsonBuilder().create();
+ final var gson = new GsonBuilder().create();
pssdConfigParameters = gson.fromJson(new FileReader("src/test/resources/handling-filesystem.json"),
FileSystemReceptionHandlerConfigurationParameterGroup.class);
ParameterService.register(pssdConfigParameters);
fileSystemHandler = new FileSystemReceptionHandler();
}
- @After
- public void teardown() {
+ @AfterEach
+ void teardown() {
ParameterService.deregister(pssdConfigParameters);
}
@Test
- public final void testInit() throws IOException {
- FileSystemReceptionHandler sypHandler = Mockito.spy(fileSystemHandler);
+ final void testInit() throws IOException {
+ var sypHandler = spy(fileSystemHandler);
Mockito.doNothing().when(sypHandler).initFileWatcher(Mockito.isA(String.class),
Mockito.anyInt());
assertThatCode(() -> sypHandler.initializeReception(pssdConfigParameters.getName()))
@@ -93,8 +90,8 @@
}
@Test
- public final void testDestroy() throws IOException {
- final FileSystemReceptionHandler sypHandler = Mockito.spy(fileSystemHandler);
+ final void testDestroy() throws IOException {
+ final var sypHandler = spy(fileSystemHandler);
Mockito.doNothing().when(sypHandler).initFileWatcher(Mockito.isA(String.class),
Mockito.anyInt());
assertThatCode(() -> {
@@ -104,17 +101,17 @@
}
@Test
- public void testMain() throws IOException {
- final Object lock = new Object();
- final String watchPath = tempFolder.getRoot().getAbsolutePath();
+ void testMain() throws IOException {
+ final var lock = new Object();
+ final var watchPath = tempFolder.getAbsolutePath();
class Processed {
public boolean processed = false;
}
- final Processed cond = new Processed();
+ final var cond = new Processed();
- final FileSystemReceptionHandler sypHandler = Mockito.spy(fileSystemHandler);
+ final var sypHandler = Mockito.spy(fileSystemHandler);
Mockito.doAnswer((Answer<Object>) invocation -> {
synchronized (lock) {
cond.processed = true;
@@ -123,7 +120,7 @@
return null;
}).when(sypHandler).createPolicyInputAndCallHandler(Mockito.isA(String.class));
- final Thread th = new Thread(() -> {
+ final var th = new Thread(() -> {
try {
sypHandler.initFileWatcher(watchPath, 2);
} catch (final IOException ex) {
@@ -134,7 +131,7 @@
th.start();
try {
// wait until internal watch service started or counter reached
- final AtomicInteger counter = new AtomicInteger();
+ final var counter = new AtomicInteger();
counter.set(0);
synchronized (lock) {
while (!sypHandler.isRunning() && counter.getAndIncrement() < 10) {
@@ -156,8 +153,7 @@
} catch (final InterruptedException ex) {
LOGGER.error("testMain failed", ex);
}
- Mockito.verify(sypHandler, Mockito.times(1)).createPolicyInputAndCallHandler(Mockito.isA(String.class));
+ verify(sypHandler, Mockito.times(1)).createPolicyInputAndCallHandler(Mockito.isA(String.class));
}
}
-
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 c8bcc7b..46d7f27 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
@@ -24,64 +24,58 @@
package org.onap.policy.distribution.reception.handling.file;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.onap.policy.common.parameters.ValidationResult;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
/**
* Class to perform unit test of {@link FileSystemReceptionHandlerConfigurationParameterGroup}.
*
*/
-public class TestFileSystemReceptionHandlerConfigurationParameterGroup {
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder();
+class TestFileSystemReceptionHandlerConfigurationParameterGroup {
+
+ @TempDir
+ private File tempFolder;
@Test
- public void testFileSystemConfiguration() throws IOException {
- FileSystemReceptionHandlerConfigurationParameterGroup configParameters = null;
- String validPath = null;
+ void testFileSystemConfiguration() throws IOException {
+ String validPath = tempFolder.getPath();
- validPath = tempFolder.getRoot().getAbsolutePath();
-
- configParameters = new FileSystemReceptionHandlerConfigurationParameterGroup();
+ var configParameters = new FileSystemReceptionHandlerConfigurationParameterGroup();
configParameters.setWatchPath(validPath);
configParameters.setMaxThread(2);
- final ValidationResult validationResult = configParameters.validate();
+ final var validationResult = configParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(validPath, configParameters.getWatchPath());
assertEquals(2, configParameters.getMaxThread());
}
@Test
- public void testInvalidFileSystemConfiguration() throws IOException {
- FileSystemReceptionHandlerConfigurationParameterGroup configParameters = null;
- final Gson gson = new GsonBuilder().create();
- configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"),
+ void testInvalidFileSystemConfiguration() throws IOException {
+ final var gson = new GsonBuilder().create();
+ var configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"),
FileSystemReceptionHandlerConfigurationParameterGroup.class);
- final ValidationResult validationResult = configParameters.validate();
+ final var validationResult = configParameters.validate();
assertFalse(validationResult.isValid());
}
@Test
- public void testFileSystemReceptionHandlerConfigurationParameterBuilderWithInvalidPath() throws IOException {
- final String invalidPath = tempFolder.newFile("foobar").getAbsolutePath();
+ void testFileSystemReceptionHandlerConfigurationParameterBuilderWithInvalidPath() throws IOException {
+ final var invalidPath = new File(tempFolder, "foobar").getAbsolutePath();
- final FileSystemReceptionHandlerConfigurationParameterGroup configParameters =
- new FileSystemReceptionHandlerConfigurationParameterGroup();
+ final var configParameters = new FileSystemReceptionHandlerConfigurationParameterGroup();
configParameters.setWatchPath(invalidPath);
- final ValidationResult validateResult = configParameters.validate();
+ final var validateResult = configParameters.validate();
assertFalse(validateResult.isValid());
assertThat(validateResult.getResult()).contains("is not a valid directory");
}
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java
index c593582..d3f7ee0 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java
@@ -21,20 +21,20 @@
package org.onap.policy.distribution.reception.handling.sdc;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.utils.DistributionStatusEnum;
-public class TestComponentDoneStatusMessage {
+class TestComponentDoneStatusMessage {
private static final String CONSUMER_ID = "dummyId";
private static final String DISTRIBUTION_ID = "dummyDistribution";
@Test
- public void testComponentDoneStatusMessage_Success() {
- final long timestamp = System.currentTimeMillis();
- final ComponentDoneStatusMessage message = ComponentDoneStatusMessage.builder().consumerId(CONSUMER_ID)
+ void testComponentDoneStatusMessage_Success() {
+ final var timestamp = System.currentTimeMillis();
+ final var message = ComponentDoneStatusMessage.builder().consumerId(CONSUMER_ID)
.distributionId(DISTRIBUTION_ID).distributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK)
.timestamp(timestamp).build();
assertEquals("POLICY", message.getComponentName());
@@ -45,9 +45,9 @@
}
@Test
- public void testComponentDoneStatusMessage_Failure() {
- final long timestamp = System.currentTimeMillis();
- final ComponentDoneStatusMessage message = ComponentDoneStatusMessage.builder().consumerId(CONSUMER_ID)
+ void testComponentDoneStatusMessage_Failure() {
+ final var timestamp = System.currentTimeMillis();
+ final var message = ComponentDoneStatusMessage.builder().consumerId(CONSUMER_ID)
.distributionId(DISTRIBUTION_ID).distributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR)
.timestamp(timestamp).build();
assertEquals("POLICY", message.getComponentName());
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java
index 62cf0f3..86d4bde 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java
@@ -21,22 +21,22 @@
package org.onap.policy.distribution.reception.handling.sdc;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.utils.DistributionStatusEnum;
-public class TestDistributionStatusMessage {
+class TestDistributionStatusMessage {
private static final String ARTIFACT_URL = "http://dummyurl";
private static final String CONSUMER_ID = "dummyId";
private static final String DISTRIBUTION_ID = "dummyDistribution";
@Test
- public void testDistributionStatusMessage_Download() {
- final long timestamp = System.currentTimeMillis();
+ void testDistributionStatusMessage_Download() {
+ final var timestamp = System.currentTimeMillis();
- final DistributionStatusMessage message = DistributionStatusMessage.builder().artifactUrl(ARTIFACT_URL)
+ final var message = DistributionStatusMessage.builder().artifactUrl(ARTIFACT_URL)
.consumerId(CONSUMER_ID).distributionId(DISTRIBUTION_ID)
.distributionStatus(DistributionStatusEnum.DOWNLOAD_OK).timestamp(timestamp).build();
assertEquals(ARTIFACT_URL, message.getArtifactURL());
@@ -47,10 +47,10 @@
}
@Test
- public void testDistributionStatusMessage_Deploy() {
- final long timestamp = System.currentTimeMillis();
+ void testDistributionStatusMessage_Deploy() {
+ final var timestamp = System.currentTimeMillis();
- final DistributionStatusMessage message = DistributionStatusMessage.builder().artifactUrl(ARTIFACT_URL)
+ final var message = DistributionStatusMessage.builder().artifactUrl(ARTIFACT_URL)
.consumerId(CONSUMER_ID).distributionId(DISTRIBUTION_ID)
.distributionStatus(DistributionStatusEnum.DEPLOY_OK).timestamp(timestamp).build();
assertEquals(ARTIFACT_URL, message.getArtifactURL());
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
index 3e8f4a6..9a993c6 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
@@ -23,28 +23,25 @@
package org.onap.policy.distribution.reception.handling.sdc;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
-import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.FileReader;
import java.io.IOException;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.forwarding.PolicyForwarder;
import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
@@ -68,23 +65,17 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-@RunWith(MockitoJUnitRunner.class)
-public class TestSdcReceptionHandler {
+class TestSdcReceptionHandler {
private static final String DUMMY_SERVICE_CSAR = "dummyService.csar";
- @Mock
- private IDistributionClientResult successfulClientInitResult;
- @Mock
- private IDistributionClientResult failureClientInitResult;
- @Mock
- private IDistributionClient distributionClient;
- @Mock
- private IDistributionClientDownloadResult successfulClientDownloadResult;
- @Mock
- private INotificationData notificationData;
- @Mock
- private IArtifactInfo artifactInfo;
+ private final IDistributionClientResult successfulClientInitResult = mock(IDistributionClientResult.class);
+ private final IDistributionClientResult failureClientInitResult = mock(IDistributionClientResult.class);
+ private final IDistributionClient distributionClient = mock(IDistributionClient.class);
+ private final IDistributionClientDownloadResult successfulClientDownloadResult
+ = mock(IDistributionClientDownloadResult.class);
+ private final INotificationData notificationData = mock(INotificationData.class);
+ private final IArtifactInfo artifactInfo = mock(IArtifactInfo.class);
private SdcReceptionHandlerConfigurationParameterGroup pssdConfigParameters;
private SdcReceptionHandler sypHandler;
@@ -97,70 +88,70 @@
* @throws SecurityException if it occurs
* @throws IllegalArgumentException if it occurs
*/
- @Before
- public final void init() throws IOException, SecurityException, IllegalArgumentException {
+ @BeforeEach
+ final void init() throws IOException, SecurityException, IllegalArgumentException {
DistributionStatisticsManager.resetAllStatistics();
- final Gson gson = new GsonBuilder().create();
+ final var gson = new GsonBuilder().create();
pssdConfigParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"),
SdcReceptionHandlerConfigurationParameterGroup.class);
ParameterService.register(pssdConfigParameters);
- final SdcReceptionHandler sdcHandler = new SdcReceptionHandler();
- sypHandler = Mockito.spy(sdcHandler);
+ final var sdcHandler = new SdcReceptionHandler();
+ sypHandler = spy(sdcHandler);
- Mockito.when(sypHandler.createSdcDistributionClient()).thenReturn(distributionClient);
- Mockito.when(distributionClient.init(any(), any())).thenReturn(successfulClientInitResult);
- Mockito.when(distributionClient.start()).thenReturn(successfulClientInitResult);
- Mockito.when(distributionClient.stop()).thenReturn(successfulClientInitResult);
- Mockito.when(distributionClient.sendComponentDoneStatus(any())).thenReturn(successfulClientInitResult);
- Mockito.when(distributionClient.sendComponentDoneStatus(any(), any())).thenReturn(successfulClientInitResult);
- Mockito.when(distributionClient.sendDownloadStatus(any())).thenReturn(successfulClientInitResult);
- Mockito.when(distributionClient.sendDownloadStatus(any(), any())).thenReturn(successfulClientInitResult);
- Mockito.when(distributionClient.sendDeploymentStatus(any())).thenReturn(successfulClientInitResult);
- Mockito.when(distributionClient.sendDeploymentStatus(any(), any())).thenReturn(successfulClientInitResult);
- Mockito.when(distributionClient.download(any())).thenReturn(successfulClientDownloadResult);
- Mockito.when(notificationData.getServiceArtifacts()).thenReturn(List.of(artifactInfo));
- Mockito.when(artifactInfo.getArtifactName()).thenReturn(DUMMY_SERVICE_CSAR);
- Mockito.when(successfulClientDownloadResult.getArtifactPayload()).thenReturn(new byte[1]);
- Mockito.when(successfulClientInitResult.getDistributionActionResult())
+ when(sypHandler.createSdcDistributionClient()).thenReturn(distributionClient);
+ when(distributionClient.init(any(), any())).thenReturn(successfulClientInitResult);
+ when(distributionClient.start()).thenReturn(successfulClientInitResult);
+ when(distributionClient.stop()).thenReturn(successfulClientInitResult);
+ when(distributionClient.sendComponentDoneStatus(any())).thenReturn(successfulClientInitResult);
+ when(distributionClient.sendComponentDoneStatus(any(), any())).thenReturn(successfulClientInitResult);
+ when(distributionClient.sendDownloadStatus(any())).thenReturn(successfulClientInitResult);
+ when(distributionClient.sendDownloadStatus(any(), any())).thenReturn(successfulClientInitResult);
+ when(distributionClient.sendDeploymentStatus(any())).thenReturn(successfulClientInitResult);
+ when(distributionClient.sendDeploymentStatus(any(), any())).thenReturn(successfulClientInitResult);
+ when(distributionClient.download(any())).thenReturn(successfulClientDownloadResult);
+ when(notificationData.getServiceArtifacts()).thenReturn(List.of(artifactInfo));
+ when(artifactInfo.getArtifactName()).thenReturn(DUMMY_SERVICE_CSAR);
+ when(successfulClientDownloadResult.getArtifactPayload()).thenReturn(new byte[1]);
+ when(successfulClientInitResult.getDistributionActionResult())
.thenReturn(DistributionActionResultEnum.SUCCESS);
- Mockito.when(successfulClientDownloadResult.getDistributionActionResult())
+ when(successfulClientDownloadResult.getDistributionActionResult())
.thenReturn(DistributionActionResultEnum.SUCCESS);
- Mockito.when(failureClientInitResult.getDistributionActionResult())
+ when(failureClientInitResult.getDistributionActionResult())
.thenReturn(DistributionActionResultEnum.FAIL);
}
- @After
- public void teardown() {
+ @AfterEach
+ void teardown() {
ParameterService.deregister(pssdConfigParameters);
}
@Test
- public final void testInitializeSdcClient() {
+ final void testInitializeSdcClient() {
assertThatCode(() -> sypHandler.initializeReception(pssdConfigParameters.getName()))
.doesNotThrowAnyException();
}
@Test
- public final void testInitializeSdcClient_Failure() {
+ final void testInitializeSdcClient_Failure() {
- Mockito.when(successfulClientInitResult.getDistributionActionResult())
+ when(successfulClientInitResult.getDistributionActionResult())
.thenReturn(DistributionActionResultEnum.FAIL).thenReturn(DistributionActionResultEnum.SUCCESS);
assertThatCode(() -> sypHandler.initializeReception(pssdConfigParameters.getName()))
.doesNotThrowAnyException();
}
@Test
- public final void testStartSdcClient_Failure() {
+ final void testStartSdcClient_Failure() {
assertThatCode(() -> {
- Mockito.when(distributionClient.start()).thenReturn(failureClientInitResult)
+ when(distributionClient.start()).thenReturn(failureClientInitResult)
.thenReturn(successfulClientInitResult);
sypHandler.initializeReception(pssdConfigParameters.getName());
}).doesNotThrowAnyException();
}
@Test
- public final void testStopSdcClient() {
+ final void testStopSdcClient() {
assertThatCode(() -> {
sypHandler.initializeReception(pssdConfigParameters.getName());
sypHandler.destroy();
@@ -168,27 +159,27 @@
}
@Test
- public final void testStopSdcClient_Failure() {
+ final void testStopSdcClient_Failure() {
sypHandler.initializeReception(pssdConfigParameters.getName());
- Mockito.when(distributionClient.stop()).thenReturn(failureClientInitResult)
+ when(distributionClient.stop()).thenReturn(failureClientInitResult)
.thenReturn(successfulClientInitResult);
assertThatCode(() -> sypHandler.destroy()).doesNotThrowAnyException();
}
@Test
- public final void testStopSdcClientWithoutStart() {
+ final void testStopSdcClientWithoutStart() {
assertThatCode(() -> sypHandler.destroy()).doesNotThrowAnyException();
}
@Test
- public void testNotificationCallBack() throws NoSuchFieldException, SecurityException, IllegalArgumentException,
+ void testNotificationCallBack() throws NoSuchFieldException, SecurityException, IllegalArgumentException,
IllegalAccessException, PluginInitializationException {
- final DummyDecoder policyDecoder = new DummyDecoder();
+ final var policyDecoder = new DummyDecoder();
final Collection<PolicyDecoder<Csar, DummyPolicy>> policyDecoders = new ArrayList<>();
policyDecoders.add(policyDecoder);
- final DummyPolicyForwarder policyForwarder = new DummyPolicyForwarder();
+ final var policyForwarder = new DummyPolicyForwarder();
final Collection<PolicyForwarder> policyForwarders = new ArrayList<>();
policyForwarders.add(policyForwarder);
@@ -208,17 +199,17 @@
}
@Test
- public void testDownloadArtifactFailure() throws NoSuchFieldException, SecurityException, IllegalArgumentException,
+ void testDownloadArtifactFailure() throws NoSuchFieldException, SecurityException, IllegalArgumentException,
IllegalAccessException, PluginInitializationException {
- Mockito.when(successfulClientDownloadResult.getDistributionActionResult())
+ when(successfulClientDownloadResult.getDistributionActionResult())
.thenReturn(DistributionActionResultEnum.FAIL);
- final DummyDecoder policyDecoder = new DummyDecoder();
+ final var policyDecoder = new DummyDecoder();
final Collection<PolicyDecoder<Csar, DummyPolicy>> policyDecoders = new ArrayList<>();
policyDecoders.add(policyDecoder);
- final DummyPolicyForwarder policyForwarder = new DummyPolicyForwarder();
+ final var policyForwarder = new DummyPolicyForwarder();
final Collection<PolicyForwarder> policyForwarders = new ArrayList<>();
policyForwarders.add(policyForwarder);
@@ -237,20 +228,20 @@
}
@Test
- public void testSendDistributionStatusFailure() throws NoSuchFieldException, SecurityException,
+ void testSendDistributionStatusFailure() throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException, PluginInitializationException {
- Mockito.when(successfulClientDownloadResult.getDistributionActionResult())
+ when(successfulClientDownloadResult.getDistributionActionResult())
.thenReturn(DistributionActionResultEnum.FAIL);
- Mockito.when(distributionClient.sendDownloadStatus(any(), any())).thenReturn(failureClientInitResult);
- Mockito.when(distributionClient.sendDeploymentStatus(any(), any())).thenReturn(failureClientInitResult);
- Mockito.when(distributionClient.sendComponentDoneStatus(any(), any())).thenReturn(failureClientInitResult);
+ when(distributionClient.sendDownloadStatus(any(), any())).thenReturn(failureClientInitResult);
+ when(distributionClient.sendDeploymentStatus(any(), any())).thenReturn(failureClientInitResult);
+ when(distributionClient.sendComponentDoneStatus(any(), any())).thenReturn(failureClientInitResult);
- final DummyDecoder policyDecoder = new DummyDecoder();
+ final var policyDecoder = new DummyDecoder();
final Collection<PolicyDecoder<Csar, DummyPolicy>> policyDecoders = new ArrayList<>();
policyDecoders.add(policyDecoder);
- final DummyPolicyForwarder policyForwarder = new DummyPolicyForwarder();
+ final var policyForwarder = new DummyPolicyForwarder();
final Collection<PolicyForwarder> policyForwarders = new ArrayList<>();
policyForwarders.add(policyForwarder);
@@ -267,34 +258,34 @@
final Collection<PolicyForwarder> forwarders)
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException,
PluginInitializationException {
- final PluginHandlerParameters pluginParameters = getPluginHandlerParameters();
+ final var pluginParameters = getPluginHandlerParameters();
pluginParameters.setName("DummyDistributionGroup");
ParameterService.register(pluginParameters);
- final PluginHandler pluginHandler = new PluginHandler(pluginParameters.getName());
+ final var pluginHandler = new PluginHandler(pluginParameters.getName());
- final Field decodersField = pluginHandler.getClass().getDeclaredField("policyDecoders");
+ final var decodersField = pluginHandler.getClass().getDeclaredField("policyDecoders");
decodersField.setAccessible(true);
decodersField.set(pluginHandler, decoders);
- final Field forwardersField = pluginHandler.getClass().getDeclaredField("policyForwarders");
+ final var forwardersField = pluginHandler.getClass().getDeclaredField("policyForwarders");
forwardersField.setAccessible(true);
forwardersField.set(pluginHandler, forwarders);
- final Field pluginHandlerField = AbstractReceptionHandler.class.getDeclaredField("pluginHandler");
+ final var pluginHandlerField = AbstractReceptionHandler.class.getDeclaredField("pluginHandler");
pluginHandlerField.setAccessible(true);
pluginHandlerField.set(receptionHandler, pluginHandler);
ParameterService.deregister(pluginParameters.getName());
}
private PluginHandlerParameters getPluginHandlerParameters() {
- final Map<String, PolicyDecoderParameters> policyDecoders = getPolicyDecoders();
- final Map<String, PolicyForwarderParameters> policyForwarders = getPolicyForwarders();
+ final var policyDecoders = getPolicyDecoders();
+ final var policyForwarders = getPolicyForwarders();
return new PluginHandlerParameters(policyDecoders, policyForwarders);
}
private Map<String, PolicyDecoderParameters> getPolicyDecoders() {
final Map<String, PolicyDecoderParameters> policyDecoders = new HashMap<>();
- final PolicyDecoderParameters pDParameters = new PolicyDecoderParameters("DummyDecoder",
+ final var pDParameters = new PolicyDecoderParameters("DummyDecoder",
"org.onap.policy.distribution.reception.handling.sdc.DummyDecoder", "DummyDecoderConfiguration");
policyDecoders.put("DummyDecoderKey", pDParameters);
return policyDecoders;
@@ -302,7 +293,7 @@
private Map<String, PolicyForwarderParameters> getPolicyForwarders() {
final Map<String, PolicyForwarderParameters> policyForwarders = new HashMap<>();
- final PolicyForwarderParameters pFParameters = new PolicyForwarderParameters("DummyForwarder",
+ final var pFParameters = new PolicyForwarderParameters("DummyForwarder",
"org.onap.policy.distribution.reception.handling.sdc.DummyPolicyForwarder", "DummyConfiguration");
policyForwarders.put("DummyForwarderKey", pFParameters);
return policyForwarders;
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 717f635..0bf8568 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
@@ -22,35 +22,33 @@
package org.onap.policy.distribution.reception.handling.sdc;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ValidationResult;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationStatus;
/**
* Class to perform unit test of {@link SdcConfiguration}.
*
*/
-public class TestSdcReceptionHandlerConfigurationParameterGroup {
+class TestSdcReceptionHandlerConfigurationParameterGroup {
@Test
- public void testSdcConfiguration() throws IOException {
- SdcReceptionHandlerConfigurationParameterGroup configParameters = null;
- final Gson gson = new GsonBuilder().create();
- configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"),
+ void testSdcConfiguration() throws IOException {
+ final var gson = new GsonBuilder().create();
+ var configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"),
SdcReceptionHandlerConfigurationParameterGroup.class);
- final ValidationResult validationResult = configParameters.validate();
+ final var validationResult = configParameters.validate();
assertTrue(validationResult.isValid());
- final SdcConfiguration config = new SdcConfiguration(configParameters);
+ final var config = new SdcConfiguration(configParameters);
assertEquals(Arrays.asList("TOSCA_CSAR", "HEAT"), config.getRelevantArtifactTypes());
assertEquals("localhost", config.getSdcAddress());
assertEquals("policy", config.getUser());
@@ -62,44 +60,41 @@
assertEquals("TEST", config.getEnvironmentName());
assertEquals("null", config.getKeyStorePath());
assertEquals("null", config.getKeyStorePassword());
- assertEquals(false, config.activateServerTLSAuth());
- assertEquals(true, config.isFilterInEmptyResources());
- assertEquals(false, config.isUseHttpsWithSDC());
+ assertFalse(config.activateServerTLSAuth());
+ assertTrue(config.isFilterInEmptyResources());
+ assertFalse(config.isUseHttpsWithSDC());
}
@Test
- public void testSdcConfigurationNullParameters() throws IOException {
- SdcReceptionHandlerConfigurationParameterGroup configParameters = null;
- final Gson gson = new GsonBuilder().create();
- configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc-null-parameters.json"),
+ void testSdcConfigurationNullParameters() throws IOException {
+ final var gson = new GsonBuilder().create();
+ var configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc-null-parameters.json"),
SdcReceptionHandlerConfigurationParameterGroup.class);
- final ValidationResult validationResult = configParameters.validate();
+ final var validationResult = configParameters.validate();
assertTrue(validationResult.isValid());
- final SdcConfiguration config = new SdcConfiguration(configParameters);
- assertEquals(null, config.getKeyStorePath());
- assertEquals(null, config.getKeyStorePassword());
+ final var config = new SdcConfiguration(configParameters);
+ assertThat(config.getKeyStorePath()).isNull();
+ assertThat(config.getKeyStorePassword()).isNull();
//if boolean parameters are null they are set to false
- assertEquals(false, config.activateServerTLSAuth());
- assertEquals(false, config.isFilterInEmptyResources());
+ assertFalse(config.activateServerTLSAuth());
+ assertFalse(config.isFilterInEmptyResources());
}
@Test
- public void testInvalidSdcConfiguration() throws IOException {
- SdcReceptionHandlerConfigurationParameterGroup configParameters = null;
-
- final Gson gson = new GsonBuilder().create();
- configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"),
+ void testInvalidSdcConfiguration() throws IOException {
+ final var gson = new GsonBuilder().create();
+ var configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"),
SdcReceptionHandlerConfigurationParameterGroup.class);
- final ValidationResult validationResult = configParameters.validate();
+ final var validationResult = configParameters.validate();
assertFalse(validationResult.isValid());
}
@Test
- public void testEmptyParameters() {
- final SdcReceptionHandlerConfigurationParameterGroup configurationParameters =
+ void testEmptyParameters() {
+ final var configurationParameters =
CommonTestData.getPolicyDecoderParameters("src/test/resources/parameters/EmptyParameters.json",
SdcReceptionHandlerConfigurationParameterGroup.class);
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/TestExceptions.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/TestExceptions.java
index 2b6c98d..3d40957 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/TestExceptions.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/TestExceptions.java
@@ -20,13 +20,13 @@
package org.onap.policy.distribution.reception.handling.sdc.exceptions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class TestExceptions {
+class TestExceptions {
@Test
- public void test() {
+ void test() {
new ExceptionsTester().test(ArtifactDownloadException.class);
}
}
diff --git a/pom.xml b/pom.xml
index 6f7a2c3..8447372 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,19 +22,19 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.parent</groupId>
<artifactId>integration</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath />
+ <version>4.0.1-SNAPSHOT</version>
+ <relativePath/>
</parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>policy-distribution</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
@@ -45,8 +45,11 @@
<!-- Default Sonar configuration -->
<jacoco.dataFile>${project.basedir}/../target/code-coverage/jacoco-ut.exec</jacoco.dataFile>
- <policy.common.version>2.0.0-SNAPSHOT</policy.common.version>
- <policy.models.version>3.0.0-SNAPSHOT</policy.models.version>
+ <policy.common.version>2.0.1-SNAPSHOT</policy.common.version>
+ <policy.models.version>3.0.1-SNAPSHOT</policy.models.version>
+ <surefireArgLine>
+ --add-opens java.base/java.lang=ALL-UNNAMED
+ </surefireArgLine>
</properties>
<modules>
@@ -61,8 +64,8 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -72,7 +75,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/reception/pom.xml b/reception/pom.xml
index 935e016..994c985 100644
--- a/reception/pom.xml
+++ b/reception/pom.xml
@@ -18,12 +18,13 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>policy-distribution</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>reception</artifactId>
diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/decoding/TestExceptions.java b/reception/src/test/java/org/onap/policy/distribution/reception/decoding/TestExceptions.java
index 2b52eb2..7b70bb5 100644
--- a/reception/src/test/java/org/onap/policy/distribution/reception/decoding/TestExceptions.java
+++ b/reception/src/test/java/org/onap/policy/distribution/reception/decoding/TestExceptions.java
@@ -20,13 +20,13 @@
package org.onap.policy.distribution.reception.decoding;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class TestExceptions {
+class TestExceptions {
@Test
- public void test() {
+ void test() {
new ExceptionsTester().test(PluginInitializationException.class);
new ExceptionsTester().test(PluginTerminationException.class);
new ExceptionsTester().test(PolicyDecodingException.class);
diff --git a/reception/src/test/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandlerTest.java b/reception/src/test/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandlerTest.java
index 1dc4bfe..cde5eb7 100644
--- a/reception/src/test/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandlerTest.java
+++ b/reception/src/test/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandlerTest.java
@@ -21,16 +21,16 @@
package org.onap.policy.distribution.reception.handling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.forwarding.PolicyForwarder;
import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
@@ -47,7 +47,7 @@
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class AbstractReceptionHandlerTest {
+class AbstractReceptionHandlerTest {
private static final String DISTRIBUTION_GROUP = "DummyDistributionGroup";
private static final String DECODER_TYPE = "DummyDecoder";
@@ -61,24 +61,24 @@
private static final String DECODER_CONFIGURATION_PARAMETERS = "DummyDecoderConfiguration";
@Test
- public void testInputReceived() throws PolicyDecodingException, NoSuchFieldException, SecurityException,
+ void testInputReceived() throws PolicyDecodingException, NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException, PluginInitializationException {
- final AbstractReceptionHandler handler = new DummyReceptionHandler();
+ final var handler = new DummyReceptionHandler();
- final ToscaEntity generatedPolicy1 = new DummyPolicy1();
- final ToscaEntity generatedPolicy2 = new DummyPolicy2();
+ final var generatedPolicy1 = new DummyPolicy1();
+ final var generatedPolicy2 = new DummyPolicy2();
- final PolicyDecoder<PolicyInput, ToscaEntity> policyDecoder1 =
+ final var policyDecoder1 =
new DummyDecoder(true, Collections.singletonList(generatedPolicy1));
- final PolicyDecoder<PolicyInput, ToscaEntity> policyDecoder2 =
+ final var policyDecoder2 =
new DummyDecoder(true, Collections.singletonList(generatedPolicy2));
final Collection<PolicyDecoder<PolicyInput, ToscaEntity>> policyDecoders = new ArrayList<>();
policyDecoders.add(policyDecoder1);
policyDecoders.add(policyDecoder2);
- final DummyPolicyForwarder policyForwarder1 = new DummyPolicyForwarder();
- final DummyPolicyForwarder policyForwarder2 = new DummyPolicyForwarder();
+ final var policyForwarder1 = new DummyPolicyForwarder();
+ final var policyForwarder2 = new DummyPolicyForwarder();
final Collection<PolicyForwarder> policyForwarders = new ArrayList<>();
policyForwarders.add(policyForwarder1);
@@ -96,27 +96,28 @@
assertTrue(policyForwarder2.receivedPolicy(generatedPolicy2));
}
- @Test(expected = PolicyDecodingException.class)
- public void testInputReceivedNoSupportingDecoder() throws PolicyDecodingException, NoSuchFieldException,
+ @Test
+ void testInputReceivedNoSupportingDecoder() throws NoSuchFieldException,
SecurityException, IllegalArgumentException, IllegalAccessException, PluginInitializationException {
- final AbstractReceptionHandler handler = new DummyReceptionHandler();
+ final var handler = new DummyReceptionHandler();
- final PolicyDecoder<PolicyInput, ToscaEntity> policyDecoder = new DummyDecoder(false, Collections.emptyList());
- final DummyPolicyForwarder policyForwarder = new DummyPolicyForwarder();
+ final var policyDecoder = new DummyDecoder(false, Collections.emptyList());
+ final var policyForwarder = new DummyPolicyForwarder();
setUpPlugins(handler, Collections.singleton(policyDecoder), Collections.singleton(policyForwarder));
-
- handler.inputReceived(new DummyPolicyInput());
+ var policyInput = new DummyPolicyInput();
+ assertThrows(PolicyDecodingException.class, () -> handler.inputReceived(policyInput));
}
- @Test(expected = PolicyDecodingException.class)
- public void testInputReceivedNoDecoder() throws PolicyDecodingException, NoSuchFieldException, SecurityException,
+ @Test
+ void testInputReceivedNoDecoder() throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException, PluginInitializationException {
- final AbstractReceptionHandler handler = new DummyReceptionHandler();
+ final var handler = new DummyReceptionHandler();
- final DummyPolicyForwarder policyForwarder = new DummyPolicyForwarder();
+ final var policyForwarder = new DummyPolicyForwarder();
setUpPlugins(handler, Collections.emptySet(), Collections.singleton(policyForwarder));
- handler.inputReceived(new DummyPolicyInput());
+ var policyInput = new DummyPolicyInput();
+ assertThrows(PolicyDecodingException.class, () -> handler.inputReceived(policyInput));
}
static class DummyPolicyInput implements PolicyInput {
@@ -142,20 +143,20 @@
final Collection<PolicyDecoder<PolicyInput, ToscaEntity>> decoders,
final Collection<PolicyForwarder> forwarders) throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException, PluginInitializationException {
- final PluginHandlerParameters pluginParameters = getPluginHandlerParameters();
+ final var pluginParameters = getPluginHandlerParameters();
pluginParameters.setName(DISTRIBUTION_GROUP);
ParameterService.register(pluginParameters);
- final PluginHandler pluginHandler = new PluginHandler(pluginParameters.getName());
+ final var pluginHandler = new PluginHandler(pluginParameters.getName());
- final Field decodersField = pluginHandler.getClass().getDeclaredField("policyDecoders");
+ final var decodersField = pluginHandler.getClass().getDeclaredField("policyDecoders");
decodersField.setAccessible(true);
decodersField.set(pluginHandler, decoders);
- final Field forwardersField = pluginHandler.getClass().getDeclaredField("policyForwarders");
+ final var forwardersField = pluginHandler.getClass().getDeclaredField("policyForwarders");
forwardersField.setAccessible(true);
forwardersField.set(pluginHandler, forwarders);
- final Field pluginHandlerField = AbstractReceptionHandler.class.getDeclaredField("pluginHandler");
+ final var pluginHandlerField = AbstractReceptionHandler.class.getDeclaredField("pluginHandler");
pluginHandlerField.setAccessible(true);
pluginHandlerField.set(receptionHandler, pluginHandler);
ParameterService.deregister(pluginParameters.getName());
@@ -163,24 +164,23 @@
private Map<String, PolicyDecoderParameters> getPolicyDecoders() {
final Map<String, PolicyDecoderParameters> policyDecoders = new HashMap<>();
- final PolicyDecoderParameters pDParameters =
+ final var pDParameters =
new PolicyDecoderParameters(DECODER_TYPE, DECODER_CLASS_NAME, DECODER_CONFIGURATION_PARAMETERS);
policyDecoders.put(DECODER_KEY, pDParameters);
return policyDecoders;
}
private Map<String, PolicyForwarderParameters> getPolicyForwarders() {
- final Map<String, PolicyForwarderParameters> policyForwarders =
- new HashMap<>();
- final PolicyForwarderParameters pFParameters =
+ final Map<String, PolicyForwarderParameters> policyForwarders = new HashMap<>();
+ final var pFParameters =
new PolicyForwarderParameters(FORWARDER_TYPE, FORWARDER_CLASS_NAME, FORWARDER_CONFIGURATION_PARAMETERS);
policyForwarders.put(FORWARDER_KEY, pFParameters);
return policyForwarders;
}
private PluginHandlerParameters getPluginHandlerParameters() {
- final Map<String, PolicyDecoderParameters> policyDecoders = getPolicyDecoders();
- final Map<String, PolicyForwarderParameters> policyForwarders = getPolicyForwarders();
+ final var policyDecoders = getPolicyDecoders();
+ final var policyForwarders = getPolicyForwarders();
return new PluginHandlerParameters(policyDecoders, policyForwarders);
}
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
index 9a0ac31..68dc6b5 100644
--- 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
@@ -25,8 +25,7 @@
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ValidationResult;
+import org.junit.jupiter.api.Test;
import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
/**
@@ -35,29 +34,29 @@
* @author Adheli Tavares (adheli.tavares@est.tech)
*
*/
-public class TestPluginHandlerParameters {
+class TestPluginHandlerParameters {
@Test
- public void testValidate_PolicyDecodersEmpty() {
- PluginHandlerParameters emptyDecoder = new PluginHandlerParameters(new HashMap<>(), getPolicyForwarders());
+ void testValidate_PolicyDecodersEmpty() {
+ var emptyDecoder = new PluginHandlerParameters(new HashMap<>(), getPolicyForwarders());
- ValidationResult result = emptyDecoder.validate();
+ var result = emptyDecoder.validate();
assertThat(result.getResult()).contains("\"policyDecoders\"", "minimum").doesNotContain("\"policyForwarders\"");
}
@Test
- public void testValidate_PolicyForwardersNullEmpty() {
- PluginHandlerParameters emptyDecoder = new PluginHandlerParameters(getPolicyDecoders(), new HashMap<>());
+ void testValidate_PolicyForwardersNullEmpty() {
+ var emptyDecoder = new PluginHandlerParameters(getPolicyDecoders(), new HashMap<>());
- ValidationResult result = emptyDecoder.validate();
+ var result = emptyDecoder.validate();
assertThat(result.getResult()).contains("\"policyForwarders\"", "minimum").doesNotContain("\"policyDecoders\"");
}
private Map<String, PolicyDecoderParameters> getPolicyDecoders() {
final Map<String, PolicyDecoderParameters> policyDecoders = new HashMap<>();
- final PolicyDecoderParameters pDParameters =
+ final var pDParameters =
new PolicyDecoderParameters("DummyDecoder", getClass().getName(), "dummyDecoderConfiguration");
policyDecoders.put("DummyDecoder", pDParameters);
@@ -66,7 +65,7 @@
private Map<String, PolicyForwarderParameters> getPolicyForwarders() {
final Map<String, PolicyForwarderParameters> policyForwarders = new HashMap<>();
- final PolicyForwarderParameters pFParameters =
+ final var pFParameters =
new PolicyForwarderParameters("DummyForwarder", getClass().getName(), "dummyForwarderConfiguration");
policyForwarders.put("DummyForwarder", pFParameters);
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
index 127f122..d3a0e3d 100644
--- 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
@@ -21,19 +21,16 @@
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 static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.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.junit.jupiter.api.Test;
import org.onap.policy.distribution.reception.testclasses.DummyPolicyDecoderParameterGroup;
/**
@@ -45,49 +42,48 @@
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));
+ void testDeserialize() throws JsonSyntaxException, IOException {
+ final var validJsonFile = "src/test/resources/PolicyDecoderConfiguration.json";
+ final var mockJsonElement = JsonParser.parseString(getJsonValues(validJsonFile));
- Gson gson = new GsonBuilder().registerTypeAdapter(PolicyDecoderConfigurationParameterGroup.class,
+ var gson = new GsonBuilder().registerTypeAdapter(PolicyDecoderConfigurationParameterGroup.class,
new PolicyDecoderConfigurationParametersJsonAdapter()).create();
- PolicyDecoderConfigurationParameterGroup result =
- gson.fromJson(mockJsonElement, PolicyDecoderConfigurationParameterGroup.class);
+ var 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";
+ void testDeserialize_shouldThrowExceptionEmptyClassName() throws JsonSyntaxException, IOException {
+ final var jsonFile = "src/test/resources/EmptyClassName.json";
+ var 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";
+ void testDeserialize_shouldThrowExceptionNullClassName() throws JsonSyntaxException, IOException {
+ final var jsonFile = "src/test/resources/NullClassName.json";
+ var 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 "
+ void testDeserialize_shouldThrowExceptionWrongClassName() throws JsonSyntaxException, IOException {
+ final var jsonFile = "src/test/resources/WrongClassName.json";
+ var 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));
+ final var mockJsonElement = JsonParser.parseString(getJsonValues(jsonFile));
- Gson gson = new GsonBuilder().registerTypeAdapter(PolicyDecoderConfigurationParameterGroup.class,
+ var gson = new GsonBuilder().registerTypeAdapter(PolicyDecoderConfigurationParameterGroup.class,
new PolicyDecoderConfigurationParametersJsonAdapter()).create();
assertThatThrownBy(() -> gson.fromJson(mockJsonElement, PolicyDecoderConfigurationParameterGroup.class))
@@ -95,7 +91,7 @@
}
private String getJsonValues(String path) throws IOException {
- return new String(Files.readAllBytes(new File(path).toPath()), StandardCharsets.UTF_8);
+ return Files.readString(new File(path).toPath());
}
}
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
index dae91ab..d18c64d 100644
--- 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
@@ -23,7 +23,7 @@
import static org.assertj.core.api.Assertions.assertThat;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.distribution.reception.handling.DummyDecoder;
/**
@@ -32,15 +32,15 @@
* @author Adheli Tavares (adheli.tavares@est.tech)
*
*/
-public class TestPolicyDecoderParameters {
+class TestPolicyDecoderParameters {
static final String DECODER_CLASS_NAME = DummyDecoder.class.getName();
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);
+ void testValidate_DecoderTypeEmptyNull() {
+ var sutParams = new PolicyDecoderParameters(null, DECODER_CLASS_NAME, DECODER_CONFIG);
assertThat(sutParams.validate().getResult()).contains("\"decoderType\" value \"null\" INVALID, is null");
@@ -51,13 +51,13 @@
}
@Test
- public void testValidate_ClassNameEmptyNull() {
- PolicyDecoderParameters nullClassName = new PolicyDecoderParameters(DECODER_TYPE, null, DECODER_CONFIG);
+ void testValidate_ClassNameEmptyNull() {
+ var nullClassName = new PolicyDecoderParameters(DECODER_TYPE, null, DECODER_CONFIG);
assertThat(nullClassName.validate().getResult())
.contains("\"decoderClassName\" value \"null\" INVALID, is null");
- PolicyDecoderParameters emptyClassName = new PolicyDecoderParameters(DECODER_TYPE, "", DECODER_CONFIG);
+ var emptyClassName = new PolicyDecoderParameters(DECODER_TYPE, "", DECODER_CONFIG);
assertThat(emptyClassName.validate().getResult()).contains("\"decoderClassName\" value \"\" INVALID, is blank");
}
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
index ae85e0d..40e29f6 100644
--- 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
@@ -21,19 +21,16 @@
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 static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.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.junit.jupiter.api.Test;
import org.onap.policy.distribution.reception.testclasses.DummyReceptionHandlerParameterGroup;
/**
@@ -42,17 +39,17 @@
* @author Adheli Tavares (adheli.tavares@est.tech)
*
*/
-public class TestReceptionHandlerConfigurationParametersJsonAdapter {
+class TestReceptionHandlerConfigurationParametersJsonAdapter {
@Test
- public void testDeserialize() throws JsonSyntaxException, IOException {
- final String validJsonFile = "src/test/resources/ReceptionHandlerConfiguration.json";
- final JsonElement mockJsonElement = JsonParser.parseString(getJsonValues(validJsonFile));
+ void testDeserialize() throws JsonSyntaxException, IOException {
+ final var validJsonFile = "src/test/resources/ReceptionHandlerConfiguration.json";
+ final var mockJsonElement = JsonParser.parseString(getJsonValues(validJsonFile));
- Gson gson = new GsonBuilder().registerTypeAdapter(ReceptionHandlerConfigurationParameterGroup.class,
+ var gson = new GsonBuilder().registerTypeAdapter(ReceptionHandlerConfigurationParameterGroup.class,
new ReceptionHandlerConfigurationParametersJsonAdapter()).create();
- ReceptionHandlerConfigurationParameterGroup result =
+ var result =
gson.fromJson(mockJsonElement, ReceptionHandlerConfigurationParameterGroup.class);
assertNotNull(result);
@@ -60,34 +57,34 @@
}
@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";
+ void testDeserialize_shouldThrowExceptionEmptyClassName() throws JsonSyntaxException, IOException {
+ final var jsonFile = "src/test/resources/EmptyClassName.json";
+ var 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";
+ void testDeserialize_shouldThrowExceptionNullClassName() throws JsonSyntaxException, IOException {
+ final var jsonFile = "src/test/resources/NullClassName.json";
+ var 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 "
+ void testDeserialize_shouldThrowExceptionWrongClassName() throws JsonSyntaxException, IOException {
+ final var jsonFile = "src/test/resources/WrongClassName.json";
+ var 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));
+ final var mockJsonElement = JsonParser.parseString(getJsonValues(jsonFile));
- Gson gson = new GsonBuilder().registerTypeAdapter(ReceptionHandlerConfigurationParameterGroup.class,
+ var gson = new GsonBuilder().registerTypeAdapter(ReceptionHandlerConfigurationParameterGroup.class,
new ReceptionHandlerConfigurationParametersJsonAdapter()).create();
assertThatThrownBy(() -> gson.fromJson(mockJsonElement, ReceptionHandlerConfigurationParameterGroup.class))
@@ -95,7 +92,6 @@
}
private String getJsonValues(String path) throws IOException {
- return new String(Files.readAllBytes(new File(path).toPath()), StandardCharsets.UTF_8);
+ return Files.readString(new File(path).toPath());
}
-
}
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
index b12af00..1cfd65d 100644
--- 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
@@ -25,7 +25,7 @@
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
import org.onap.policy.distribution.reception.handling.DummyDecoder;
@@ -35,47 +35,47 @@
* @author Adheli Tavares (adheli.tavares@est.tech)
*
*/
-public class TestReceptionHandlerParameters {
+class TestReceptionHandlerParameters {
@Test
- public void testValidate_ClassNotFound() {
- final String className = "org.onap.policy.distribution.reception.testclasses.NotExistent";
+ void testValidate_ClassNotFound() {
+ final var className = "org.onap.policy.distribution.reception.testclasses.NotExistent";
- ReceptionHandlerParameters sutParams = getReceptionHandlerParameters(className);
+ var sutParams = getReceptionHandlerParameters(className);
sutParams.setName(className);
assertThat(sutParams.validate().getResult()).contains("class is not in the classpath");
}
@Test
- public void testValidate_ReceptionHandlerTypeNullEmpty() {
- final String className = DummyDecoder.class.getName();
- final PluginHandlerParameters pHParameters =
+ void testValidate_ReceptionHandlerTypeNullEmpty() {
+ final var className = DummyDecoder.class.getName();
+ final var pHParameters =
new PluginHandlerParameters(getPolicyDecoders(), getPolicyForwarders());
- ReceptionHandlerParameters nullType = new ReceptionHandlerParameters(null, className, className, pHParameters);
+ var nullType = new ReceptionHandlerParameters(null, className, className, pHParameters);
assertThat(nullType.validate().getResult())
.contains("\"receptionHandlerType\" value \"null\" INVALID, is null");
- ReceptionHandlerParameters emptyType = new ReceptionHandlerParameters("", className, className, pHParameters);
+ var emptyType = new ReceptionHandlerParameters("", className, className, pHParameters);
assertThat(emptyType.validate().getResult()).contains("\"receptionHandlerType\" value \"\" INVALID, is blank")
.doesNotContain("classpath");
}
@Test
- public void testValidate_ReceptionHandlerClassNameNullEmpty() {
+ void testValidate_ReceptionHandlerClassNameNullEmpty() {
final PluginHandlerParameters pHParameters =
new PluginHandlerParameters(getPolicyDecoders(), getPolicyForwarders());
- ReceptionHandlerParameters nullType = new ReceptionHandlerParameters("DummyReceptionHandler", null,
+ var nullType = new ReceptionHandlerParameters("DummyReceptionHandler", null,
"dummyReceptionHandlerConfiguration", pHParameters);
assertThat(nullType.validate().getResult())
.contains("\"receptionHandlerClassName\" value \"null\" INVALID, is null");
- ReceptionHandlerParameters emptyType = new ReceptionHandlerParameters("DummyReceptionHandler", "",
+ var emptyType = new ReceptionHandlerParameters("DummyReceptionHandler", "",
"dummyReceptionHandlerConfiguration", pHParameters);
assertThat(emptyType.validate().getResult())
@@ -83,10 +83,10 @@
}
@Test
- public void testValidate_PluginHandlerParametersNull() {
- final String className = "org.onap.policy.distribution.reception.testclasses.DummyReceptionHandler";
+ void testValidate_PluginHandlerParametersNull() {
+ final var className = "org.onap.policy.distribution.reception.testclasses.DummyReceptionHandler";
- ReceptionHandlerParameters sutParams = new ReceptionHandlerParameters("DummyReceptionHandler", className,
+ var sutParams = new ReceptionHandlerParameters("DummyReceptionHandler", className,
"dummyReceptionHandlerConfiguration", null);
assertThat(sutParams.validate().getResult())
@@ -94,10 +94,10 @@
}
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",
+ final var policyDecoders = getPolicyDecoders();
+ final var policyForwarders = getPolicyForwarders();
+ final var pHParameters = new PluginHandlerParameters(policyDecoders, policyForwarders);
+ final var rhParameters = new ReceptionHandlerParameters("DummyReceptionHandler",
className, "dummyReceptionHandlerConfiguration", pHParameters);
return rhParameters;
}
@@ -105,7 +105,7 @@
private Map<String, PolicyDecoderParameters> getPolicyDecoders() {
final Map<String, PolicyDecoderParameters> policyDecoders = new HashMap<>();
- final PolicyDecoderParameters pDParameters =
+ final var pDParameters =
new PolicyDecoderParameters("DummyDecoder", DummyDecoder.class.getName(), "dummyDecoderConfiguration");
policyDecoders.put("DummyDecoder", pDParameters);
@@ -115,7 +115,7 @@
private Map<String, PolicyForwarderParameters> getPolicyForwarders() {
final Map<String, PolicyForwarderParameters> policyForwarders = new HashMap<>();
- final PolicyForwarderParameters pFParameters = new PolicyForwarderParameters("DummyForwarder",
+ final var pFParameters = new PolicyForwarderParameters("DummyForwarder",
DummyDecoder.class.getName(), "dummyForwarderConfiguration");
policyForwarders.put("DummyForwarder", pFParameters);
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
index 3c14da3..c3ea7bb 100644
--- 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
@@ -20,87 +20,87 @@
package org.onap.policy.distribution.reception.statistics;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Class to perform unit test of DistributionStatisticsManager.
*
* @author Adheli Tavares (adheli.tavares@est.tech)
* */
-public class TestDistributionStatisticsManager {
+class TestDistributionStatisticsManager {
- @Before
- public void reset() {
+ @BeforeEach
+ void reset() {
DistributionStatisticsManager.resetAllStatistics();
}
@Test
- public void testUpdateTotalDistributionCount() {
+ void testUpdateTotalDistributionCount() {
DistributionStatisticsManager.updateTotalDistributionCount();
assertEquals(1L, DistributionStatisticsManager.getTotalDistributionCount());
}
@Test
- public void testUpdateDistributionSuccessCount() {
+ void testUpdateDistributionSuccessCount() {
DistributionStatisticsManager.updateDistributionSuccessCount();
assertEquals(1L, DistributionStatisticsManager.getDistributionSuccessCount());
}
@Test
- public void testUpdateDistributionFailureCount() {
+ void testUpdateDistributionFailureCount() {
DistributionStatisticsManager.updateDistributionFailureCount();
assertEquals(1L, DistributionStatisticsManager.getDistributionFailureCount());
}
@Test
- public void testUpdateTotalDownloadCount() {
+ void testUpdateTotalDownloadCount() {
DistributionStatisticsManager.updateTotalDownloadCount();
assertEquals(1L, DistributionStatisticsManager.getTotalDownloadCount());
}
@Test
- public void testUpdateDownloadSuccessCount() {
+ void testUpdateDownloadSuccessCount() {
DistributionStatisticsManager.updateDownloadSuccessCount();
assertEquals(1L, DistributionStatisticsManager.getDownloadSuccessCount());
}
@Test
- public void testUpdateDownloadFailureCount() {
+ void testUpdateDownloadFailureCount() {
DistributionStatisticsManager.updateDownloadFailureCount();
assertEquals(1L, DistributionStatisticsManager.getDownloadFailureCount());
}
@Test
- public void testGetTotalDistributionCount() {
+ void testGetTotalDistributionCount() {
assertEquals(0L, DistributionStatisticsManager.getTotalDistributionCount());
}
@Test
- public void testGetDistributionSuccessCount() {
+ void testGetDistributionSuccessCount() {
assertEquals(0L, DistributionStatisticsManager.getDistributionSuccessCount());
}
@Test
- public void testGetDistributionFailureCount() {
+ void testGetDistributionFailureCount() {
assertEquals(0L, DistributionStatisticsManager.getDistributionFailureCount());
}
@Test
- public void testGetTotalDownloadCount() {
+ void testGetTotalDownloadCount() {
assertEquals(0L, DistributionStatisticsManager.getTotalDownloadCount());
}
@Test
- public void testGetDownloadSuccessCount() {
+ void testGetDownloadSuccessCount() {
assertEquals(0L, DistributionStatisticsManager.getDownloadSuccessCount());
}
@Test
- public void testGetDownloadFailureCount() {
+ void testGetDownloadFailureCount() {
assertEquals(0L, DistributionStatisticsManager.getDownloadFailureCount());
}
}
diff --git a/testsuites/performance/pom.xml b/testsuites/performance/pom.xml
index a9f3225..3e3bd54 100644
--- a/testsuites/performance/pom.xml
+++ b/testsuites/performance/pom.xml
@@ -18,12 +18,13 @@
limitations under the License.
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>distribution-testsuites</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>distribution-performance</artifactId>
<build>
diff --git a/testsuites/pom.xml b/testsuites/pom.xml
index dc69333..5c152fa 100644
--- a/testsuites/pom.xml
+++ b/testsuites/pom.xml
@@ -18,18 +18,19 @@
limitations under the License.
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>policy-distribution</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>distribution-testsuites</artifactId>
<packaging>pom</packaging>
<properties>
- <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. -->
+ <!-- There is no code in this submodule, only holds interfaces. So skip sonar. -->
<sonar.skip>true</sonar.skip>
</properties>
diff --git a/testsuites/stability/pom.xml b/testsuites/stability/pom.xml
index c59f48e..c0444f0 100644
--- a/testsuites/stability/pom.xml
+++ b/testsuites/stability/pom.xml
@@ -18,12 +18,13 @@
limitations under the License.
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.distribution</groupId>
<artifactId>distribution-testsuites</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.0.1-SNAPSHOT</version>
</parent>
<artifactId>distribution-stability</artifactId>
<build>
diff --git a/version.properties b/version.properties
index 4ba0a9a..3288dcd 100644
--- a/version.properties
+++ b/version.properties
@@ -4,7 +4,7 @@
minor=3
minor=0
-patch=0
+patch=1
base_version=${major}.${minor}.${patch}