Clean up of JUnit 4 dependencies 56/138356/2
authorwaynedunican <wayne.dunican@est.tech>
Mon, 1 Jul 2024 13:15:04 +0000 (14:15 +0100)
committerwaynedunican <wayne.dunican@est.tech>
Tue, 2 Jul 2024 09:04:30 +0000 (10:04 +0100)
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>
17 files changed:
models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicConfigTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/FutureManagerTest.java
models-interactions/model-simulators/pom.xml
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLcmTopicServerTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AppcLegacyTopicServerTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/ExceptionsTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SdnrTopicServerTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/TopicServerTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/VfcSimulatorTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/XacmlSimulatorTest.java
models-sim/policy-models-simulators/pom.xml
pom.xml

index 9ce1b21..b2afce2 100644 (file)
@@ -30,8 +30,6 @@ import java.util.Map;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.resources.ResourceUtils;
index 57dbfb1..27b841a 100644 (file)
@@ -58,9 +58,7 @@ import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.runner.RunWith;
 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.utils.NetLoggerUtil.EventType;
index 8f833b7..b1199d0 100644 (file)
@@ -31,9 +31,7 @@ import java.util.concurrent.Executor;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
 import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicManager;
index f97ff9a..18bf314 100644 (file)
@@ -32,9 +32,7 @@ import java.util.concurrent.Future;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.runner.RunWith;
 import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
 import org.mockito.junit.jupiter.MockitoExtension;
 
 @ExtendWith(MockitoExtension.class)
index c3d840b..00cce39 100644 (file)
         </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>
index a730d97..76fc928 100644 (file)
@@ -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.
 
 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);
index c1badf6..48ae2da 100644 (file)
 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);
index 25cba30..d5428db 100644 (file)
@@ -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.
 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);
index 5770769..f3d5b3b 100644 (file)
@@ -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");
index e3d91f0..2d5da1c 100644 (file)
@@ -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.
 
 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));
     }
 }
index 96ea9fb..02b9653 100644 (file)
@@ -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.
 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);
index 129f284..0a8edb5 100644 (file)
@@ -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.
  * ================================================================================
 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(
index 972769d..a91431e 100644 (file)
@@ -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.
 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) {
index a290f56..d7b9432 100644 (file)
@@ -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.
 
 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);
index 417dcc9..24e9c93 100644 (file)
@@ -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.
 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);
index fc963aa..7a9dd7f 100644 (file)
             <artifactId>assertj-core</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-junit-jupiter</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>
diff --git a/pom.xml b/pom.xml
index 5bef29d..62c238b 100644 (file)
--- a/pom.xml
+++ b/pom.xml
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.mariadb.jdbc</groupId>
             <artifactId>mariadb-java-client</artifactId>