aboutsummaryrefslogtreecommitdiffstats
path: root/models-sim/policy-models-simulators/src
diff options
context:
space:
mode:
authorwaynedunican <wayne.dunican@est.tech>2024-06-13 09:29:20 +0100
committerwaynedunican <wayne.dunican@est.tech>2024-06-20 16:46:07 +0100
commit9c8f53960b265ec82814f9a4a54ff44ce0682dde (patch)
tree0d2a7fbbc250422274316ea8cb6e9a1418681e89 /models-sim/policy-models-simulators/src
parent9e8684c88435734cb2e142208436cec647cde887 (diff)
Convert models to JUnit 5
Review for models-sim and models-tosca Issue-ID: POLICY-5042 Change-Id: I72533933b34df145e1ff4eb40ebafa93f85cca9a Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'models-sim/policy-models-simulators/src')
-rw-r--r--models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/CdsServerParametersTest.java13
-rw-r--r--models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java13
-rw-r--r--models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java38
3 files changed, 33 insertions, 31 deletions
diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/CdsServerParametersTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/CdsServerParametersTest.java
index 7b0ab6bbe..03442b968 100644
--- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/CdsServerParametersTest.java
+++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/CdsServerParametersTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Bell Canada.
* Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,19 +20,19 @@
package org.onap.policy.models.simulators;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
-public class CdsServerParametersTest {
+class CdsServerParametersTest {
@Test
- public void testValidateString() throws CoderException {
+ void testValidateString() throws CoderException {
// some fields missing
ValidationResult result = new CdsServerParameters().validate();
assertFalse(result.isValid());
diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java
index 0560e851c..77f694233 100644
--- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java
+++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/ClassRestServerParametersTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,20 +21,20 @@
package org.onap.policy.models.simulators;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.File;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
-public class ClassRestServerParametersTest {
+class ClassRestServerParametersTest {
@Test
- public void testValidateString() throws CoderException {
+ void testValidateString() throws CoderException {
// some fields missing
ValidationResult result = new ClassRestServerParameters().validate();
assertFalse(result.isValid());
diff --git a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java
index 09064f472..67cd7d800 100644
--- a/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java
+++ b/models-sim/policy-models-simulators/src/test/java/org/onap/policy/models/simulators/MainTest.java
@@ -24,9 +24,9 @@ package org.onap.policy.models.simulators;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -41,10 +41,10 @@ import java.util.Map.Entry;
import java.util.Properties;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
@@ -56,7 +56,7 @@ import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.common.utils.security.SelfSignedKeyStore;
-public class MainTest {
+class MainTest {
private static final String PARAMETER_FILE = "simParameters.json";
private static final String HOST = "localhost";
private static final String EXPECTED_EXCEPTION = "expected exception";
@@ -66,7 +66,7 @@ public class MainTest {
/**
* Saves system properties.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws IOException, InterruptedException {
savedValues = new HashMap<>();
@@ -91,7 +91,7 @@ public class MainTest {
/**
* Restores system properties.
*/
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
for (Entry<String, String> ent : savedValues.entrySet()) {
if (ent.getValue() == null) {
@@ -105,8 +105,8 @@ public class MainTest {
/**
* Shuts down the simulator instance.
*/
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
Main main = Main.getInstance();
if (main != null && main.isAlive()) {
main.shutdown();
@@ -118,7 +118,7 @@ public class MainTest {
* least one of them.
*/
@Test
- public void testMain() throws Exception {
+ void testMain() throws Exception {
Main.main(new String[0]);
assertTrue(Main.getInstance() == null || !Main.getInstance().isAlive());
@@ -126,7 +126,7 @@ public class MainTest {
// don't need to wait long, because buildXxx() does the wait for us
for (int port : new int[] {6666, 6667, 6668, 6669, 6670, 6680}) {
- assertTrue("simulator on port " + port, NetworkUtil.isTcpPortOpen(HOST, port, 1, 100));
+ assertTrue(NetworkUtil.isTcpPortOpen(HOST, port, 1, 100), "simulator on port " + port);
}
// it's sufficient to verify that one of the simulators works
@@ -134,7 +134,7 @@ public class MainTest {
}
@Test
- public void testMainMinimalParameters() {
+ void testMainMinimalParameters() {
Main.main(new String[] {"minParameters.json"});
assertNotNull(Main.getInstance());
assertTrue(Main.getInstance().isAlive());
@@ -156,7 +156,7 @@ public class MainTest {
* Tests readParameters() when the file cannot be found.
*/
@Test
- public void testReadParametersNoFile() {
+ void testReadParametersNoFile() {
assertThatIllegalArgumentException().isThrownBy(() -> new Main("missing-file.json"))
.withCauseInstanceOf(FileNotFoundException.class);
}
@@ -165,7 +165,7 @@ public class MainTest {
* Tests readParameters() when the json cannot be decoded.
*/
@Test
- public void testReadParametersInvalidJson() throws CoderException {
+ void testReadParametersInvalidJson() throws CoderException {
Coder coder = mock(Coder.class);
when(coder.decode(any(String.class), any())).thenThrow(new CoderException(EXPECTED_EXCEPTION));
@@ -181,7 +181,7 @@ public class MainTest {
* Tests buildRestServer() when the server port is not open.
*/
@Test
- public void testBuildRestServerNotOpen() {
+ void testBuildRestServerNotOpen() {
HttpServletServer server = mock(HttpServletServer.class);
Main main = new Main(PARAMETER_FILE) {
@@ -203,7 +203,7 @@ public class MainTest {
* Tests buildRestServer() when the port checker is interrupted.
*/
@Test
- public void testBuildRestServerInterrupted() throws InterruptedException {
+ void testBuildRestServerInterrupted() throws InterruptedException {
HttpServletServer server = mock(HttpServletServer.class);
Main main = new Main(PARAMETER_FILE) {