summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-simulators
diff options
context:
space:
mode:
authorwaynedunican <wayne.dunican@est.tech>2024-07-01 14:15:04 +0100
committerwaynedunican <wayne.dunican@est.tech>2024-07-02 10:04:30 +0100
commite82ebd1c0dac2df0044d0c23f29c8071b8e941a9 (patch)
tree0712ee1678dc61d0a02cc8a18aa81a3afa541324 /models-interactions/model-simulators
parent02e14c79d535773f2bb9e020f285208265e3f994 (diff)
Clean up of JUnit 4 dependencies
Cleanup of JUnit 4 dependenies Convert model-simulators to JUnit 5 Issue-ID: POLICY-5042 Change-Id: I608f675ef04437207769f624988cb4e630b67440 Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'models-interactions/model-simulators')
-rw-r--r--models-interactions/model-simulators/pom.xml4
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java23
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLcmTopicServerTest.java20
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLegacyTopicServerTest.java21
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java22
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/ExceptionsTest.java9
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SdnrTopicServerTest.java21
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java30
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/TopicServerTest.java27
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java24
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/XacmlSimulatorTest.java30
11 files changed, 118 insertions, 113 deletions
diff --git a/models-interactions/model-simulators/pom.xml b/models-interactions/model-simulators/pom.xml
index c3d840bcc..00cce39fe 100644
--- a/models-interactions/model-simulators/pom.xml
+++ b/models-interactions/model-simulators/pom.xml
@@ -108,8 +108,8 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>compile</scope>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
index a730d977d..76fc92826 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
@@ -3,7 +3,7 @@
* simulators
* ================================================================================
* Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-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.
@@ -21,25 +21,26 @@
package org.onap.policy.simulators;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.UUID;
-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.aai.AaiCqResponse;
import org.onap.policy.aai.AaiManager;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.rest.RestManager;
-public class AaiSimulatorTest {
+class AaiSimulatorTest {
/**
* Set up test class.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpSimulator() {
try {
var testServer = Util.buildAaiSim();
@@ -49,13 +50,13 @@ public class AaiSimulatorTest {
}
}
- @AfterClass
+ @AfterAll
public static void tearDownSimulator() {
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@Test
- public void testCqGet() {
+ void testCqGet() {
final AaiCqResponse response = new AaiManager(new RestManager()).getCustomQueryResponse("http://localhost:6666",
"testUser", "testPass", UUID.randomUUID(), "Ete_vFWCLvFWSNK_7ba1fbde_0");
assertNotNull(response);
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLcmTopicServerTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLcmTopicServerTest.java
index c1badf67b..48ae2da83 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLcmTopicServerTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLcmTopicServerTest.java
@@ -22,24 +22,24 @@
package org.onap.policy.simulators;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.utils.resources.ResourceUtils;
-@RunWith(MockitoJUnitRunner.class)
-public class AppcLcmTopicServerTest {
+@ExtendWith(MockitoExtension.class)
+class AppcLcmTopicServerTest {
private static final String MY_TOPIC = "my-topic";
@Mock
@@ -52,13 +52,13 @@ public class AppcLcmTopicServerTest {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
server = new AppcLcmTopicServer(sink, source);
}
@Test
- public void testProcessAppcLcmMessageWrapper() {
+ void testProcessAppcLcmMessageWrapper() {
String request = ResourceUtils.getResourceAsString("org/onap/policy/simulators/appclcm/appc.lcm.request.json");
assertNotNull(request);
@@ -74,7 +74,7 @@ public class AppcLcmTopicServerTest {
* Tests process() when the message is a response.
*/
@Test
- public void testProcessNoResponse() {
+ void testProcessNoResponse() {
// NOTE: this json file is a RESPONSE, not a request
String request = ResourceUtils.getResourceAsString("org/onap/policy/simulators/appclcm/appc.lcm.success.json");
assertNotNull(request);
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLegacyTopicServerTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLegacyTopicServerTest.java
index 25cba30bd..d5428dbd6 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLegacyTopicServerTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLegacyTopicServerTest.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.
@@ -21,24 +22,24 @@
package org.onap.policy.simulators;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.utils.resources.ResourceUtils;
-@RunWith(MockitoJUnitRunner.class)
-public class AppcLegacyTopicServerTest {
+@ExtendWith(MockitoExtension.class)
+class AppcLegacyTopicServerTest {
private static final String MY_TOPIC = "my-topic";
@Mock
@@ -51,13 +52,13 @@ public class AppcLegacyTopicServerTest {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
server = new AppcLegacyTopicServer(sink, source);
}
@Test
- public void testProcess() {
+ void testProcess() {
String request = ResourceUtils.getResourceAsString("org/onap/policy/simulators/appc/appc.legacy.request.json");
assertNotNull(request);
@@ -73,7 +74,7 @@ public class AppcLegacyTopicServerTest {
* Tests process() when the message is a response.
*/
@Test
- public void testProcessNoResponse() {
+ void testProcessNoResponse() {
// NOTE: this json file is a RESPONSE, not a request
String request = ResourceUtils.getResourceAsString("org/onap/policy/simulators/appc/appc.legacy.success.json");
assertNotNull(request);
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java
index 57707693c..f3d5b3b96 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023-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.
@@ -22,8 +22,8 @@
package org.onap.policy.simulators;
-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 com.google.protobuf.TextFormat.ParseException;
import com.google.protobuf.util.JsonFormat;
@@ -37,9 +37,9 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils;
-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.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
@@ -50,7 +50,7 @@ import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.common.utils.resources.ResourceUtils;
-public class CdsSimulatorTest {
+class CdsSimulatorTest {
private static final StandardCoder coder = new StandardCoder();
private CdsSimulator sim;
@@ -59,20 +59,20 @@ public class CdsSimulatorTest {
* Starts the simulator, allocating a unique port for each test so we don't have to
* wait for the prior server to shut down.
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
int port = NetworkUtil.allocPort();
sim = new CdsSimulator(Util.LOCALHOST, port);
sim.start();
}
- @After
+ @AfterEach
public void tearDown() {
sim.stop();
}
@Test
- public void test() throws Exception {
+ void test() throws Exception {
String reqstr = IOUtils.toString(Objects.requireNonNull(getClass().getResource("cds/cds.request.json")),
StandardCharsets.UTF_8);
Builder builder = ExecutionServiceInput.newBuilder();
@@ -127,7 +127,7 @@ public class CdsSimulatorTest {
}
@Test
- public void testGetResponse() throws IOException, CoderException, ParseException {
+ void testGetResponse() throws IOException, CoderException, ParseException {
CdsSimulator cdsSimulator = new CdsSimulator(Util.LOCALHOST, sim.getPort());
String reqstr = ResourceUtils.getResourceAsString(
"org/onap/policy/simulators/cds/cds.request.json");
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/ExceptionsTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/ExceptionsTest.java
index e3d91f0f2..2d5da1c11 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/ExceptionsTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/ExceptionsTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,18 +21,18 @@
package org.onap.policy.simulators;
-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.utils.test.ExceptionsTester;
/**
* Tests XxxException classes.
*/
-public class ExceptionsTest {
+class ExceptionsTest {
@Test
- public void testSimulatorRuntimeException() {
+ void testSimulatorRuntimeException() {
assertEquals(4, new ExceptionsTester().test(SimulatorRuntimeException.class));
}
}
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SdnrTopicServerTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SdnrTopicServerTest.java
index 96ea9fbcc..02b9653ec 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SdnrTopicServerTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SdnrTopicServerTest.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.
@@ -21,24 +22,24 @@
package org.onap.policy.simulators;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.utils.resources.ResourceUtils;
-@RunWith(MockitoJUnitRunner.class)
-public class SdnrTopicServerTest {
+@ExtendWith(MockitoExtension.class)
+class SdnrTopicServerTest {
private static final String MY_TOPIC = "my-topic";
@Mock
@@ -51,13 +52,13 @@ public class SdnrTopicServerTest {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
server = new SdnrTopicServer(sink, source);
}
@Test
- public void testProcess() {
+ void testProcess() {
String request = ResourceUtils.getResourceAsString("org/onap/policy/simulators/sdnr/vpci.sdnr.request.json");
assertNotNull(request);
@@ -73,7 +74,7 @@ public class SdnrTopicServerTest {
* Tests process() when the message is a response.
*/
@Test
- public void testProcessNoResponse() {
+ void testProcessNoResponse() {
// NOTE: this json file is a RESPONSE, not a request
String request = ResourceUtils.getResourceAsString("org/onap/policy/simulators/sdnr/vpci.sdnr.success.json");
assertNotNull(request);
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
index 129f2841b..0a8edb54c 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
@@ -3,7 +3,7 @@
* simulators
* ================================================================================
* Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2024 Nordix Foundation.
* Modifications Copyright (C) 2020 Wipro Limited.
* Modifications Copyright (C) 2022 CTC, Inc. and others.
* ================================================================================
@@ -24,17 +24,17 @@
package org.onap.policy.simulators;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+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.junit.jupiter.api.Assertions.fail;
import java.util.HashMap;
import java.util.UUID;
import org.apache.commons.lang3.tuple.Pair;
-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.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.rest.RestManager;
import org.onap.policy.so.SoCloudConfiguration;
@@ -49,12 +49,12 @@ import org.onap.policy.so.SoRequestInfo;
import org.onap.policy.so.SoRequestParameters;
import org.onap.policy.so.util.Serialization;
-public class SoSimulatorTest {
+class SoSimulatorTest {
/**
* Set up test class.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpSimulator() {
try {
var testServer = Util.buildSoSim();
@@ -64,7 +64,7 @@ public class SoSimulatorTest {
}
}
- @AfterClass
+ @AfterAll
public static void tearDownSimulator() {
HttpServletServerFactoryInstance.getServerFactory().destroy();
SoSimulatorJaxRs.setRequirePolling(false);
@@ -142,7 +142,7 @@ public class SoSimulatorTest {
}
@Test
- public void testPost() {
+ void testPost() {
SoSimulatorJaxRs.setRequirePolling(false);
String request = Serialization.gsonPretty.toJson(this.createTestRequest());
Pair<Integer, String> httpDetails = new RestManager().post(
@@ -184,7 +184,7 @@ public class SoSimulatorTest {
}
@Test
- public void testDelete() {
+ void testDelete() {
SoSimulatorJaxRs.setRequirePolling(false);
String request = Serialization.gsonPretty.toJson(this.createTestRequest());
Pair<Integer, String> httpDetails = new RestManager().delete(
@@ -226,7 +226,7 @@ public class SoSimulatorTest {
}
@Test
- public void testModifyNssi() {
+ void testModifyNssi() {
SoSimulatorJaxRs.setRequirePolling(false);
String request = Serialization.gsonPretty.toJson(this.createNssiRequest());
Pair<Integer, String> httpDetails = new RestManager().put(
@@ -252,7 +252,7 @@ public class SoSimulatorTest {
}
@Test
- public void testModifyCll() {
+ void testModifyCll() {
SoSimulatorJaxRs.setRequirePolling(false);
String request = Serialization.gsonPretty.toJson(this.createCllRequest());
Pair<Integer, String> httpDetails = new RestManager().put(
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/TopicServerTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/TopicServerTest.java
index 972769ddd..a91431e61 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/TopicServerTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/TopicServerTest.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.
@@ -21,23 +22,23 @@
package org.onap.policy.simulators;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.utils.coder.StandardCoder;
-@RunWith(MockitoJUnitRunner.class)
-public class TopicServerTest {
+@ExtendWith(MockitoExtension.class)
+class TopicServerTest {
private static final String MY_TOPIC = "my-topic";
private static final String TEXT = "hello";
private static final String RESPONSE = "world";
@@ -52,24 +53,24 @@ public class TopicServerTest {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
server = new MyServer();
}
@Test
- public void testConstructor() {
+ void testConstructor() {
verify(source).register(server);
}
@Test
- public void testShutdown() {
+ void testShutdown() {
server.shutdown();
verify(source).unregister(server);
}
@Test
- public void testOnTopicEvent() {
+ void testOnTopicEvent() {
server.onTopicEvent(CommInfrastructure.NOOP, MY_TOPIC, "{\"text\": \"hello\"}");
verify(sink).send(RESPONSE);
}
@@ -78,7 +79,7 @@ public class TopicServerTest {
* Tests onTopicEvent() when the coder throws an exception.
*/
@Test
- public void testOnTopicEventException() {
+ void testOnTopicEventException() {
assertThatIllegalArgumentException()
.isThrownBy(() -> server.onTopicEvent(CommInfrastructure.NOOP, MY_TOPIC, "{invalid json"));
@@ -89,7 +90,7 @@ public class TopicServerTest {
* Tests onTopicEvent() when there is no response.
*/
@Test
- public void testOnTopicEventNoResponse() {
+ void testOnTopicEventNoResponse() {
server = new MyServer() {
@Override
protected String process(MyRequest request) {
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
index a290f56f3..d7b943229 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
@@ -3,7 +3,7 @@
* simulators
* ================================================================================
* Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-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.
@@ -21,26 +21,26 @@
package org.onap.policy.simulators;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.HashMap;
import org.apache.commons.lang3.tuple.Pair;
-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.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.rest.RestManager;
import org.onap.policy.vfc.VfcResponse;
import org.onap.policy.vfc.util.Serialization;
-public class VfcSimulatorTest {
+class VfcSimulatorTest {
/**
* Set up test class.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpSimulator() {
try {
var testServer = Util.buildVfcSim();
@@ -50,13 +50,13 @@ public class VfcSimulatorTest {
}
}
- @AfterClass
+ @AfterAll
public static void tearDownSimulator() {
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@Test
- public void testPost() {
+ void testPost() {
final Pair<Integer, String> httpDetails =
new RestManager().post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username", "password",
new HashMap<>(), "application/json", "Some Request Here");
@@ -67,7 +67,7 @@ public class VfcSimulatorTest {
}
@Test
- public void testGet() {
+ void testGet() {
final Pair<Integer, String> httpDetails = new RestManager().get("http://localhost:6668/api/nslcm/v1/jobs/1234",
"username", "password", new HashMap<>());
assertNotNull(httpDetails);
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/XacmlSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/XacmlSimulatorTest.java
index 417dcc9b3..24e9c938f 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/XacmlSimulatorTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/XacmlSimulatorTest.java
@@ -3,7 +3,7 @@
* simulators
* ================================================================================
* Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-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.
@@ -22,16 +22,16 @@
package org.onap.policy.simulators;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.tuple.Pair;
-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.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -39,13 +39,13 @@ import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
import org.onap.policy.rest.RestManager;
-public class XacmlSimulatorTest {
+class XacmlSimulatorTest {
private static final StandardCoder coder = new StandardCoder();
/**
* Set up test class.
*/
- @BeforeClass
+ @BeforeAll
public static void setupSimulator() {
try {
var testServer = Util.buildXacmlSim();
@@ -55,13 +55,13 @@ public class XacmlSimulatorTest {
}
}
- @AfterClass
+ @AfterAll
public static void tearDownSimulator() {
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@Test
- public void testGuard() throws CoderException {
+ void testGuard() throws CoderException {
String request = makeGuardRequest("test_actor_id", "test_op_id", "test_target", "test_clName");
DecisionResponse decision = sendRequest(request);
assertEquals("Permit", decision.getStatus());
@@ -72,7 +72,7 @@ public class XacmlSimulatorTest {
}
@Test
- public void testConfigure() throws CoderException {
+ void testConfigure() throws CoderException {
// test retrieving a policy
String request = makeConfigureRequest("policy-id", "test-policy");
DecisionResponse decision = sendRequest(request);
@@ -92,7 +92,7 @@ public class XacmlSimulatorTest {
}
@Test
- public void testConfigureMissingFile() throws CoderException {
+ void testConfigureMissingFile() throws CoderException {
// test retrieving a policy
String request = makeConfigureRequest("policy-id", "bogus-policy");
DecisionResponse decision = sendRequest(request);
@@ -101,7 +101,7 @@ public class XacmlSimulatorTest {
}
@Test
- public void testConfigureInvalidJson() throws CoderException {
+ void testConfigureInvalidJson() throws CoderException {
// test retrieving a policy
String request = makeConfigureRequest("policy-id", "invalid-policy");
DecisionResponse decision = sendRequest(request);
@@ -110,7 +110,7 @@ public class XacmlSimulatorTest {
}
@Test
- public void testUnknownAction() throws CoderException {
+ void testUnknownAction() throws CoderException {
String request = makeGuardRequest("test_actor_id", "test_op_id", "test_target", "test_clName");
request = request.replace("guard", "bogus-action");
DecisionResponse decision = sendRequest(request);