aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/reception-plugins/src
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-08-22 14:47:22 +0100
committerLiam Fallon <liam.fallon@est.tech>2023-08-24 14:30:09 +0000
commita354531009fcfe529d08183249601adb6d0adc6e (patch)
treec6386f6056c62c20e1730ddc535fff40aeb1e27f /plugins/reception-plugins/src
parent960773d01db3072b4a57dbd69e911df1af2df47c (diff)
Upgrade policy-distribution to JUnit 5java-17
Issue-ID: POLICY-4805 Change-Id: I47aaed48f3f05c2f1c5814882386e114dbad0443 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'plugins/reception-plugins/src')
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/AutomationCompositionDecoderFileInCsarParameterGroupTest.java18
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/AutomationCompositionDecoderFileInCsarTest.java42
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyParameterGroupTest.java18
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicyTest.java58
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java52
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java50
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestComponentDoneStatusMessage.java18
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestDistributionStatusMessage.java18
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java88
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java63
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/exceptions/TestExceptions.java6
11 files changed, 207 insertions, 224 deletions
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 ea844e4e..201133f2 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 @@ import org.onap.policy.distribution.reception.handling.sdc.CommonTestData;
*
* @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 @@ public class AutomationCompositionDecoderFileInCsarParameterGroupTest {
}
@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 @@ public class AutomationCompositionDecoderFileInCsarParameterGroupTest {
}
@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 279bb976..eca893dc 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,33 +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.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)
*/
-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);
@@ -59,33 +57,33 @@ public class AutomationCompositionDecoderFileInCsarTest {
/**
* 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 c3cf3f5b..0164fe57 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 @@ import org.onap.policy.distribution.reception.handling.sdc.CommonTestData;
*
* @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 @@ public class PolicyDecoderFileInCsarToPolicyParameterGroupTest {
}
@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 @@ public class PolicyDecoderFileInCsarToPolicyParameterGroupTest {
}
@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 640f4723..88b4c863 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,32 +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.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)
*/
-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);
@@ -58,47 +56,47 @@ public class PolicyDecoderFileInCsarToPolicyTest {
/**
* 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)
@@ -107,13 +105,13 @@ public class PolicyDecoderFileInCsarToPolicyTest {
@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 fcad382f..c36cd363 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,11 +32,10 @@ import java.io.IOException;
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.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.stubbing.Answer;
import org.onap.policy.common.parameters.ParameterService;
@@ -46,12 +46,12 @@ import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of {@link FileSystemReceptionHandler}.
*/
-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;
@@ -64,25 +64,25 @@ public class TestFileSystemReceptionHandler {
* @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()))
@@ -90,8 +90,8 @@ public class TestFileSystemReceptionHandler {
}
@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(() -> {
@@ -101,17 +101,17 @@ public class TestFileSystemReceptionHandler {
}
@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;
@@ -120,7 +120,7 @@ public class TestFileSystemReceptionHandler {
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) {
@@ -131,7 +131,7 @@ public class TestFileSystemReceptionHandler {
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) {
@@ -153,7 +153,7 @@ public class TestFileSystemReceptionHandler {
} 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 c8bcc7bd..46d7f27e 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 {
- @Test
- public void testFileSystemConfiguration() throws IOException {
- FileSystemReceptionHandlerConfigurationParameterGroup configParameters = null;
- String validPath = null;
+ @TempDir
+ private File tempFolder;
- validPath = tempFolder.getRoot().getAbsolutePath();
+ @Test
+ void testFileSystemConfiguration() throws IOException {
+ String validPath = tempFolder.getPath();
- 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 c5935822..d3f7ee00 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 @@ public class TestComponentDoneStatusMessage {
}
@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 62cf0f3d..86d4bdeb 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 @@ public class TestDistributionStatusMessage {
}
@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 9eaf67b1..9a993c6c 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,27 +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.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.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;
@@ -67,17 +65,17 @@ import org.onap.sdc.utils.DistributionActionResultEnum;
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
-public class TestSdcReceptionHandler {
+class TestSdcReceptionHandler {
private static final String DUMMY_SERVICE_CSAR = "dummyService.csar";
- private IDistributionClientResult successfulClientInitResult = mock(IDistributionClientResult.class);
- private IDistributionClientResult failureClientInitResult = mock(IDistributionClientResult.class);
- private IDistributionClient distributionClient = mock(IDistributionClient.class);
- private IDistributionClientDownloadResult successfulClientDownloadResult
+ 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 INotificationData notificationData = mock(INotificationData.class);
- private IArtifactInfo artifactInfo = mock(IArtifactInfo.class);
+ private final INotificationData notificationData = mock(INotificationData.class);
+ private final IArtifactInfo artifactInfo = mock(IArtifactInfo.class);
private SdcReceptionHandlerConfigurationParameterGroup pssdConfigParameters;
private SdcReceptionHandler sypHandler;
@@ -90,14 +88,14 @@ public class TestSdcReceptionHandler {
* @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();
+ final var sdcHandler = new SdcReceptionHandler();
sypHandler = spy(sdcHandler);
when(sypHandler.createSdcDistributionClient()).thenReturn(distributionClient);
@@ -123,19 +121,19 @@ public class TestSdcReceptionHandler {
}
- @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() {
when(successfulClientInitResult.getDistributionActionResult())
.thenReturn(DistributionActionResultEnum.FAIL).thenReturn(DistributionActionResultEnum.SUCCESS);
@@ -144,7 +142,7 @@ public class TestSdcReceptionHandler {
}
@Test
- public final void testStartSdcClient_Failure() {
+ final void testStartSdcClient_Failure() {
assertThatCode(() -> {
when(distributionClient.start()).thenReturn(failureClientInitResult)
.thenReturn(successfulClientInitResult);
@@ -153,7 +151,7 @@ public class TestSdcReceptionHandler {
}
@Test
- public final void testStopSdcClient() {
+ final void testStopSdcClient() {
assertThatCode(() -> {
sypHandler.initializeReception(pssdConfigParameters.getName());
sypHandler.destroy();
@@ -161,7 +159,7 @@ public class TestSdcReceptionHandler {
}
@Test
- public final void testStopSdcClient_Failure() {
+ final void testStopSdcClient_Failure() {
sypHandler.initializeReception(pssdConfigParameters.getName());
when(distributionClient.stop()).thenReturn(failureClientInitResult)
.thenReturn(successfulClientInitResult);
@@ -169,19 +167,19 @@ public class TestSdcReceptionHandler {
}
@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);
@@ -201,17 +199,17 @@ public class TestSdcReceptionHandler {
}
@Test
- public void testDownloadArtifactFailure() throws NoSuchFieldException, SecurityException, IllegalArgumentException,
+ void testDownloadArtifactFailure() throws NoSuchFieldException, SecurityException, IllegalArgumentException,
IllegalAccessException, PluginInitializationException {
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);
@@ -230,7 +228,7 @@ public class TestSdcReceptionHandler {
}
@Test
- public void testSendDistributionStatusFailure() throws NoSuchFieldException, SecurityException,
+ void testSendDistributionStatusFailure() throws NoSuchFieldException, SecurityException,
IllegalArgumentException, IllegalAccessException, PluginInitializationException {
when(successfulClientDownloadResult.getDistributionActionResult())
@@ -239,11 +237,11 @@ public class TestSdcReceptionHandler {
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);
@@ -260,34 +258,34 @@ public class TestSdcReceptionHandler {
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;
@@ -295,7 +293,7 @@ public class TestSdcReceptionHandler {
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 717f635d..0bf85681 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 @@ public class TestSdcReceptionHandlerConfigurationParameterGroup {
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 2b6c98dc..3d409575 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);
}
}