aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions
diff options
context:
space:
mode:
authorwaynedunican <wayne.dunican@est.tech>2024-06-13 09:19:14 +0100
committerwaynedunican <wayne.dunican@est.tech>2024-06-20 12:24:23 +0100
commit9e8684c88435734cb2e142208436cec647cde887 (patch)
treeb06334cdf8309d36ceba948797ff071d14a2e82d /models-interactions
parent8236c8bab1a27bd721586550f8ba879abcba3239 (diff)
Convert models to JUnit 5
Review for models-actors Issue-ID: POLICY-5042 Change-Id: Ica07b9fbda1eca24a8a432d57a2d9af52c84625d Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'models-interactions')
-rw-r--r--models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/A1pActorTest.java17
-rw-r--r--models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/A1pOperationTest.java48
-rw-r--r--models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/BasicA1pOperation.java11
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiActorTest.java9
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java61
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java48
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperationTest.java57
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperationTest.java57
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiUtilTest.java7
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/BasicAaiOperation.java3
-rw-r--r--models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcActorTest.java16
-rw-r--r--models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java56
-rw-r--r--models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java12
-rw-r--r--models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java48
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorTest.java10
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java72
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmRecipeFormatterTest.java18
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorTest.java14
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java33
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java51
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java25
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfPropertiesTest.java13
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPnfPropertiesTest.java13
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPropertiesTest.java9
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationTargetVnfPropertiesTest.java13
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java21
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java52
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java21
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java46
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java11
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java30
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java19
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorTest.java17
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java56
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java36
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyCllTest.java46
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyNssiTest.java48
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/RestManagerResponseTest.java24
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorTest.java14
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java52
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java79
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java93
-rw-r--r--models-interactions/model-actors/actor.test/pom.xml14
-rw-r--r--models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicActor.java7
-rw-r--r--models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java4
-rw-r--r--models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java2
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java7
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java62
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java34
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java36
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/DummyActor.java7
-rw-r--r--models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/DummyOperator.java3
-rw-r--r--models-interactions/model-actors/actor.vfc/pom.xml5
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java18
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java44
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorTest.java12
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java36
-rw-r--r--models-interactions/model-actors/actor.xacml/pom.xml5
-rw-r--r--models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/ConfigureOperationTest.java46
-rw-r--r--models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionConfigTest.java27
-rw-r--r--models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionOperationTest.java58
-rw-r--r--models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionOperatorTest.java34
-rw-r--r--models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionParamsTest.java27
-rw-r--r--models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/GuardOperationTest.java57
-rw-r--r--models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/XacmlActorParamsTest.java25
-rw-r--r--models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/XacmlActorTest.java16
-rw-r--r--models-interactions/model-actors/actorServiceProvider/pom.xml5
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java75
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/CallbackManagerTest.java27
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DelayedIdentStringTest.java21
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DummyActor.java2
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java27
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/UtilTest.java47
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java43
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java72
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java104
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java39
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpActorTest.java19
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java99
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperatorTest.java39
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java57
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.java32
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java158
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartialTest.java27
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartialTest.java29
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ActorParamsTest.java33
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParamsTest.java21
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicConfigTest.java21
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParamsTest.java25
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParamsTest.java79
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParamsTest.java21
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpConfigTest.java23
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParamsTest.java25
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingActorParamsTest.java21
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingConfigTest.java23
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingParamsTest.java25
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ParameterValidationRuntimeExceptionTest.java27
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/FutureManagerTest.java25
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/ListenerManagerTest.java27
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java73
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtilTest.java7
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java39
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/ForwarderTest.java30
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/SelectorKeyTest.java25
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImplTest.java31
105 files changed, 1794 insertions, 1701 deletions
diff --git a/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/A1pActorTest.java b/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/A1pActorTest.java
index 654c35878..c22206c3f 100644
--- a/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/A1pActorTest.java
+++ b/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/A1pActorTest.java
@@ -2,6 +2,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2022 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,20 +20,20 @@
package org.onap.policy.controlloop.actor.a1p;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.actor.test.BasicActor;
import org.onap.policy.controlloop.actorserviceprovider.Operator;
-public class A1pActorTest extends BasicActor {
+class A1pActorTest extends BasicActor {
@Test
- public void testConstructor() {
+ void testConstructor() {
A1pActor prov = new A1pActor();
assertEquals(0, prov.getSequenceNumber());
@@ -44,13 +45,13 @@ public class A1pActorTest extends BasicActor {
}
@Test
- public void testActorService() {
+ void testActorService() {
// verify that it all plugs into the ActorService
verifyActorService(A1pActor.NAME, "service.yaml");
}
@Test
- public void testGetOperator() {
+ void testGetOperator() {
A1pActor sp = new A1pActor();
// should always return the same operator regardless of the name
diff --git a/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/A1pOperationTest.java b/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/A1pOperationTest.java
index 1d8e77147..930888da2 100644
--- a/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/A1pOperationTest.java
+++ b/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/A1pOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2022 AT&T Intellectual Property. 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,69 +22,69 @@
package org.onap.policy.controlloop.actor.a1p;
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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.List;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
import org.onap.policy.sdnr.util.StatusCodeEnum;
-@RunWith(MockitoJUnitRunner.class)
-public class A1pOperationTest extends BasicA1pOperation {
+@ExtendWith(MockitoExtension.class)
+ class A1pOperationTest extends BasicA1pOperation {
private A1pOperation operation;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
BasicBidirectionalTopicOperation.initBeforeClass(MY_SINK, MY_SOURCE);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
/**
* Setup.
*/
- @Before
+ @BeforeEach
@Override
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUp();
operation = new A1pOperation(params, config);
operation.setProperty(OperationProperties.EVENT_PAYLOAD, "my payload");
}
- @After
+ @AfterEach
@Override
- public void tearDown() {
+ void tearDown() {
super.tearDown();
}
@Test
- public void testA1pOperation() {
+ void testA1pOperation() {
assertEquals(DEFAULT_ACTOR, operation.getActorName());
assertEquals(DEFAULT_OPERATION, operation.getName());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(operation.getPropertyNames()).isEqualTo(List.of(OperationProperties.EVENT_PAYLOAD));
}
@Test
- public void testSetOutcome() {
+ void testSetOutcome() {
// with a status value
checkOutcome();
assertEquals(StatusCodeEnum.SUCCESS.toString(), outcome.getMessage());
diff --git a/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/BasicA1pOperation.java b/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/BasicA1pOperation.java
index 410dab176..3620b0cef 100644
--- a/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/BasicA1pOperation.java
+++ b/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/BasicA1pOperation.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2022 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,9 +21,9 @@
package org.onap.policy.controlloop.actor.a1p;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
@@ -68,7 +69,7 @@ public abstract class BasicA1pOperation extends BasicBidirectionalTopicOperation
/**
* Initializes mocks and sets up.
*/
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUpBasic();
response = new PciMessage();
@@ -85,7 +86,7 @@ public abstract class BasicA1pOperation extends BasicBidirectionalTopicOperation
status.setValue(StatusCodeEnum.SUCCESS.toString());
}
- public void tearDown() {
+ void tearDown() {
super.tearDownBasic();
}
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiActorTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiActorTest.java
index e56a55139..a31c7951b 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiActorTest.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiActorTest.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,19 +21,19 @@
package org.onap.policy.controlloop.actor.aai;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.actor.test.BasicActor;
-public class AaiActorTest extends BasicActor {
+class AaiActorTest extends BasicActor {
@Test
- public void testAaiActorServiceProvider() {
+ void testAaiActorServiceProvider() {
final AaiActor prov = new AaiActor();
// verify that it has the operators we expect
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
index 45db6b356..8768aec7b 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. 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,10 +22,11 @@
package org.onap.policy.controlloop.actor.aai;
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.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.verify;
@@ -39,12 +40,12 @@ import java.util.TreeMap;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.aai.AaiConstants;
import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
@@ -55,33 +56,33 @@ import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
-@RunWith(MockitoJUnitRunner.class)
-public class AaiCustomQueryOperationTest extends BasicAaiOperation {
+@ExtendWith(MockitoExtension.class)
+class AaiCustomQueryOperationTest extends BasicAaiOperation {
private static final StandardCoder coder = new StandardCoder();
private static final String MY_LINK = "my-link";
private AaiCustomQueryOperation oper;
- public AaiCustomQueryOperationTest() {
+ AaiCustomQueryOperationTest() {
super(AaiConstants.ACTOR_NAME, AaiCustomQueryOperation.NAME);
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
initBeforeClass();
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
/**
* Sets up.
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUpBasic();
oper = new AaiCustomQueryOperation(params, config);
@@ -92,7 +93,7 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
HttpParams opParams = HttpParams.builder().clientName(MY_CLIENT).path("v16/query").build();
config = new HttpConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -108,25 +109,25 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(AaiConstants.ACTOR_NAME, oper.getActorName());
assertEquals(AaiCustomQueryOperation.NAME, oper.getName());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_VSERVER_LINK));
}
@Test
- public void testGenerateSubRequestId() {
+ void testGenerateSubRequestId() {
oper.generateSubRequestId(3);
assertEquals("3", oper.getSubRequestId());
}
@Test
@SuppressWarnings("unchecked")
- public void testStartOperationAsync_testMakeRequest() throws Exception {
+ void testStartOperationAsync_testMakeRequest() throws Exception {
// need two responses
when(rawResponse.readEntity(String.class)).thenReturn(makeTenantReply()).thenReturn(makeCqReply());
lenient().when(webAsync.get(any(InvocationCallback.class))).thenAnswer(provideResponse(rawResponse));
@@ -140,13 +141,13 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation {
}
@Test
- public void testMakeHeaders() {
+ void testMakeHeaders() {
verifyHeaders(oper.makeHeaders());
}
@Test
@SuppressWarnings("unchecked")
- public void testMakeRequest_testGetVserverLink() throws Exception {
+ void testMakeRequest_testGetVserverLink() throws Exception {
when(rawResponse.readEntity(String.class)).thenReturn(makeCqReply());
when(webAsync.put(any(), any(InvocationCallback.class))).thenAnswer(provideResponse(rawResponse, 1));
@@ -165,18 +166,18 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation {
}
@Test
- public void testGetVserverLink() throws Exception {
+ void testGetVserverLink() throws Exception {
oper.setProperty(OperationProperties.AAI_VSERVER_LINK, MY_LINK);
assertEquals(MY_LINK, oper.getVserverLink());
}
@Test
- public void testSetOutcome() {
+ void testSetOutcome() {
outcome = oper.setOutcome(params.makeOutcome(), OperationResult.SUCCESS, null, null);
assertNull(outcome.getResponse());
outcome = oper.setOutcome(params.makeOutcome(), OperationResult.SUCCESS, null, "{}");
- assertTrue(outcome.getResponse() instanceof AaiCqResponse);
+ assertInstanceOf(AaiCqResponse.class, outcome.getResponse());
}
private String makeTenantReply() throws Exception {
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java
index e76dfbdd4..e9890b748 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. 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.
@@ -21,8 +21,8 @@
package org.onap.policy.controlloop.actor.aai;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -32,59 +32,59 @@ import static org.mockito.Mockito.when;
import jakarta.ws.rs.client.Invocation.Builder;
import jakarta.ws.rs.client.WebTarget;
import java.util.Map;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.aai.AaiConstants;
-@RunWith(MockitoJUnitRunner.class)
-public class AaiGetOperationTest extends BasicAaiOperation {
+@ExtendWith(MockitoExtension.class)
+class AaiGetOperationTest extends BasicAaiOperation {
private static final String MY_NAME = "my-operation-name";
private static final String PARAM_NAME = "my-param";
private static final String PARAM_VALUE = "my-value";
private AaiGetOperation oper;
- public AaiGetOperationTest() {
+ AaiGetOperationTest() {
super(AaiConstants.ACTOR_NAME, MY_NAME);
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
initBeforeClass();
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
/**
* Sets up.
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUpBasic();
oper = new AaiGetOperation(params, config);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(AaiConstants.ACTOR_NAME, oper.getActorName());
assertEquals(MY_NAME, oper.getName());
}
@Test
- public void testGenerateSubRequestId() {
+ void testGenerateSubRequestId() {
oper.generateSubRequestId(3);
assertEquals("3", oper.getSubRequestId());
}
@Test
- public void testAddQuery() {
+ void testAddQuery() {
WebTarget web = mock(WebTarget.class);
when(web.queryParam(any(), any())).thenReturn(web);
@@ -95,7 +95,7 @@ public class AaiGetOperationTest extends BasicAaiOperation {
}
@Test
- public void testAddHeaders() {
+ void testAddHeaders() {
Builder bldr = mock(Builder.class);
oper.addHeaders(bldr, Map.of("hdrA", "valA", "hdrB", "valB"));
@@ -105,7 +105,7 @@ public class AaiGetOperationTest extends BasicAaiOperation {
}
@Test
- public void testGetRetry() {
+ void testGetRetry() {
// use default if null retry
assertEquals(AaiGetOperation.DEFAULT_RETRY, oper.getRetry(null));
@@ -115,7 +115,7 @@ public class AaiGetOperationTest extends BasicAaiOperation {
}
@Test
- public void testMakeHeaders() {
+ void testMakeHeaders() {
verifyHeaders(oper.makeHeaders());
}
}
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperationTest.java
index c306e0031..cf2bb1b62 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperationTest.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. 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.
@@ -23,9 +23,10 @@ package org.onap.policy.controlloop.actor.aai;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-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.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@@ -33,12 +34,12 @@ import jakarta.ws.rs.client.InvocationCallback;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.aai.AaiConstants;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -49,45 +50,45 @@ import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
-@RunWith(MockitoJUnitRunner.class)
-public class AaiGetPnfOperationTest extends BasicAaiOperation {
+@ExtendWith(MockitoExtension.class)
+class AaiGetPnfOperationTest extends BasicAaiOperation {
private static final String INPUT_FIELD = "input";
private static final String TEXT = "my-text";
private AaiGetPnfOperation oper;
- public AaiGetPnfOperationTest() {
+ AaiGetPnfOperationTest() {
super(AaiConstants.ACTOR_NAME, AaiGetPnfOperation.NAME);
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
initBeforeClass();
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
/**
* Sets up.
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUpBasic();
oper = new AaiGetPnfOperation(params, config);
oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, TARGET_ENTITY);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(AaiConstants.ACTOR_NAME, oper.getActorName());
assertEquals(AaiGetPnfOperation.NAME, oper.getName());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_TARGET_ENTITY));
}
@@ -95,7 +96,7 @@ public class AaiGetPnfOperationTest extends BasicAaiOperation {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
HttpParams opParams = HttpParams.builder().clientName(MY_CLIENT).path("v16/network/pnfs/pnf").build();
config = new HttpConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -105,14 +106,14 @@ public class AaiGetPnfOperationTest extends BasicAaiOperation {
outcome = oper.start().get();
assertEquals(OperationResult.SUCCESS, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof StandardCoderObject);
+ assertInstanceOf(StandardCoderObject.class, outcome.getResponse());
}
/**
* Tests "failure" case with simulator.
*/
@Test
- public void testFailure() throws Exception {
+ void testFailure() throws Exception {
HttpParams opParams = HttpParams.builder().clientName(MY_CLIENT).path("v16/network/pnfs/pnf").build();
config = new HttpConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -126,7 +127,7 @@ public class AaiGetPnfOperationTest extends BasicAaiOperation {
@Test
@SuppressWarnings("unchecked")
- public void testStartOperationAsync_testStartQueryAsync() throws Exception {
+ void testStartOperationAsync_testStartQueryAsync() throws Exception {
// return a map in the reply
Map<String, String> reply = Map.of(INPUT_FIELD, TEXT);
@@ -153,7 +154,7 @@ public class AaiGetPnfOperationTest extends BasicAaiOperation {
*/
@Test
@SuppressWarnings("unchecked")
- public void testStartOperationAsyncFailure() throws Exception {
+ void testStartOperationAsyncFailure() throws Exception {
when(rawResponse.getStatus()).thenReturn(500);
when(rawResponse.readEntity(String.class)).thenReturn("");
@@ -173,7 +174,7 @@ public class AaiGetPnfOperationTest extends BasicAaiOperation {
* Tests startOperationAsync() when a property is missing.
*/
@Test
- public void testStartOperationAsyncMissingProperty() throws Exception {
+ void testStartOperationAsyncMissingProperty() throws Exception {
oper = new AaiGetPnfOperation(params, config);
oper.generateSubRequestId(1);
@@ -184,7 +185,7 @@ public class AaiGetPnfOperationTest extends BasicAaiOperation {
}
@Test
- public void testGetKey() {
+ void testGetKey() {
assertEquals("AAI.Pnf." + TARGET_ENTITY, AaiGetPnfOperation.getKey(TARGET_ENTITY));
}
}
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperationTest.java
index 13b8e0536..65d3fe831 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperationTest.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. 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.
@@ -23,9 +23,10 @@ package org.onap.policy.controlloop.actor.aai;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-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.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@@ -33,12 +34,12 @@ import jakarta.ws.rs.client.InvocationCallback;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.aai.AaiConstants;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -49,45 +50,45 @@ import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
-@RunWith(MockitoJUnitRunner.class)
-public class AaiGetTenantOperationTest extends BasicAaiOperation {
+@ExtendWith(MockitoExtension.class)
+class AaiGetTenantOperationTest extends BasicAaiOperation {
private static final String INPUT_FIELD = "input";
private static final String TEXT = "my-text";
private AaiGetTenantOperation oper;
- public AaiGetTenantOperationTest() {
+ AaiGetTenantOperationTest() {
super(AaiConstants.ACTOR_NAME, AaiGetTenantOperation.NAME);
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
initBeforeClass();
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
/**
* Sets up.
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUpBasic();
oper = new AaiGetTenantOperation(params, config);
oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, TARGET_ENTITY);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(AaiConstants.ACTOR_NAME, oper.getActorName());
assertEquals(AaiGetTenantOperation.NAME, oper.getName());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_TARGET_ENTITY));
}
@@ -95,7 +96,7 @@ public class AaiGetTenantOperationTest extends BasicAaiOperation {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
HttpParams opParams = HttpParams.builder().clientName(MY_CLIENT).path("v16/search/nodes-query").build();
config = new HttpConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -105,14 +106,14 @@ public class AaiGetTenantOperationTest extends BasicAaiOperation {
outcome = oper.start().get();
assertEquals(OperationResult.SUCCESS, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof StandardCoderObject);
+ assertInstanceOf(StandardCoderObject.class, outcome.getResponse());
}
/**
* Tests "failure" case with simulator.
*/
@Test
- public void testFailure() throws Exception {
+ void testFailure() throws Exception {
HttpParams opParams = HttpParams.builder().clientName(MY_CLIENT).path("v16/search/nodes-query").build();
config = new HttpConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -126,7 +127,7 @@ public class AaiGetTenantOperationTest extends BasicAaiOperation {
@Test
@SuppressWarnings("unchecked")
- public void testStartOperationAsync_testStartQueryAsync() throws Exception {
+ void testStartOperationAsync_testStartQueryAsync() throws Exception {
// return a map in the reply
Map<String, String> reply = Map.of(INPUT_FIELD, TEXT);
@@ -153,7 +154,7 @@ public class AaiGetTenantOperationTest extends BasicAaiOperation {
*/
@Test
@SuppressWarnings("unchecked")
- public void testStartOperationAsyncFailure() throws Exception {
+ void testStartOperationAsyncFailure() throws Exception {
when(rawResponse.getStatus()).thenReturn(500);
when(rawResponse.readEntity(String.class)).thenReturn("");
@@ -173,7 +174,7 @@ public class AaiGetTenantOperationTest extends BasicAaiOperation {
* Tests startOperationAsync() when a property is missing.
*/
@Test
- public void testStartOperationAsyncMissingProperty() throws Exception {
+ void testStartOperationAsyncMissingProperty() throws Exception {
oper = new AaiGetTenantOperation(params, config);
oper.generateSubRequestId(1);
@@ -184,7 +185,7 @@ public class AaiGetTenantOperationTest extends BasicAaiOperation {
}
@Test
- public void testGetKey() {
+ void testGetKey() {
assertEquals("AAI.Tenant." + TARGET_ENTITY, AaiGetTenantOperation.getKey(TARGET_ENTITY));
}
}
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiUtilTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiUtilTest.java
index ca8233a4d..baaf4a3ee 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiUtilTest.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiUtilTest.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.
@@ -21,12 +22,12 @@
package org.onap.policy.controlloop.actor.aai;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class AaiUtilTest extends BasicAaiOperation {
+class AaiUtilTest extends BasicAaiOperation {
@Test
- public void testMakeHeaders() {
+ void testMakeHeaders() {
makeContext();
Map<String, Object> headers = AaiUtil.makeHeaders(params);
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/BasicAaiOperation.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/BasicAaiOperation.java
index 9479d063b..0b03704e6 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/BasicAaiOperation.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/BasicAaiOperation.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,7 +21,7 @@
package org.onap.policy.controlloop.actor.aai;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Map;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcActorTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcActorTest.java
index 5d9ce0d7a..eda2ab586 100644
--- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcActorTest.java
+++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcActorTest.java
@@ -21,19 +21,19 @@
package org.onap.policy.controlloop.actor.appc;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.stream.Stream;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.controlloop.actor.test.BasicActor;
-@RunWith(MockitoJUnitRunner.class)
-public class AppcActorTest extends BasicActor {
+@ExtendWith(MockitoExtension.class)
+ class AppcActorTest extends BasicActor {
@Test
- public void testConstructor() {
+ void testConstructor() {
AppcActor prov = new AppcActor();
assertEquals(0, prov.getSequenceNumber());
@@ -45,7 +45,7 @@ public class AppcActorTest extends BasicActor {
}
@Test
- public void testActorService() {
+ void testActorService() {
// verify that it all plugs into the ActorService
verifyActorService(AppcActor.NAME, "service.yaml");
}
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java
index b6e9b34e7..caa190f71 100644
--- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java
+++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. 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,21 +22,21 @@
package org.onap.policy.controlloop.actor.appc;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.appc.CommonHeader;
import org.onap.policy.appc.Request;
import org.onap.policy.appc.ResponseCode;
@@ -46,46 +46,46 @@ import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicO
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-@RunWith(MockitoJUnitRunner.class)
-public class AppcOperationTest extends BasicAppcOperation {
+@ExtendWith(MockitoExtension.class)
+ class AppcOperationTest extends BasicAppcOperation {
private AppcOperation oper;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
// use same topic name for both sides
initBeforeClass(MY_SINK, MY_SINK);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
/**
* Sets up.
*/
- @Before
+ @BeforeEach
@Override
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUp();
oper = new MyOper(params, config);
}
- @After
+ @AfterEach
@Override
- public void tearDown() {
+ void tearDown() {
super.tearDown();
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
}
@Test
- public void testMakeRequest() {
+ void testMakeRequest() {
oper.generateSubRequestId(2);
String subreq = oper.getSubRequestId();
assertNotNull(subreq);
@@ -111,7 +111,7 @@ public class AppcOperationTest extends BasicAppcOperation {
}
@Test
- public void testConvertPayload() {
+ void testConvertPayload() {
Request request = oper.makeRequest(genvnf);
// @formatter:off
@@ -164,7 +164,7 @@ public class AppcOperationTest extends BasicAppcOperation {
}
@Test
- public void testGetExpectedKeyValues() {
+ void testGetExpectedKeyValues() {
oper.generateSubRequestId(2);
Request request = oper.makeRequest(genvnf);
assertEquals(Arrays.asList(request.getCommonHeader().getSubRequestId()),
@@ -172,7 +172,7 @@ public class AppcOperationTest extends BasicAppcOperation {
}
@Test
- public void testDetmStatusStringResponse() {
+ void testDetmStatusStringResponse() {
final ResponseStatus status = response.getStatus();
// null status (i.e., it's a Request, not a Response)
@@ -204,7 +204,7 @@ public class AppcOperationTest extends BasicAppcOperation {
}
@Test
- public void testSetOutcome() {
+ void testSetOutcome() {
final ResponseStatus status = response.getStatus();
// null status
@@ -233,7 +233,7 @@ public class AppcOperationTest extends BasicAppcOperation {
private class MyOper extends AppcOperation {
- public MyOper(ControlLoopOperationParams params, BidirectionalTopicConfig config) {
+ MyOper(ControlLoopOperationParams params, BidirectionalTopicConfig config) {
super(params, config, Collections.emptyList());
}
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java
index 25993d385..b934d8659 100644
--- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java
+++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.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,16 +21,15 @@
package org.onap.policy.controlloop.actor.appc;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
import java.util.function.BiConsumer;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.policy.appc.Request;
@@ -86,7 +86,7 @@ public abstract class BasicAppcOperation extends BasicBidirectionalTopicOperatio
/**
* Initializes mocks and sets up.
*/
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUpBasic();
response = new Response();
@@ -100,7 +100,7 @@ public abstract class BasicAppcOperation extends BasicBidirectionalTopicOperatio
genvnf.setVnfId(MY_VNF);
}
- public void tearDown() {
+ void tearDown() {
super.tearDownBasic();
}
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java
index e42811191..fad504434 100644
--- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java
+++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java
@@ -22,55 +22,55 @@
package org.onap.policy.controlloop.actor.appc;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.List;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.appc.Request;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams;
-@RunWith(MockitoJUnitRunner.class)
-public class ModifyConfigOperationTest extends BasicAppcOperation {
+@ExtendWith(MockitoExtension.class)
+ class ModifyConfigOperationTest extends BasicAppcOperation {
private ModifyConfigOperation oper;
- public ModifyConfigOperationTest() {
+ ModifyConfigOperationTest() {
super(DEFAULT_ACTOR, ModifyConfigOperation.NAME);
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
// use same topic name for both sides
initBeforeClass(MY_SINK, MY_SINK);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
- @Before
+ @BeforeEach
@Override
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUp();
oper = new ModifyConfigOperation(params, config);
}
- @After
+ @AfterEach
@Override
- public void tearDown() {
+ void tearDown() {
super.tearDown();
}
@@ -78,7 +78,7 @@ public class ModifyConfigOperationTest extends BasicAppcOperation {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
BidirectionalTopicParams opParams =
BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SINK).build();
config = new BidirectionalTopicConfig(blockingExecutor, opParams, topicMgr, AppcOperation.SELECTOR_KEYS);
@@ -96,18 +96,18 @@ public class ModifyConfigOperationTest extends BasicAppcOperation {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(ModifyConfigOperation.NAME, oper.getName());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_RESOURCE_VNF));
}
@Test
- public void testMakeRequest() throws CoderException {
+ void testMakeRequest() throws CoderException {
oper.setProperty(OperationProperties.AAI_RESOURCE_VNF, genvnf);
oper.generateSubRequestId(2);
diff --git a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorTest.java b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorTest.java
index 3ac57603b..96961f434 100644
--- a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorTest.java
+++ b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* 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,15 +21,15 @@
package org.onap.policy.controlloop.actor.appclcm;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class AppcLcmActorTest {
+class AppcLcmActorTest {
@Test
- public void testConstructor() {
+ void testConstructor() {
AppcLcmActor prov = new AppcLcmActor();
assertEquals(-1, prov.getSequenceNumber());
diff --git a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java
index e933621e9..8fa165f6f 100644
--- a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java
+++ b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java
@@ -24,25 +24,25 @@ package org.onap.policy.controlloop.actor.appclcm;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.appclcm.AppcLcmBody;
import org.onap.policy.appclcm.AppcLcmCommonHeader;
import org.onap.policy.appclcm.AppcLcmMessageWrapper;
@@ -64,8 +64,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
import org.onap.policy.simulators.AppcLcmTopicServer;
import org.onap.policy.simulators.TopicServer;
-@RunWith(MockitoJUnitRunner.class)
-public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcLcmMessageWrapper> {
+@ExtendWith(MockitoExtension.class)
+ class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcLcmMessageWrapper> {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String PAYLOAD_KEY1 = "key-A";
@@ -78,21 +78,21 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL
private AppcLcmMessageWrapper response;
private AppcLcmOperation oper;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
initBeforeClass(MY_SINK, MY_SOURCE);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
super.setUpBasic();
response = makeResponse();
@@ -101,8 +101,8 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL
oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, TARGET_ENTITY);
}
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
super.tearDownBasic();
}
@@ -115,7 +115,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
BidirectionalTopicParams opParams =
BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SOURCE).build();
config = new BidirectionalTopicConfig(blockingExecutor, opParams, topicMgr, AppcLcmOperation.SELECTOR_KEYS);
@@ -132,18 +132,18 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_TARGET_ENTITY));
}
@Test
- public void testMakeRequest() {
+ void testMakeRequest() {
oper.generateSubRequestId(2);
String subreq = oper.getSubRequestId();
assertNotNull(subreq);
@@ -167,7 +167,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL
* Tests makeRequest() when a property is missing.
*/
@Test
- public void testMakeRequestMissingProperty() throws Exception {
+ void testMakeRequestMissingProperty() throws Exception {
oper = new AppcLcmOperation(params, config);
oper.generateSubRequestId(1);
@@ -176,7 +176,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL
}
@Test
- public void testConvertPayload() {
+ void testConvertPayload() {
// only builds a payload for ConfigModify
params = params.toBuilder().operation(AppcLcmConstants.OPERATION_CONFIG_MODIFY).build();
oper = new AppcLcmOperation(params, config);
@@ -207,7 +207,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL
}
@Test
- public void testGetExpectedKeyValues() {
+ void testGetExpectedKeyValues() {
oper.generateSubRequestId(2);
AppcLcmMessageWrapper request = oper.makeRequest(2);
assertEquals(List.of(request.getBody().getInput().getCommonHeader().getSubRequestId()),
@@ -215,7 +215,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL
}
@Test
- public void testDetmStatus() {
+ void testDetmStatus() {
assertEquals(Status.SUCCESS, oper.detmStatus(null, response));
// failure
@@ -244,7 +244,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL
}
@Test
- public void testSetOutcome() {
+ void testSetOutcome() {
oper.setOutcome(outcome, OperationResult.SUCCESS, response);
assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertEquals(MY_MESSAGE, outcome.getMessage());
@@ -270,7 +270,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL
}
@Test
- public void testGetStatus() {
+ void testGetStatus() {
assertNotNull(oper.getStatus(response));
// null status
@@ -290,14 +290,14 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL
}
@Test
- public void testOperationSupportsPayload() {
+ void testOperationSupportsPayload() {
// these should support a payload
Set<String> supported = Set.of(AppcLcmConstants.OPERATION_CONFIG_MODIFY);
for (String name : supported) {
params = params.toBuilder().operation(name).build();
oper = new AppcLcmOperation(params, config);
- assertTrue(name, oper.operationSupportsPayload());
+ assertTrue(oper.operationSupportsPayload(), name);
}
// these should NOT support a payload
@@ -307,7 +307,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL
for (String name : unsupported) {
params = params.toBuilder().operation(name).build();
oper = new AppcLcmOperation(params, config);
- assertFalse(name, oper.operationSupportsPayload());
+ assertFalse(oper.operationSupportsPayload(), name);
}
// pick an operation that would ordinarily support payloads
diff --git a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmRecipeFormatterTest.java b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmRecipeFormatterTest.java
index 110dfabd9..6f1e8f02e 100644
--- a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmRecipeFormatterTest.java
+++ b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmRecipeFormatterTest.java
@@ -3,7 +3,7 @@
*
* ================================================================================
* Copyright (C) 2018 Nokia 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,14 +21,14 @@
package org.onap.policy.controlloop.actor.appclcm;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class AppcLcmRecipeFormatterTest {
+class AppcLcmRecipeFormatterTest {
@Test
- public void testShouldCorrectlyFormatRestartRequestWhenRestartGiven() {
+ void testShouldCorrectlyFormatRestartRequestWhenRestartGiven() {
// given
AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("Restart");
String expectedUrlRecipe = "restart";
@@ -44,7 +44,7 @@ public class AppcLcmRecipeFormatterTest {
}
@Test
- public void testShouldReturnCapitalizedBodySingleWordRecipe() {
+ void testShouldReturnCapitalizedBodySingleWordRecipe() {
// given
AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("moDify");
String expectedRecipe = "Modify";
@@ -57,7 +57,7 @@ public class AppcLcmRecipeFormatterTest {
}
@Test
- public void testShouldReturnCapitalizeAndJoinedBodyMultiWordRecipe() {
+ void testShouldReturnCapitalizeAndJoinedBodyMultiWordRecipe() {
// given
AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("coNfig-moDify");
String expectedRecipe = "ConfigModify";
@@ -70,7 +70,7 @@ public class AppcLcmRecipeFormatterTest {
}
@Test
- public void testShouldReturnLowercasedUrlSingleWordRecipe() {
+ void testShouldReturnLowercasedUrlSingleWordRecipe() {
// given
AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("ModIfy");
String expectedRecipe = "modify";
@@ -83,7 +83,7 @@ public class AppcLcmRecipeFormatterTest {
}
@Test
- public void testShouldReturnLowercasedDashJoinedUrlMultiWordRecipe() {
+ void testShouldReturnLowercasedDashJoinedUrlMultiWordRecipe() {
// given
AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("Config-MoDify");
String expectedRecipe = "config-modify";
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorTest.java
index 1d84e1c60..a3dfcaf50 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/CdsActorTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,24 +20,24 @@
package org.onap.policy.controlloop.actor.cds;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
import org.onap.policy.controlloop.actor.test.BasicActor;
import org.onap.policy.controlloop.actorserviceprovider.Operator;
-public class CdsActorTest extends BasicActor {
+class CdsActorTest extends BasicActor {
@Test
- public void testActorService() {
+ void testActorService() {
// verify that it all plugs into the ActorService
verifyActorService(CdsActorConstants.CDS_ACTOR, "service.yaml");
}
@Test
- public void testGetOperator() {
+ void testGetOperator() {
CdsActor sp = new CdsActor();
// should always return the same operator regardless of the name
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java
index 456b10fdf..dc7fcf447 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Bell Canada. All rights reserved.
* Modifications 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,27 +21,27 @@
package org.onap.policy.controlloop.actor.cds;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType;
import org.onap.ccsdk.cds.controllerblueprints.common.api.Status;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
-@RunWith(MockitoJUnitRunner.class)
-public class GrpcActorServiceManagerTest {
+@ExtendWith(MockitoExtension.class)
+ class GrpcActorServiceManagerTest {
CdsActorServiceManager manager;
CompletableFuture<OperationOutcome> future;
@@ -49,14 +50,14 @@ public class GrpcActorServiceManagerTest {
/**
* Sets up the fields.
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
future = new CompletableFuture<>();
manager = new CdsActorServiceManager(new OperationOutcome(), future);
}
@Test
- public void testOnMessageSuccess() throws InterruptedException, ExecutionException, TimeoutException {
+ void testOnMessageSuccess() throws InterruptedException, ExecutionException, TimeoutException {
Status status = Status.newBuilder().setEventType(EventType.EVENT_COMPONENT_EXECUTED).build();
output = ExecutionServiceOutput.newBuilder().setStatus(status).build();
@@ -67,7 +68,7 @@ public class GrpcActorServiceManagerTest {
}
@Test
- public void testOnMessageProcessing() throws InterruptedException, ExecutionException, TimeoutException {
+ void testOnMessageProcessing() throws InterruptedException, ExecutionException, TimeoutException {
Status status = Status.newBuilder().setEventType(EventType.EVENT_COMPONENT_PROCESSING).build();
output = ExecutionServiceOutput.newBuilder().setStatus(status).build();
@@ -77,7 +78,7 @@ public class GrpcActorServiceManagerTest {
}
@Test
- public void testOnMessageFailure() throws InterruptedException, ExecutionException, TimeoutException {
+ void testOnMessageFailure() throws InterruptedException, ExecutionException, TimeoutException {
Status status = Status.newBuilder().setEventType(EventType.EVENT_COMPONENT_FAILURE).build();
output = ExecutionServiceOutput.newBuilder().setStatus(status).build();
@@ -88,7 +89,7 @@ public class GrpcActorServiceManagerTest {
}
@Test
- public void testOnError() throws InterruptedException, ExecutionException, TimeoutException {
+ void testOnError() throws InterruptedException, ExecutionException, TimeoutException {
Exception exception = new Exception("something failed");
manager.onError(exception);
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java
index cae048b17..c5a20d9f2 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2020-2022 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.
@@ -22,9 +23,9 @@ package org.onap.policy.controlloop.actor.cds;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-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.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Collections;
import java.util.HashMap;
@@ -33,13 +34,13 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
@@ -60,8 +61,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
import org.onap.policy.simulators.CdsSimulator;
import org.onap.policy.simulators.Util;
-@RunWith(MockitoJUnitRunner.class)
-public class GrpcOperationTest {
+@ExtendWith(MockitoExtension.class)
+ class GrpcOperationTest {
private static final String MY_VNF = "my-vnf";
private static final String MY_SVC_ID = "my-service-instance-id";
private static final String RESOURCE_ID = "my-resource-id";
@@ -86,21 +87,21 @@ public class GrpcOperationTest {
private GrpcConfig config;
private GrpcOperation operation;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
sim = Util.buildCdsSim();
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
sim.stop();
}
/**
* Sets up the fields.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
// Setup the CDS properties
cdsProps = new CdsServerProperties();
cdsProps.setHost("10.10.10.10");
@@ -124,7 +125,7 @@ public class GrpcOperationTest {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
Map<String, Object> payload = Map.of("artifact_name", "my_artifact", "artifact_version", "1.0");
params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation("subscribe")
@@ -145,11 +146,11 @@ public class GrpcOperationTest {
OperationOutcome outcome = operation.start().get();
assertEquals(OperationResult.SUCCESS, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof ExecutionServiceOutput);
+ assertInstanceOf(ExecutionServiceOutput.class, outcome.getResponse());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
/*
* check VNF case with target entities
*/
@@ -195,7 +196,7 @@ public class GrpcOperationTest {
}
@Test
- public void testGetServiceInstanceId() {
+ void testGetServiceInstanceId() {
params = params.toBuilder().targetType(TargetType.VNF).targetEntityIds(targetEntityIds).build();
operation = new GrpcOperation(params, config);
loadVnfData();
@@ -206,7 +207,7 @@ public class GrpcOperationTest {
}
@Test
- public void testGetVnfId() {
+ void testGetVnfId() {
params = params.toBuilder().targetType(TargetType.VNF).targetEntityIds(targetEntityIds).build();
operation = new GrpcOperation(params, config);
loadVnfData();
@@ -231,7 +232,7 @@ public class GrpcOperationTest {
}
@Test
- public void testStartOperationAsync() {
+ void testStartOperationAsync() {
ControlLoopOperationParams clop =
ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
.operation(GrpcOperation.NAME)
@@ -248,7 +249,7 @@ public class GrpcOperationTest {
* Tests startOperationAsync() when the target type is PNF.
*/
@Test
- public void testStartOperationAsyncPnf() {
+ void testStartOperationAsyncPnf() {
ControlLoopOperationParams clop =
ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
.operation(GrpcOperation.NAME)
@@ -261,7 +262,7 @@ public class GrpcOperationTest {
}
@Test
- public void testStartOperationAsyncError() {
+ void testStartOperationAsyncError() {
operation = new GrpcOperation(params, config);
assertThatIllegalArgumentException()
.isThrownBy(() -> operation.startOperationAsync(1, params.makeOutcome()));
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java
index aa11d7efd..cd81dc7a5 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Bell Canada. All rights reserved.
* Modifications 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.
@@ -22,14 +23,14 @@ package org.onap.policy.controlloop.actor.cds;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Map;
import java.util.UUID;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.cds.properties.CdsServerProperties;
import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
@@ -37,8 +38,8 @@ import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-@RunWith(MockitoJUnitRunner.class)
-public class GrpcOperatorTest {
+@ExtendWith(MockitoExtension.class)
+ class GrpcOperatorTest {
GrpcOperator operation;
Map<String, Object> paramMap;
@@ -47,8 +48,8 @@ public class GrpcOperatorTest {
/**
* Initializes fields, including {@link #operation}.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
operation = new GrpcOperator(CdsActorConstants.CDS_ACTOR, GrpcOperation.NAME, GrpcOperation::new);
CdsServerProperties props = new CdsServerProperties();
@@ -64,7 +65,7 @@ public class GrpcOperatorTest {
}
@Test
- public void testGrpcOperator() {
+ void testGrpcOperator() {
assertEquals(CdsActorConstants.CDS_ACTOR, operation.getActorName());
assertEquals(GrpcOperation.NAME, operation.getName());
assertEquals(CdsActorConstants.CDS_ACTOR + "." + GrpcOperation.NAME, operation.getFullName());
@@ -72,7 +73,7 @@ public class GrpcOperatorTest {
@Test
- public void testDoConfigure() {
+ void testDoConfigure() {
operation.doConfigure(paramMap);
assertEquals(30000, operation.getCurrentConfig().getTimeoutMs());
@@ -83,7 +84,7 @@ public class GrpcOperatorTest {
}
@Test
- public void testBuildOperation() {
+ void testBuildOperation() {
ControlLoopOperationParams params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
.operation(GrpcOperation.NAME).requestId(UUID.randomUUID()).build();
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfPropertiesTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfPropertiesTest.java
index 44ebc12c5..1b20ef2bb 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfPropertiesTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrcpOperationResourceVnfPropertiesTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 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,12 +20,12 @@
package org.onap.policy.controlloop.actor.cds.properties;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.Collections;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.policy.cds.properties.CdsServerProperties;
@@ -35,16 +36,16 @@ import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-public class GrcpOperationResourceVnfPropertiesTest {
+class GrcpOperationResourceVnfPropertiesTest {
@Test
- public void getPropertyNames() {
+ void getPropertyNames() {
assertEquals(GrcpOperationResourceVnfProperties.VNF_PROPERTY_NAMES,
new GrcpOperationResourceVnfProperties().getPropertyNames());
}
@Test
- public void convertToAaiProperties() {
+ void convertToAaiProperties() {
ControlLoopOperationParams params =
ControlLoopOperationParams.builder()
.targetType(TargetType.VNF)
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPnfPropertiesTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPnfPropertiesTest.java
index 828ededa9..db034001a 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPnfPropertiesTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPnfPropertiesTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 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,12 +20,12 @@
package org.onap.policy.controlloop.actor.cds.properties;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.Collections;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.cds.properties.CdsServerProperties;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
@@ -37,17 +38,17 @@ import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-public class GrpcOperationPnfPropertiesTest {
+class GrpcOperationPnfPropertiesTest {
private static final Coder coder = new StandardCoder();
@Test
- public void getPropertyNames() {
+ void getPropertyNames() {
assertEquals(GrpcOperationPnfProperties.PNF_PROPERTY_NAMES,
new GrpcOperationPnfProperties().getPropertyNames());
}
@Test
- public void convertToAaiProperties() throws CoderException {
+ void convertToAaiProperties() throws CoderException {
ControlLoopOperationParams params =
ControlLoopOperationParams.builder()
.targetType(TargetType.PNF)
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPropertiesTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPropertiesTest.java
index 514df4e2f..df848e6d8 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPropertiesTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationPropertiesTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 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.
@@ -18,18 +19,18 @@
package org.onap.policy.controlloop.actor.cds.properties;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-public class GrpcOperationPropertiesTest {
+class GrpcOperationPropertiesTest {
@Test
- public void build() {
+ void build() {
ControlLoopOperationParams params = ControlLoopOperationParams.builder().targetType(TargetType.VNF).build();
assertEquals(GrpcOperationTargetVnfProperties.VNF_PROPERTY_NAMES,
GrpcOperationProperties.build(params).getPropertyNames());
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationTargetVnfPropertiesTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationTargetVnfPropertiesTest.java
index 798a96bed..dbc014203 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationTargetVnfPropertiesTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/properties/GrpcOperationTargetVnfPropertiesTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 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,12 +20,12 @@
package org.onap.policy.controlloop.actor.cds.properties;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.Collections;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.cds.properties.CdsServerProperties;
import org.onap.policy.common.utils.time.PseudoExecutor;
import org.onap.policy.controlloop.actor.cds.GrpcConfig;
@@ -33,16 +34,16 @@ import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-public class GrpcOperationTargetVnfPropertiesTest {
+class GrpcOperationTargetVnfPropertiesTest {
@Test
- public void getPropertyNames() {
+ void getPropertyNames() {
assertEquals(GrpcOperationTargetVnfProperties.VNF_PROPERTY_NAMES,
new GrpcOperationTargetVnfProperties().getPropertyNames());
}
@Test
- public void convertToAaiProperties() {
+ void convertToAaiProperties() {
ControlLoopOperationParams params =
ControlLoopOperationParams.builder()
.targetType(TargetType.VNF)
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java
index 7266d0311..731d0d269 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/request/CdsActionRequestTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Bell Canada. 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.
@@ -18,18 +19,18 @@
package org.onap.policy.controlloop.actor.cds.request;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.ImmutableMap;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
-public class CdsActionRequestTest {
+class CdsActionRequestTest {
private static final String TEST_ACTION_NAME = "vfw-modify-config";
private CdsActionRequest req = new CdsActionRequest();
@@ -37,8 +38,8 @@ public class CdsActionRequestTest {
/**
* Setup the CdsActionRequest object.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
req.setActionName(TEST_ACTION_NAME);
req.setResolutionKey("1234567890");
@@ -51,7 +52,7 @@ public class CdsActionRequestTest {
}
@Test
- public void testGenerateCdsPayloadWhenPolicyPayloadIsNotValidJsonString() throws CoderException {
+ void testGenerateCdsPayloadWhenPolicyPayloadIsNotValidJsonString() throws CoderException {
String payloadStr = "active-streams=5";
Map<String, String> payloadProps = ImmutableMap.of(CdsActorConstants.KEY_POLICY_PAYLOAD_DATA, payloadStr);
req.setPolicyPayload(payloadProps);
@@ -67,7 +68,7 @@ public class CdsActionRequestTest {
}
@Test
- public void testGenerateCdsPayloadWhenPolicyPayloadIsValidJsonString() throws CoderException {
+ void testGenerateCdsPayloadWhenPolicyPayloadIsValidJsonString() throws CoderException {
String payloadStr = "{\"active-streams\":\"5\"}";
Map<String, String> payloadProps = ImmutableMap.of(CdsActorConstants.KEY_POLICY_PAYLOAD_DATA, payloadStr);
req.setPolicyPayload(payloadProps);
@@ -83,7 +84,7 @@ public class CdsActionRequestTest {
}
@Test
- public void testGenerateCdsPayloadWhenPolicyPayloadIsNull() throws CoderException {
+ void testGenerateCdsPayloadWhenPolicyPayloadIsNull() throws CoderException {
Map<String, String> payloadProps = new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
{
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java
index 4619fee50..3510c4a67 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. 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.
@@ -23,16 +23,16 @@ package org.onap.policy.controlloop.actor.sdnc;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-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.assertInstanceOf;
import java.util.List;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
@@ -40,8 +40,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
import org.onap.policy.sdnc.SdncResponse;
-@RunWith(MockitoJUnitRunner.class)
-public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
+@ExtendWith(MockitoExtension.class)
+class BandwidthOnDemandOperationTest extends BasicSdncOperation {
private static final String MY_SERVICE = "my-service";
private static final String MY_VNF = "my-vnf";
private static final String MY_BANDWIDTH = "my-bandwidth";
@@ -49,17 +49,17 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
private BandwidthOnDemandOperation oper;
- public BandwidthOnDemandOperationTest() {
+ BandwidthOnDemandOperationTest() {
super(DEFAULT_ACTOR, BandwidthOnDemandOperation.NAME);
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
initBeforeClass();
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
@@ -67,20 +67,20 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
* Set up.
*/
@Override
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUp();
oper = new BandwidthOnDemandOperation(params, config);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(BandwidthOnDemandOperation.NAME, oper.getName());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
// @formatter:off
assertThat(oper.getPropertyNames()).isEqualTo(
List.of(
@@ -96,7 +96,7 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
HttpParams opParams = HttpParams.builder().clientName(MY_CLIENT)
.path("GENERIC-RESOURCE-API:vf-module-topology-operation").build();
config = new HttpConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -111,11 +111,11 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
outcome = oper.start().get();
assertEquals(OperationResult.SUCCESS, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof SdncResponse);
+ assertInstanceOf(SdncResponse.class, outcome.getResponse());
}
@Test
- public void testMakeRequest() throws Exception {
+ void testMakeRequest() throws Exception {
oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE);
oper.setProperty(OperationProperties.ENRICHMENT_BANDWIDTH, MY_BANDWIDTH);
oper.setProperty(OperationProperties.ENRICHMENT_BANDWIDTH_CHANGE_TIME, MY_CHANGE_TIME);
@@ -129,7 +129,7 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
*/
@Test
- public void testMakeRequestMissingBandwidth() throws Exception {
+ void testMakeRequestMissingBandwidth() throws Exception {
oper = new BandwidthOnDemandOperation(params, config);
oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE);
oper.setProperty(OperationProperties.ENRICHMENT_BANDWIDTH_CHANGE_TIME, MY_CHANGE_TIME);
@@ -143,7 +143,7 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
}
@Test
- public void testMakeRequestMissingBandwidthChangeTime() throws Exception {
+ void testMakeRequestMissingBandwidthChangeTime() throws Exception {
oper = new BandwidthOnDemandOperation(params, config);
oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE);
oper.setProperty(OperationProperties.ENRICHMENT_BANDWIDTH, MY_BANDWIDTH);
@@ -157,7 +157,7 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation {
}
@Test
- public void testMakeRequestMissingVnfId() throws Exception {
+ void testMakeRequestMissingVnfId() throws Exception {
oper = new BandwidthOnDemandOperation(params, config);
oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE);
oper.setProperty(OperationProperties.ENRICHMENT_BANDWIDTH, MY_BANDWIDTH);
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
index a88bb0231..cfdec987d 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.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,17 +21,17 @@
package org.onap.policy.controlloop.actor.sdnc;
-import static org.junit.Assert.assertEquals;
-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.assertEquals;
+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 static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
+import org.mockito.Mockito;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
@@ -47,7 +48,7 @@ import org.onap.policy.simulators.Util;
/**
* Superclass for various operator tests.
*/
-public abstract class BasicSdncOperation extends BasicHttpOperation {
+abstract class BasicSdncOperation extends BasicHttpOperation {
/**
* Fields to be ignored when comparing requests with JSON.
*/
@@ -58,7 +59,7 @@ public abstract class BasicSdncOperation extends BasicHttpOperation {
/**
* Constructs the object using a default actor and operation name.
*/
- public BasicSdncOperation() {
+ BasicSdncOperation() {
super();
}
@@ -68,7 +69,7 @@ public abstract class BasicSdncOperation extends BasicHttpOperation {
* @param actor actor name
* @param operation operation name
*/
- public BasicSdncOperation(String actor, String operation) {
+ BasicSdncOperation(String actor, String operation) {
super(actor, operation);
}
@@ -92,7 +93,7 @@ public abstract class BasicSdncOperation extends BasicHttpOperation {
/**
* Initializes mocks and sets up.
*/
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUpBasic();
response = new SdncResponse();
@@ -101,7 +102,7 @@ public abstract class BasicSdncOperation extends BasicHttpOperation {
response.setResponseOutput(output);
output.setResponseCode("200");
- when(rawResponse.readEntity(String.class)).thenReturn(new StandardCoder().encode(response));
+ Mockito.lenient().when(rawResponse.readEntity(String.class)).thenReturn(new StandardCoder().encode(response));
}
/**
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java
index df12ad520..5ef4b771a 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. 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,16 +22,16 @@
package org.onap.policy.controlloop.actor.sdnc;
import static org.assertj.core.api.Assertions.assertThat;
-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.assertInstanceOf;
import java.util.List;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
@@ -39,24 +39,24 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
import org.onap.policy.sdnc.SdncResponse;
-@RunWith(MockitoJUnitRunner.class)
-public class RerouteOperationTest extends BasicSdncOperation {
+@ExtendWith(MockitoExtension.class)
+class RerouteOperationTest extends BasicSdncOperation {
private static final String MY_SERVICE = "my-service";
private static final String MY_NETWORK = "my-network";
private RerouteOperation oper;
- public RerouteOperationTest() {
+ RerouteOperationTest() {
super(DEFAULT_ACTOR, RerouteOperation.NAME);
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
initBeforeClass();
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
@@ -64,8 +64,8 @@ public class RerouteOperationTest extends BasicSdncOperation {
* Set up.
*/
@Override
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUp();
oper = new RerouteOperation(params, config);
}
@@ -74,7 +74,7 @@ public class RerouteOperationTest extends BasicSdncOperation {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
HttpParams opParams = HttpParams.builder().clientName(MY_CLIENT)
.path("GENERIC-RESOURCE-API:network-topology-operation").build();
config = new HttpConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -87,17 +87,17 @@ public class RerouteOperationTest extends BasicSdncOperation {
outcome = oper.start().get();
assertEquals(OperationResult.SUCCESS, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof SdncResponse);
+ assertInstanceOf(SdncResponse.class, outcome.getResponse());
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(RerouteOperation.NAME, oper.getName());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
// @formatter:off
assertThat(oper.getPropertyNames()).isEqualTo(
List.of(
@@ -107,7 +107,7 @@ public class RerouteOperationTest extends BasicSdncOperation {
}
@Test
- public void testMakeRequest() throws Exception {
+ void testMakeRequest() throws Exception {
oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE);
oper.setProperty(OperationProperties.ENRICHMENT_NETWORK_ID, MY_NETWORK);
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java
index f0f280cb6..b7b209db2 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018-2019 Huawei. All rights reserved.
* Modifications Copyright (C) 2018-2020 AT&T Corp. 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.
@@ -22,17 +22,18 @@
package org.onap.policy.controlloop.actor.sdnc;
-import static org.junit.Assert.assertEquals;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.actor.test.BasicActor;
-public class SdncActorTest extends BasicActor {
+class SdncActorTest extends BasicActor {
@Test
- public void testSdncActor() {
+ void testSdncActor() {
final SdncActor prov = new SdncActor();
// verify that it has the operators we expect
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java
index 7c9cbb150..12b6db0e5 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. 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.
@@ -21,21 +21,21 @@
package org.onap.policy.controlloop.actor.sdnc;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collections;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.sdnc.SdncHealRequest;
import org.onap.policy.sdnc.SdncHealRequestHeaderInfo;
import org.onap.policy.sdnc.SdncRequest;
-@RunWith(MockitoJUnitRunner.class)
-public class SdncOperationTest extends BasicSdncOperation {
+@ExtendWith(MockitoExtension.class)
+ class SdncOperationTest extends BasicSdncOperation {
private static final String MY_URI = "my-uri";
@@ -46,8 +46,8 @@ public class SdncOperationTest extends BasicSdncOperation {
* Sets up.
*/
@Override
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUp();
request = new SdncRequest();
@@ -69,18 +69,18 @@ public class SdncOperationTest extends BasicSdncOperation {
}
@Test
- public void testSdncOperator() {
+ void testSdncOperator() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
}
@Test
- public void testStartOperationAsync_testStartRequestAsync() throws Exception {
+ void testStartOperationAsync_testStartRequestAsync() throws Exception {
verifyOperation(oper);
}
@Test
- public void testIsSuccess() {
+ void testIsSuccess() {
// success case
response.getResponseOutput().setResponseCode("200");
assertTrue(oper.isSuccess(null, response));
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java
index 64e88aa6e..ee9a3a1f2 100644
--- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java
+++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.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,9 +21,9 @@
package org.onap.policy.controlloop.actor.sdnr;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
@@ -45,14 +46,14 @@ import org.onap.policy.sdnr.util.StatusCodeEnum;
import org.onap.policy.simulators.SdnrTopicServer;
import org.onap.policy.simulators.TopicServer;
-public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperation<PciMessage> {
+abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperation<PciMessage> {
protected PciMessage response;
/**
* Constructs the object using a default actor and operation name.
*/
- public BasicSdnrOperation() {
+ BasicSdnrOperation() {
super();
}
@@ -62,14 +63,14 @@ public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperatio
* @param actor actor name
* @param operation operation name
*/
- public BasicSdnrOperation(String actor, String operation) {
+ BasicSdnrOperation(String actor, String operation) {
super(actor, operation);
}
/**
* Initializes mocks and sets up.
*/
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUpBasic();
response = new PciMessage();
@@ -86,7 +87,7 @@ public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperatio
status.setValue(StatusCodeEnum.SUCCESS.toString());
}
- public void tearDown() {
+ void tearDown() {
super.tearDownBasic();
}
@@ -101,7 +102,7 @@ public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperatio
* @param operation operation to run
*/
protected void verifyOperation(SdnrOperation operation)
- throws InterruptedException, ExecutionException, TimeoutException {
+ throws InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<OperationOutcome> future2 = operation.start();
executor.runAll(100);
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorTest.java
index 0f023ff55..68a81bb14 100644
--- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorTest.java
+++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorTest.java
@@ -3,6 +3,7 @@
* ================================================================================
* Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-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,20 +21,20 @@
package org.onap.policy.controlloop.actor.sdnr;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.Arrays;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.actor.test.BasicActor;
import org.onap.policy.controlloop.actorserviceprovider.Operator;
-public class SdnrActorTest extends BasicActor {
+class SdnrActorTest extends BasicActor {
@Test
- public void testConstructor() {
+ void testConstructor() {
SdnrActor prov = new SdnrActor();
assertEquals(0, prov.getSequenceNumber());
@@ -45,13 +46,13 @@ public class SdnrActorTest extends BasicActor {
}
@Test
- public void testActorService() {
+ void testActorService() {
// verify that it all plugs into the ActorService
verifyActorService(SdnrActor.NAME, "service.yaml");
}
@Test
- public void testGetOperator() {
+ void testGetOperator() {
SdnrActor sp = new SdnrActor();
// should always return the same operator regardless of the name
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
index 4ad19452a..e16ad1177 100644
--- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
+++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java
@@ -23,18 +23,18 @@ package org.onap.policy.controlloop.actor.sdnr;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.List;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
@@ -46,52 +46,52 @@ import org.onap.policy.sdnr.PciMessage;
import org.onap.policy.sdnr.PciRequest;
import org.onap.policy.sdnr.util.StatusCodeEnum;
-@RunWith(MockitoJUnitRunner.class)
-public class SdnrOperationTest extends BasicSdnrOperation {
+@ExtendWith(MockitoExtension.class)
+ class SdnrOperationTest extends BasicSdnrOperation {
private SdnrOperation operation;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
BasicBidirectionalTopicOperation.initBeforeClass(MY_SINK, MY_SOURCE);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
/**
* Setup.
*/
- @Before
+ @BeforeEach
@Override
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUp();
operation = new SdnrOperation(params, config);
operation.setProperty(OperationProperties.EVENT_PAYLOAD, "my payload");
}
- @After
+ @AfterEach
@Override
- public void tearDown() {
+ void tearDown() {
super.tearDown();
}
@Test
- public void testSdnrOperation() {
+ void testSdnrOperation() {
assertEquals(DEFAULT_ACTOR, operation.getActorName());
assertEquals(DEFAULT_OPERATION, operation.getName());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(operation.getPropertyNames()).isEqualTo(List.of(OperationProperties.EVENT_PAYLOAD));
}
@Test
- public void testMakeRequest() {
+ void testMakeRequest() {
operation.generateSubRequestId(1);
PciMessage request = operation.makeRequest(1);
@@ -114,7 +114,7 @@ public class SdnrOperationTest extends BasicSdnrOperation {
* Tests makeRequest() when a property is missing.
*/
@Test
- public void testMakeRequestMissingProperty() {
+ void testMakeRequestMissingProperty() {
operation = new SdnrOperation(params, config);
operation.generateSubRequestId(1);
@@ -125,7 +125,7 @@ public class SdnrOperationTest extends BasicSdnrOperation {
}
@Test
- public void testGetExpectedKeyValues() {
+ void testGetExpectedKeyValues() {
operation.generateSubRequestId(1);
PciMessage request = operation.makeRequest(1);
@@ -137,7 +137,7 @@ public class SdnrOperationTest extends BasicSdnrOperation {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
BidirectionalTopicParams opParams =
BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SOURCE).build();
config = new BidirectionalTopicConfig(blockingExecutor, opParams, topicMgr, SdnrOperation.SELECTOR_KEYS);
@@ -154,7 +154,7 @@ public class SdnrOperationTest extends BasicSdnrOperation {
}
@Test
- public void testDetmStatusStringResponse() {
+ void testDetmStatusStringResponse() {
final org.onap.policy.sdnr.Status status = response.getBody().getOutput().getStatus();
// null status
@@ -193,7 +193,7 @@ public class SdnrOperationTest extends BasicSdnrOperation {
}
@Test
- public void testSetOutcome() {
+ void testSetOutcome() {
// with a status value
checkOutcome();
assertEquals(StatusCodeEnum.SUCCESS.toString(), outcome.getMessage());
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
index 1e38861e2..286ed3ce4 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. 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.
@@ -47,20 +47,20 @@ import org.onap.policy.so.SoResponse;
/**
* Superclass for various operator tests.
*/
-public abstract class BasicSoOperation extends BasicHttpOperation {
+abstract class BasicSoOperation extends BasicHttpOperation {
protected static final String[] IGNORE_FIELDS = {"RequestID", "subRequestID", "seconds", "nanos"};
- public static final String MODEL_CUSTOM_ID = "my-model-customization-id";
- public static final String MODEL_INVAR_ID = "my-model-invariant-id";
- public static final String MODEL_NAME = "my-model-name";
- public static final String MODEL_VERSION = "my-model-version";
- public static final String MODEL_VERS_ID = "my-model-version-id";
- public static final String SUBSCRIPTION_SVC_TYPE = "my-subscription-service-type";
- public static final String MY_PATH = "my-path";
- public static final String POLL_PATH = "my-poll-path/";
- public static final int MAX_POLLS = 3;
- public static final int POLL_WAIT_SEC = 20;
- public static final Integer VF_COUNT = 10;
+ static final String MODEL_CUSTOM_ID = "my-model-customization-id";
+ static final String MODEL_INVAR_ID = "my-model-invariant-id";
+ static final String MODEL_NAME = "my-model-name";
+ static final String MODEL_VERSION = "my-model-version";
+ static final String MODEL_VERS_ID = "my-model-version-id";
+ static final String SUBSCRIPTION_SVC_TYPE = "my-subscription-service-type";
+ static final String MY_PATH = "my-path";
+ static final String POLL_PATH = "my-poll-path/";
+ static final int MAX_POLLS = 3;
+ static final int POLL_WAIT_SEC = 20;
+ static final Integer VF_COUNT = 10;
@Mock
protected HttpPollingConfig config;
@@ -72,7 +72,7 @@ public abstract class BasicSoOperation extends BasicHttpOperation {
/**
* Constructs the object using a default actor and operation name.
*/
- public BasicSoOperation() {
+ BasicSoOperation() {
super();
}
@@ -82,7 +82,7 @@ public abstract class BasicSoOperation extends BasicHttpOperation {
* @param actor actor name
* @param operation operation name
*/
- public BasicSoOperation(String actor, String operation) {
+ BasicSoOperation(String actor, String operation) {
super(actor, operation);
}
@@ -93,8 +93,8 @@ public abstract class BasicSoOperation extends BasicHttpOperation {
org.onap.policy.simulators.Util.buildSoSim();
BusTopicParams clientParams = BusTopicParams.builder().clientName(MY_CLIENT).basePath("").hostname("localhost")
- .managed(true).port(org.onap.policy.simulators.Util.SOSIM_SERVER_PORT)
- .build();
+ .managed(true).port(org.onap.policy.simulators.Util.SOSIM_SERVER_PORT)
+ .build();
HttpClientFactoryInstance.getClientFactory().build(clientParams);
SoSimulatorJaxRs.setRequirePolling(true);
@@ -109,7 +109,7 @@ public abstract class BasicSoOperation extends BasicHttpOperation {
/**
* Initializes mocks and sets up.
*/
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUpBasic();
response = new SoResponse();
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyCllTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyCllTest.java
index f7a59201d..ff1a93b85 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyCllTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyCllTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2022 CTC, Inc. and others. 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.
@@ -24,17 +24,17 @@ package org.onap.policy.controlloop.actor.so;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
@@ -43,35 +43,35 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingCo
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
import org.onap.policy.so.SoResponse;
-@RunWith(MockitoJUnitRunner.class)
-public class ModifyCllTest extends BasicSoOperation {
+@ExtendWith(MockitoExtension.class)
+class ModifyCllTest extends BasicSoOperation {
private ModifyCll oper;
- public ModifyCllTest() {
+ ModifyCllTest() {
super(DEFAULT_ACTOR, ModifyCll.NAME);
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
initBeforeClass();
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
@Override
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUp();
oper = new ModifyCll(params, config);
}
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT)
.path("infra/serviceIntent/v1/modify")
.pollPath("orchestrationRequests/v5/").maxPolls(2).build();
@@ -87,7 +87,7 @@ public class ModifyCllTest extends BasicSoOperation {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(ModifyCll.NAME, oper.getName());
assertFalse(oper.isUsePolling());
@@ -98,7 +98,7 @@ public class ModifyCllTest extends BasicSoOperation {
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.EVENT_PAYLOAD));
}
@@ -110,7 +110,7 @@ public class ModifyCllTest extends BasicSoOperation {
* Tests makeRequest() when a property is missing.
*/
@Test
- public void testMakeRequestMissingProperty() throws Exception {
+ void testMakeRequestMissingProperty() throws Exception {
oper = new ModifyCll(params, config);
assertThatIllegalStateException().isThrownBy(() -> oper.makeRequest())
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyNssiTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyNssiTest.java
index 8a31f2c93..c5c183275 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyNssiTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyNssiTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2020 Wipro Limited.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2020,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.
@@ -25,17 +25,17 @@ package org.onap.policy.controlloop.actor.so;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-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.assertInstanceOf;
import java.util.List;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
@@ -44,35 +44,35 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingCo
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
import org.onap.policy.so.SoResponse;
-@RunWith(MockitoJUnitRunner.class)
-public class ModifyNssiTest extends BasicSoOperation {
+@ExtendWith(MockitoExtension.class)
+class ModifyNssiTest extends BasicSoOperation {
private ModifyNssi oper;
- public ModifyNssiTest() {
+ ModifyNssiTest() {
super(DEFAULT_ACTOR, ModifyNssi.NAME);
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
initBeforeClass();
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
@Override
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUp();
oper = new ModifyNssi(params, config);
}
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT).path("3gppservices/v7/modify")
.pollPath("orchestrationRequests/v5/").maxPolls(2).build();
config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -83,11 +83,11 @@ public class ModifyNssiTest extends BasicSoOperation {
outcome = oper.start().get();
assertEquals(OperationResult.SUCCESS, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof SoResponse);
+ assertInstanceOf(SoResponse.class, outcome.getResponse());
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(ModifyNssi.NAME, oper.getName());
assertFalse(oper.isUsePolling());
@@ -98,7 +98,7 @@ public class ModifyNssiTest extends BasicSoOperation {
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.EVENT_PAYLOAD));
}
@@ -110,7 +110,7 @@ public class ModifyNssiTest extends BasicSoOperation {
* Tests makeRequest() when a property is missing.
*/
@Test
- public void testMakeRequestMissingProperty() throws Exception {
+ void testMakeRequestMissingProperty() throws Exception {
oper = new ModifyNssi(params, config);
assertThatIllegalStateException().isThrownBy(() -> oper.makeRequest())
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/RestManagerResponseTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/RestManagerResponseTest.java
index 2055adbc8..8b5a050b6 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/RestManagerResponseTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/RestManagerResponseTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. 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.
@@ -24,16 +24,16 @@ package org.onap.policy.controlloop.actor.so;
import static org.assertj.core.api.Assertions.assertThatCode;
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import jakarta.ws.rs.core.GenericType;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
-public class RestManagerResponseTest {
+class RestManagerResponseTest {
private static final Coder coder = new StandardCoder();
private static final int MY_STATUS = 200;
@@ -41,23 +41,23 @@ public class RestManagerResponseTest {
private RestManagerResponse resp;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
resp = new RestManagerResponse(MY_STATUS, MY_TEXT, coder);
}
@Test
- public void testGetStatus() {
+ void testGetStatus() {
assertEquals(MY_STATUS, resp.getStatus());
}
@Test
- public void testClose() {
+ void testClose() {
assertThatCode(() -> resp.close()).doesNotThrowAnyException();
}
@Test
- public void testReadEntityClassOfT() {
+ void testReadEntityClassOfT() {
// try with JSON
MyObject obj = resp.readEntity(MyObject.class);
assertNotNull(obj);
@@ -75,7 +75,7 @@ public class RestManagerResponseTest {
@Test
@SuppressWarnings("unchecked")
- public void testUnsupported() {
+ void testUnsupported() {
GenericType<String> generic = GenericType.forInstance(String.class);
assertThatThrownBy(() -> resp.hasEntity()).isInstanceOf(UnsupportedOperationException.class);
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorTest.java
index a06c91817..9cd1bea7a 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2018-2020 AT&T. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2024 Nordix Foundation.
* Modifications Copyright (C) 2020 Wipro Limited.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,29 +23,29 @@
package org.onap.policy.controlloop.actor.so;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.actor.test.BasicActor;
-public class SoActorTest extends BasicActor {
+class SoActorTest extends BasicActor {
@Test
- public void testConstructor() {
+ void testConstructor() {
SoActor prov = new SoActor();
// verify that it has the operators we expect
var expected = Arrays.asList(VfModuleCreate.NAME, VfModuleDelete.NAME, ModifyNssi.NAME, ModifyCll.NAME).stream()
- .sorted().collect(Collectors.toList());
+ .sorted().collect(Collectors.toList());
var actual = prov.getOperationNames().stream().sorted().collect(Collectors.toList());
assertEquals(expected.toString(), actual.toString());
}
@Test
- public void testActorService() {
+ void testActorService() {
// verify that it all plugs into the ActorService
verifyActorService(SoActor.NAME, "service.yaml");
}
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
index a2d392510..fe88a2371 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Wipro Limited.
- * 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.
@@ -24,11 +24,11 @@ package org.onap.policy.controlloop.actor.so;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.lenient;
import java.time.LocalDateTime;
@@ -36,10 +36,10 @@ import java.time.Month;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.Tenant;
import org.onap.policy.common.utils.coder.Coder;
@@ -53,8 +53,8 @@ import org.onap.policy.so.SoRequestInfo;
import org.onap.policy.so.SoRequestStatus;
import org.onap.policy.so.SoResponse;
-@RunWith(MockitoJUnitRunner.class)
-public class SoOperationTest extends BasicSoOperation {
+@ExtendWith(MockitoExtension.class)
+ class SoOperationTest extends BasicSoOperation {
private static final List<String> PROP_NAMES = Collections.emptyList();
@@ -64,8 +64,8 @@ public class SoOperationTest extends BasicSoOperation {
* Sets up.
*/
@Override
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUp();
initConfig();
@@ -74,7 +74,7 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
assertSame(config, oper.getConfig());
@@ -86,7 +86,7 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testValidateTarget() {
+ void testValidateTarget() {
// check when various fields are null
verifyNotNull(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_CUSTOMIZATION_ID, targetEntities);
verifyNotNull(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_INVARIANT_ID, targetEntities);
@@ -108,7 +108,7 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testGetRequestState() {
+ void testGetRequestState() {
SoResponse resp = new SoResponse();
assertNull(oper.getRequestState(resp));
@@ -125,7 +125,7 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testIsSuccess() {
+ void testIsSuccess() {
// always true
assertTrue(oper.isSuccess(rawResponse, response));
@@ -135,7 +135,7 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testSetOutcome() {
+ void testSetOutcome() {
// success case
lenient().when(rawResponse.getStatus()).thenReturn(200);
assertSame(outcome, oper.setOutcome(outcome, OperationResult.SUCCESS, rawResponse, response));
@@ -154,7 +154,7 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testPrepareSoModelInfo() throws CoderException {
+ void testPrepareSoModelInfo() throws CoderException {
// valid data
SoModelInfo info = oper.prepareSoModelInfo();
verifyRequest("model.json", info);
@@ -166,13 +166,13 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testConstructRequestInfo() throws CoderException {
+ void testConstructRequestInfo() throws CoderException {
SoRequestInfo info = oper.constructRequestInfo();
verifyRequest("reqinfo.json", info);
}
@Test
- public void testBuildRequestParameters() throws CoderException {
+ void testBuildRequestParameters() throws CoderException {
// valid data
verifyRequest("reqparams.json", oper.buildRequestParameters().get());
@@ -192,7 +192,7 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testBuildConfigurationParameters() {
+ void testBuildConfigurationParameters() {
// valid data
assertEquals(List.of(Collections.emptyMap()), oper.buildConfigurationParameters().get());
@@ -212,7 +212,7 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testConstructCloudConfiguration() throws Exception {
+ void testConstructCloudConfiguration() throws Exception {
Tenant tenantItem = new Tenant();
tenantItem.setTenantId("my-tenant-id");
@@ -235,7 +235,7 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testGetRequiredText() throws Exception {
+ void testGetRequiredText() throws Exception {
assertThatCode(() -> oper.getRequiredText("some value", "my value")).doesNotThrowAnyException();
@@ -244,7 +244,7 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testGetCoder() throws CoderException {
+ void testGetCoder() throws CoderException {
Coder opcoder = oper.getCoder();
// ensure we can decode an SO timestamp
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
index ad242c0dc..721cb6a6d 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Wipro Limited.
- * 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.
@@ -24,9 +24,10 @@ package org.onap.policy.controlloop.actor.so;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-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.assertInstanceOf;
+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.when;
@@ -35,12 +36,12 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ModelVer;
@@ -56,8 +57,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingPa
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoResponse;
-@RunWith(MockitoJUnitRunner.class)
-public class VfModuleCreateTest extends BasicSoOperation {
+@ExtendWith(MockitoExtension.class)
+class VfModuleCreateTest extends BasicSoOperation {
private static final String MODEL_NAME2 = "my-model-name-B";
@@ -67,26 +68,26 @@ public class VfModuleCreateTest extends BasicSoOperation {
private VfModuleCreate oper;
- public VfModuleCreateTest() {
+ VfModuleCreateTest() {
super(DEFAULT_ACTOR, VfModuleCreate.NAME);
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
initBeforeClass();
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
/**
* Sets up.
*/
- @Before
+ @BeforeEach
@Override
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUp();
oper = new VfModuleCreate(params, config);
loadProperties();
@@ -96,10 +97,10 @@ public class VfModuleCreateTest extends BasicSoOperation {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT)
- .path("serviceInstantiation/v7/serviceInstances").pollPath("orchestrationRequests/v5/")
- .maxPolls(2).build();
+ .path("serviceInstantiation/v7/serviceInstances").pollPath("orchestrationRequests/v5/")
+ .maxPolls(2).build();
config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
@@ -111,14 +112,14 @@ public class VfModuleCreateTest extends BasicSoOperation {
// run the operation
outcome = oper.start().get();
assertEquals(OperationResult.SUCCESS, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof SoResponse);
+ assertInstanceOf(SoResponse.class, outcome.getResponse());
int count = oper.getProperty(OperationProperties.DATA_VF_COUNT);
assertEquals(VF_COUNT + 1, count);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(VfModuleCreate.NAME, oper.getName());
assertTrue(oper.isUsePolling());
@@ -126,26 +127,26 @@ public class VfModuleCreateTest extends BasicSoOperation {
// verify that target validation is done
params = params.toBuilder().targetType(null).build();
assertThatIllegalArgumentException().isThrownBy(() -> new VfModuleCreate(params, config))
- .withMessageContaining("Target information");
+ .withMessageContaining("Target information");
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
// @formatter:off
assertThat(oper.getPropertyNames()).isEqualTo(
- List.of(
- OperationProperties.AAI_SERVICE,
- OperationProperties.AAI_SERVICE_MODEL,
- OperationProperties.AAI_VNF,
- OperationProperties.AAI_VNF_MODEL,
- OperationProperties.AAI_DEFAULT_CLOUD_REGION,
- OperationProperties.AAI_DEFAULT_TENANT,
- OperationProperties.DATA_VF_COUNT));
+ List.of(
+ OperationProperties.AAI_SERVICE,
+ OperationProperties.AAI_SERVICE_MODEL,
+ OperationProperties.AAI_VNF,
+ OperationProperties.AAI_VNF_MODEL,
+ OperationProperties.AAI_DEFAULT_CLOUD_REGION,
+ OperationProperties.AAI_DEFAULT_TENANT,
+ OperationProperties.DATA_VF_COUNT));
// @formatter:on
}
@Test
- public void testStartOperationAsync_testSuccessfulCompletion() throws Exception {
+ void testStartOperationAsync_testSuccessfulCompletion() throws Exception {
when(client.post(any(), any(), any(), any())).thenAnswer(provideResponse(rawResponse));
// use a real executor
@@ -179,7 +180,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
* Tests startOperationAsync() when polling is required.
*/
@Test
- public void testStartOperationAsyncWithPolling() throws Exception {
+ void testStartOperationAsyncWithPolling() throws Exception {
when(rawResponse.getStatus()).thenReturn(500, 500, 500, 500, 200, 200);
when(client.post(any(), any(), any(), any())).thenAnswer(provideResponse(rawResponse));
@@ -204,7 +205,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
}
@Test
- public void testMakeRequest() throws CoderException {
+ void testMakeRequest() throws CoderException {
Pair<String, SoRequest> pair = oper.makeRequest();
// @formatter:off
@@ -220,14 +221,14 @@ public class VfModuleCreateTest extends BasicSoOperation {
* Tests makeRequest() when a property is missing.
*/
@Test
- public void testMakeRequestMissingProperty() throws Exception {
+ void testMakeRequestMissingProperty() throws Exception {
loadProperties();
ServiceInstance instance = new ServiceInstance();
oper.setProperty(OperationProperties.AAI_SERVICE, instance);
assertThatIllegalArgumentException().isThrownBy(() -> oper.makeRequest())
- .withMessageContaining("missing service instance ID");
+ .withMessageContaining("missing service instance ID");
}
private void loadProperties() {
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
index 10f3f2bed..5ece1968d 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Wipro Limited.
- * 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.
@@ -24,10 +24,11 @@ package org.onap.policy.controlloop.actor.so;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
@@ -50,14 +51,14 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ServiceInstance;
@@ -73,8 +74,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingPa
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoResponse;
-@RunWith(MockitoJUnitRunner.class)
-public class VfModuleDeleteTest extends BasicSoOperation {
+@ExtendWith(MockitoExtension.class)
+class VfModuleDeleteTest extends BasicSoOperation {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String SVC_INSTANCE_ID = "my-service-instance-id";
private static final String VNF_ID = "my-vnf-id";
@@ -89,17 +90,17 @@ public class VfModuleDeleteTest extends BasicSoOperation {
private CompletableFuture<HttpResponse<String>> javaFuture;
private VfModuleDelete oper;
- public VfModuleDeleteTest() {
+ VfModuleDeleteTest() {
super(DEFAULT_ACTOR, VfModuleDelete.NAME);
}
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
initBeforeClass();
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
@@ -107,8 +108,8 @@ public class VfModuleDeleteTest extends BasicSoOperation {
* Sets up.
*/
@Override
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUp();
initHostPort();
@@ -124,9 +125,9 @@ public class VfModuleDeleteTest extends BasicSoOperation {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT).path("serviceInstances/v7")
- .pollPath("orchestrationRequests/v5/").maxPolls(2).build();
+ .pollPath("orchestrationRequests/v5/").maxPolls(2).build();
config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
@@ -138,14 +139,14 @@ public class VfModuleDeleteTest extends BasicSoOperation {
// run the operation
outcome = oper.start().get();
assertEquals(OperationResult.SUCCESS, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof SoResponse);
+ assertInstanceOf(SoResponse.class, outcome.getResponse());
int count = oper.getProperty(OperationProperties.DATA_VF_COUNT);
assertEquals(VF_COUNT - 1, count);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(VfModuleDelete.NAME, oper.getName());
assertTrue(oper.isUsePolling());
@@ -153,24 +154,24 @@ public class VfModuleDeleteTest extends BasicSoOperation {
// verify that target validation is done
params = params.toBuilder().targetType(null).build();
assertThatIllegalArgumentException().isThrownBy(() -> new MyOperation(params, config))
- .withMessageContaining("Target information");
+ .withMessageContaining("Target information");
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
// @formatter:off
assertThat(oper.getPropertyNames()).isEqualTo(
- List.of(
- OperationProperties.AAI_SERVICE,
- OperationProperties.AAI_VNF,
- OperationProperties.AAI_DEFAULT_CLOUD_REGION,
- OperationProperties.AAI_DEFAULT_TENANT,
- OperationProperties.DATA_VF_COUNT));
+ List.of(
+ OperationProperties.AAI_SERVICE,
+ OperationProperties.AAI_VNF,
+ OperationProperties.AAI_DEFAULT_CLOUD_REGION,
+ OperationProperties.AAI_DEFAULT_TENANT,
+ OperationProperties.DATA_VF_COUNT));
// @formatter:on
}
@Test
- public void testStartOperationAsync_testSuccessfulCompletion() throws Exception {
+ void testStartOperationAsync_testSuccessfulCompletion() throws Exception {
// use a real executor
params = params.toBuilder().executor(ForkJoinPool.commonPool()).build();
@@ -202,7 +203,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
* Tests startOperationAsync() when polling is required.
*/
@Test
- public void testStartOperationAsyncWithPolling() throws Exception {
+ void testStartOperationAsyncWithPolling() throws Exception {
// indicate that the response was incomplete
configureResponse(coder.encode(response).replace("COMPLETE", "incomplete"));
@@ -229,7 +230,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
}
@Test
- public void testMakeRequest() throws CoderException {
+ void testMakeRequest() throws CoderException {
Pair<String, SoRequest> pair = oper.makeRequest();
assertEquals("/my-service-instance-id/vnfs/my-vnf-id/vfModules/null", pair.getLeft());
@@ -238,7 +239,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
}
@Test
- public void testDelete() throws Exception {
+ void testDelete() throws Exception {
SoRequest req = new SoRequest();
req.setRequestId(REQ_ID);
@@ -247,7 +248,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
String reqText = oper.prettyPrint(req);
final CompletableFuture<Response> delFuture =
- oper.delete("my-uri", headers, MediaType.APPLICATION_JSON, reqText, callback);
+ oper.delete("my-uri", headers, MediaType.APPLICATION_JSON, reqText, callback);
ArgumentCaptor<HttpRequest> reqCaptor = ArgumentCaptor.forClass(HttpRequest.class);
verify(javaClient).sendAsync(reqCaptor.capture(), any());
@@ -276,7 +277,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
*/
@Test
@SuppressWarnings("unchecked")
- public void testDeleteException() throws Exception {
+ void testDeleteException() throws Exception {
Throwable thrown = new IllegalStateException(EXPECTED_EXCEPTION);
// need a new future, with an exception
@@ -289,7 +290,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
String reqText = oper.prettyPrint(req);
CompletableFuture<Response> delFuture =
- oper.delete("/my-uri", Map.of(), MediaType.APPLICATION_JSON, reqText, callback);
+ oper.delete("/my-uri", Map.of(), MediaType.APPLICATION_JSON, reqText, callback);
assertTrue(delFuture.isCompletedExceptionally());
@@ -302,7 +303,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
* Tests addAuthHeader() when there is a username, but no password.
*/
@Test
- public void testAddAuthHeader() {
+ void testAddAuthHeader() {
Builder builder = mock(Builder.class);
lenient().when(client.getUserName()).thenReturn("the-user");
lenient().when(client.getPassword()).thenReturn("the-password");
@@ -323,7 +324,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
* Tests addAuthHeader() when there is no username.
*/
@Test
- public void testAddAuthHeaderNoUser() {
+ void testAddAuthHeaderNoUser() {
Builder builder = mock(Builder.class);
lenient().when(client.getPassword()).thenReturn("world");
oper.addAuthHeader(builder);
@@ -339,7 +340,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
* Tests addAuthHeader() when there is a username, but no password.
*/
@Test
- public void testAddAuthHeaderUserOnly() {
+ void testAddAuthHeaderUserOnly() {
Builder builder = mock(Builder.class);
lenient().when(client.getUserName()).thenReturn("my-user");
oper.addAuthHeader(builder);
@@ -359,18 +360,18 @@ public class VfModuleDeleteTest extends BasicSoOperation {
* Tests makeRequest() when a property is missing.
*/
@Test
- public void testMakeRequestMissingProperty() throws Exception {
+ void testMakeRequestMissingProperty() throws Exception {
loadProperties();
ServiceInstance instance = new ServiceInstance();
oper.setProperty(OperationProperties.AAI_SERVICE, instance);
assertThatIllegalArgumentException().isThrownBy(() -> oper.makeRequest())
- .withMessageContaining("missing service instance ID");
+ .withMessageContaining("missing service instance ID");
}
@Test
- public void testMakeHttpClient() {
+ void testMakeHttpClient() {
// must use a real operation to invoke this method
assertNotNull(new MyOperation(params, config).makeHttpClient());
}
@@ -391,7 +392,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
private class MyOperation extends VfModuleDelete {
- public MyOperation(ControlLoopOperationParams params, HttpPollingConfig config) {
+ MyOperation(ControlLoopOperationParams params, HttpPollingConfig config) {
super(params, config);
}
diff --git a/models-interactions/model-actors/actor.test/pom.xml b/models-interactions/model-actors/actor.test/pom.xml
index 4cc73b18f..ff1030ce5 100644
--- a/models-interactions/model-actors/actor.test/pom.xml
+++ b/models-interactions/model-actors/actor.test/pom.xml
@@ -55,11 +55,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.onap.policy.models.policy-models-interactions</groupId>
<artifactId>simulators</artifactId>
<version>${project.version}</version>
@@ -74,6 +69,15 @@
<artifactId>mockito-core</artifactId>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicActor.java b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicActor.java
index 8d7291051..cce4da420 100644
--- a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicActor.java
+++ b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicActor.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,9 +21,9 @@
package org.onap.policy.controlloop.actor.test;
-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.FileNotFoundException;
import java.util.Map;
diff --git a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java
index 22332ae86..3f339d011 100644
--- a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java
+++ b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperation.java
@@ -21,8 +21,8 @@
package org.onap.policy.controlloop.actor.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.lenient;
import java.util.List;
diff --git a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java
index b037189b0..48ee9dcfc 100644
--- a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java
+++ b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java
@@ -21,7 +21,7 @@
package org.onap.policy.controlloop.actor.test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import jakarta.ws.rs.core.Response;
import java.util.Map;
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java
index 65ab0bbb3..1cd3827ab 100644
--- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.java
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicActorTest.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.
@@ -24,12 +25,12 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.io.FileNotFoundException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class BasicActorTest extends BasicActor {
+class BasicActorTest extends BasicActor {
@Test
- public void testVerifyActorService_testStartOtherServices_testStopOtherServices() {
+ void testVerifyActorService_testStartOtherServices_testStopOtherServices() {
// mostly empty service
verifyActorService(DummyActor.NAME, "service.yaml");
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java
index ebfc267cc..c795f9cc5 100644
--- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicBidirectionalTopicOperationTest.java
@@ -22,70 +22,72 @@
package org.onap.policy.controlloop.actor.test;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import java.util.function.BiConsumer;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
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.StandardCoderObject;
import org.onap.policy.simulators.TopicServer;
-@RunWith(MockitoJUnitRunner.class)
-public class BasicBidirectionalTopicOperationTest {
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@ExtendWith(MockitoExtension.class)
+class BasicBidirectionalTopicOperationTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-operation";
@Mock
private BiConsumer<String, StandardCoderObject> listener;
- private BasicBidirectionalTopicOperation<String> oper;
+ private BasicBidirectionalTopicOperation<String> oper = new MyOperation(ACTOR, OPERATION);
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ void setUpBeforeClass() throws Exception {
BasicBidirectionalTopicOperation.initBeforeClass(BasicBidirectionalTopicOperation.MY_SINK,
BasicBidirectionalTopicOperation.MY_SOURCE);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
BasicBidirectionalTopicOperation.destroyAfterClass();
}
/**
* Sets up.
*/
- @Before
- public void setUp() throws Exception {
- oper = new MyOperation(ACTOR, OPERATION);
+ @BeforeEach
+ void setUp() throws Exception {
oper.setUpBasic();
}
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
oper.tearDownBasic();
}
@Test
- public void testTopicMgr() {
+ void testTopicMgr() {
assertNotNull(BasicBidirectionalTopicOperation.topicMgr.getTopicHandler(
BasicBidirectionalTopicOperation.MY_SINK, BasicBidirectionalTopicOperation.MY_SOURCE));
}
@Test
- public void testBasicBidirectionalTopicOperation() {
+ void testBasicBidirectionalTopicOperation() {
oper.tearDownBasic();
oper = new MyOperation();
@@ -96,20 +98,14 @@ public class BasicBidirectionalTopicOperationTest {
}
@Test
- public void testBasicBidirectionalTopicOperationStringString() {
- assertEquals(ACTOR, oper.actorName);
- assertEquals(OPERATION, oper.operationName);
- }
-
- @Test
- public void testSetUp() {
+ void testSetUp() {
assertNotNull(oper.config);
assertNotNull(oper.outcome);
assertNotNull(oper.executor);
}
@Test
- public void testInitOperator() {
+ void testInitOperator() {
oper.initConfig();
assertSame(oper.topicHandler, oper.config.getTopicHandler());
@@ -118,7 +114,7 @@ public class BasicBidirectionalTopicOperationTest {
}
@Test
- public void testProvideResponse() {
+ void testProvideResponse() {
String response = "{\"input\": 10}";
oper.provideResponse(listener, response);
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java
index 2f16c4226..58392b96e 100644
--- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicHttpOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. 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.
@@ -21,48 +21,48 @@
package org.onap.policy.controlloop.actor.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import jakarta.ws.rs.client.InvocationCallback;
import jakarta.ws.rs.core.Response;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
-public class BasicHttpOperationTest {
+@ExtendWith(MockitoExtension.class)
+class BasicHttpOperationTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-operation";
private BasicHttpOperation oper;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
oper = new BasicHttpOperation(ACTOR, OPERATION);
oper.setUpBasic();
}
@Test
- public void testBasicHttpOperation() {
+ void testBasicHttpOperation() {
oper = new BasicHttpOperation();
assertEquals(BasicOperation.DEFAULT_ACTOR, oper.actorName);
assertEquals(BasicOperation.DEFAULT_OPERATION, oper.operationName);
}
@Test
- public void testBasicHttpOperationStringString() {
+ void testBasicHttpOperationStringString() {
assertEquals(ACTOR, oper.actorName);
assertEquals(OPERATION, oper.operationName);
}
@Test
- public void testSetUp() throws Exception {
+ void testSetUp() throws Exception {
assertNotNull(oper.client);
assertSame(oper.client, oper.factory.get(BasicHttpOperation.MY_CLIENT));
assertEquals(200, oper.rawResponse.getStatus());
@@ -73,7 +73,7 @@ public class BasicHttpOperationTest {
}
@Test
- public void testInitOperator() throws Exception {
+ void testInitOperator() throws Exception {
oper.initConfig();
assertSame(oper.client, oper.config.getClient());
@@ -81,7 +81,7 @@ public class BasicHttpOperationTest {
}
@Test
- public void testProvideResponse() throws Exception {
+ void testProvideResponse() throws Exception {
InvocationCallback<Response> cb = new InvocationCallback<>() {
@Override
public void completed(Response response) {
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java
index 34d0d122d..9ce1b214e 100644
--- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. 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.
@@ -21,56 +21,58 @@
package org.onap.policy.controlloop.actor.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
+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;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-@RunWith(MockitoJUnitRunner.class)
-public class BasicOperationTest {
+@ExtendWith(MockitoExtension.class)
+ class BasicOperationTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-operation";
private BasicOperation oper;
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
oper = new BasicHttpOperation(ACTOR, OPERATION);
oper.setUpBasic();
}
@Test
- public void testBasicHttpOperation() {
+ void testBasicHttpOperation() {
oper = new BasicHttpOperation();
assertEquals(BasicHttpOperation.DEFAULT_ACTOR, oper.actorName);
assertEquals(BasicHttpOperation.DEFAULT_OPERATION, oper.operationName);
}
@Test
- public void testBasicHttpOperationStringString() {
+ void testBasicHttpOperationStringString() {
assertEquals(ACTOR, oper.actorName);
assertEquals(OPERATION, oper.operationName);
}
@Test
- public void testSetUp() throws Exception {
+ void testSetUp() throws Exception {
assertNotNull(oper.future);
assertNotNull(oper.outcome);
assertNotNull(oper.executor);
}
@Test
- public void testMakeContext() {
+ void testMakeContext() {
oper.makeContext();
assertSame(oper.service, oper.params.getActorService());
@@ -81,12 +83,12 @@ public class BasicOperationTest {
}
@Test
- public void testMakePayload() {
+ void testMakePayload() {
assertNull(oper.makePayload());
}
@Test
- public void testVerifyRequest() throws CoderException {
+ void testVerifyRequest() throws CoderException {
Map<String, Object> map = Util.translateToMap("", ResourceUtils.getResourceAsString("actual.json"));
oper.verifyRequest("expected.json", map, "svc-request-id", "vnf-id");
}
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/DummyActor.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/DummyActor.java
index c862a18b7..1590ac314 100644
--- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/DummyActor.java
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/DummyActor.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.
@@ -23,9 +24,9 @@ package org.onap.policy.controlloop.actor.test;
import org.onap.policy.controlloop.actorserviceprovider.impl.ActorImpl;
public class DummyActor extends ActorImpl {
- public static final String NAME = "MyActor";
- public static final String MY_OPERATION1 = "MyOperationA";
- public static final String MY_OPERATION2 = "MyOperationB";
+ static final String NAME = "MyActor";
+ static final String MY_OPERATION1 = "MyOperationA";
+ static final String MY_OPERATION2 = "MyOperationB";
/**
* Constructs the object.
diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/DummyOperator.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/DummyOperator.java
index efd3b6500..6cb43627c 100644
--- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/DummyOperator.java
+++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/DummyOperator.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.
@@ -24,7 +25,7 @@ import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.impl.OperatorPartial;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-public class DummyOperator extends OperatorPartial {
+class DummyOperator extends OperatorPartial {
public DummyOperator(String actorName, String name) {
super(actorName, name);
diff --git a/models-interactions/model-actors/actor.vfc/pom.xml b/models-interactions/model-actors/actor.vfc/pom.xml
index 84eb7c553..1644aab47 100644
--- a/models-interactions/model-actors/actor.vfc/pom.xml
+++ b/models-interactions/model-actors/actor.vfc/pom.xml
@@ -85,10 +85,5 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java
index d83fd8ba8..945acabd6 100644
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java
+++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. 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.
@@ -32,10 +32,10 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingCo
import org.onap.policy.simulators.Util;
import org.onap.policy.vfc.VfcResponse;
-public abstract class BasicVfcOperation extends BasicHttpOperation {
- public static final String POLL_PATH = "my-path-get/";
- public static final int MAX_POLLS = 3;
- public static final int POLL_WAIT_SEC = 20;
+abstract class BasicVfcOperation extends BasicHttpOperation {
+ static final String POLL_PATH = "my-path-get/";
+ static final int MAX_POLLS = 3;
+ static final int POLL_WAIT_SEC = 20;
@Mock
protected HttpPollingConfig config;
@@ -45,7 +45,7 @@ public abstract class BasicVfcOperation extends BasicHttpOperation {
/**
* Constructs the object using a default actor and operation name.
*/
- public BasicVfcOperation() {
+ BasicVfcOperation() {
super();
}
@@ -55,7 +55,7 @@ public abstract class BasicVfcOperation extends BasicHttpOperation {
* @param actor actor name
* @param operation operation name
*/
- public BasicVfcOperation(String actor, String operation) {
+ BasicVfcOperation(String actor, String operation) {
super(actor, operation);
}
@@ -66,7 +66,7 @@ public abstract class BasicVfcOperation extends BasicHttpOperation {
Util.buildVfcSim();
BusTopicParams clientParams = BusTopicParams.builder().clientName(MY_CLIENT).basePath("api/nslcm/v1/")
- .hostname("localhost").managed(true).port(Util.VFCSIM_SERVER_PORT).build();
+ .hostname("localhost").managed(true).port(Util.VFCSIM_SERVER_PORT).build();
HttpClientFactoryInstance.getClientFactory().build(clientParams);
}
@@ -78,7 +78,7 @@ public abstract class BasicVfcOperation extends BasicHttpOperation {
/**
* Initializes mocks and sets up.
*/
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUpBasic();
response = new VfcResponse();
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java
index ca7cefd93..4474693cc 100644
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java
+++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. 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,19 +22,19 @@
package org.onap.policy.controlloop.actor.vfc;
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
@@ -44,8 +44,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingPa
import org.onap.policy.vfc.VfcRequest;
import org.onap.policy.vfc.VfcResponse;
-@RunWith(MockitoJUnitRunner.class)
-public class RestartTest extends BasicVfcOperation {
+@ExtendWith(MockitoExtension.class)
+ class RestartTest extends BasicVfcOperation {
private static final String TEST_SERVICE_INSTANCE_ID = "test-service-instance-id";
private static final String TEST_VSERVER_ID = "test-vserver-id";
private static final String TEST_VSERVER_NAME = "test-vserver-name";
@@ -54,21 +54,21 @@ public class RestartTest extends BasicVfcOperation {
private Restart restartOper;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
initBeforeClass();
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
destroyAfterClass();
}
/**
* setup restart operation.
*/
- @Before
- public void setup() throws Exception {
+ @BeforeEach
+ void setup() throws Exception {
super.setUp();
restartOper = new Restart(params, config);
@@ -80,7 +80,7 @@ public class RestartTest extends BasicVfcOperation {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT).path("ns").pollPath("jobs")
.maxPolls(1).build();
config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -98,14 +98,14 @@ public class RestartTest extends BasicVfcOperation {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
CompletableFuture<OperationOutcome> futureRes = restartOper.startOperationAsync(1, outcome);
assertNotNull(futureRes);
assertEquals(0, restartOper.getPollCount());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
// @formatter:off
assertThat(restartOper.getPropertyNames()).isEqualTo(
List.of(
@@ -117,7 +117,7 @@ public class RestartTest extends BasicVfcOperation {
}
@Test
- public void testMakeRequest() {
+ void testMakeRequest() {
Pair<String, VfcRequest> resultPair = restartOper.makeRequest();
assertNotNull(resultPair.getLeft());
assertNotNull(resultPair.getRight());
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorTest.java
index 08ce8e194..88176a283 100644
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorTest.java
+++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorTest.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2018-2019 AT&T Corp. 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.
@@ -22,17 +22,17 @@
package org.onap.policy.controlloop.actor.vfc;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.actor.test.BasicActor;
-public class VfcActorTest extends BasicActor {
+class VfcActorTest extends BasicActor {
@Test
- public void testConstructor() {
+ void testConstructor() {
VfcActor prov = new VfcActor();
assertEquals(0, prov.getSequenceNumber());
@@ -44,7 +44,7 @@ public class VfcActorTest extends BasicActor {
}
@Test
- public void testActorService() {
+ void testActorService() {
// verify that it all plugs into the ActorService
verifyActorService(VfcActor.NAME, "service.yaml");
}
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java
index aee9b323e..920e79984 100644
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java
+++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. 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.
@@ -21,31 +21,31 @@
package org.onap.policy.controlloop.actor.vfc;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-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.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.vfc.VfcResponse;
import org.onap.policy.vfc.VfcResponseDescriptor;
-@RunWith(MockitoJUnitRunner.class)
-public class VfcOperationTest extends BasicVfcOperation {
+@ExtendWith(MockitoExtension.class)
+ class VfcOperationTest extends BasicVfcOperation {
private VfcOperation oper;
/**
* setUp.
*/
- @Before
+ @BeforeEach
@Override
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUp();
initConfig();
@@ -54,7 +54,7 @@ public class VfcOperationTest extends BasicVfcOperation {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
assertSame(config, oper.getConfig());
@@ -62,13 +62,13 @@ public class VfcOperationTest extends BasicVfcOperation {
}
@Test
- public void testResetPollCount() {
+ void testResetPollCount() {
oper.resetPollCount();
assertEquals(0, oper.getPollCount());
}
@Test
- public void testGetRequestState() {
+ void testGetRequestState() {
VfcResponse mockResponse = Mockito.mock(VfcResponse.class);
Mockito.when(mockResponse.getResponseDescriptor()).thenReturn(null);
assertNull(oper.getRequestState(mockResponse));
@@ -82,7 +82,7 @@ public class VfcOperationTest extends BasicVfcOperation {
}
@Test
- public void testIsSuccess() {
+ void testIsSuccess() {
assertTrue(oper.isSuccess(rawResponse, response));
}
}
diff --git a/models-interactions/model-actors/actor.xacml/pom.xml b/models-interactions/model-actors/actor.xacml/pom.xml
index 1b95fbcab..27d5627ad 100644
--- a/models-interactions/model-actors/actor.xacml/pom.xml
+++ b/models-interactions/model-actors/actor.xacml/pom.xml
@@ -70,10 +70,5 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>compile</scope>
- </dependency>
</dependencies>
</project>
diff --git a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/ConfigureOperationTest.java b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/ConfigureOperationTest.java
index 9559a1d47..3dba20162 100644
--- a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/ConfigureOperationTest.java
+++ b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/ConfigureOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2021 AT&T Intellectual Property. 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,21 +22,21 @@
package org.onap.policy.controlloop.actor.xacml;
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import java.util.Map;
import java.util.function.Consumer;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
@@ -46,8 +46,8 @@ import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
-@RunWith(MockitoJUnitRunner.class)
-public class ConfigureOperationTest extends BasicHttpOperation {
+@ExtendWith(MockitoExtension.class)
+ class ConfigureOperationTest extends BasicHttpOperation {
@Mock
private Consumer<OperationOutcome> started;
@@ -60,8 +60,8 @@ public class ConfigureOperationTest extends BasicHttpOperation {
/**
* Starts the simulator.
*/
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
org.onap.policy.simulators.Util.buildXacmlSim();
BusTopicParams clientParams = BusTopicParams.builder().clientName(MY_CLIENT).basePath("policy/pdpx/v1/")
@@ -70,8 +70,8 @@ public class ConfigureOperationTest extends BasicHttpOperation {
HttpClientFactoryInstance.getClientFactory().build(clientParams);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
HttpClientFactoryInstance.getClientFactory().destroy();
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@@ -79,8 +79,8 @@ public class ConfigureOperationTest extends BasicHttpOperation {
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
super.setUpBasic();
operConfig = mock(DecisionConfig.class);
@@ -102,7 +102,7 @@ public class ConfigureOperationTest extends BasicHttpOperation {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
}
@@ -111,7 +111,7 @@ public class ConfigureOperationTest extends BasicHttpOperation {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
DecisionParams opParams =
DecisionParams.builder().clientName(MY_CLIENT).path("decision").action("configure").build();
config = new DecisionConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -124,7 +124,7 @@ public class ConfigureOperationTest extends BasicHttpOperation {
assertEquals(OperationResult.SUCCESS, outcome.getResult());
DecisionResponse response = outcome.getResponse();
- assertTrue(response instanceof DecisionResponse);
+ assertInstanceOf(DecisionResponse.class, response);
assertNotNull(response.getPolicies());
assertThat(response.getPolicies()).containsKey("test-policy");
}
@@ -133,7 +133,7 @@ public class ConfigureOperationTest extends BasicHttpOperation {
* Tests "failure" case with simulator.
*/
@Test
- public void testFailure() throws Exception {
+ void testFailure() throws Exception {
DecisionParams opParams =
DecisionParams.builder().clientName(MY_CLIENT).path("decision").action("configure").build();
config = new DecisionConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -146,7 +146,7 @@ public class ConfigureOperationTest extends BasicHttpOperation {
assertEquals(OperationResult.FAILURE, outcome.getResult());
DecisionResponse response = outcome.getResponse();
- assertTrue(response instanceof DecisionResponse);
+ assertInstanceOf(DecisionResponse.class, response);
assertNotNull(response.getPolicies());
assertThat(response.getPolicies()).isEmpty();
}
diff --git a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionConfigTest.java b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionConfigTest.java
index dbb4f6857..526840d46 100644
--- a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionConfigTest.java
+++ b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionConfigTest.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,24 +21,24 @@
package org.onap.policy.controlloop.actor.xacml;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
import java.util.concurrent.Executor;
-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.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
-@RunWith(MockitoJUnitRunner.class)
-public class DecisionConfigTest {
+@ExtendWith(MockitoExtension.class)
+ class DecisionConfigTest {
private static final String MY_CLIENT = "my-client";
private static final String PATH = "my-path";
private static final int TIMEOUT = 10;
@@ -59,8 +60,8 @@ public class DecisionConfigTest {
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
when(factory.get(MY_CLIENT)).thenReturn(client);
params = DecisionParams.builder().onapName(ONAP_NAME).onapComponent(ONAP_COMP).onapInstance(ONAP_INST)
@@ -69,7 +70,7 @@ public class DecisionConfigTest {
}
@Test
- public void test() {
+ void test() {
DecisionRequest expected = new DecisionRequest();
expected.setOnapComponent(ONAP_COMP);
expected.setOnapInstance(ONAP_INST);
diff --git a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionOperationTest.java b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionOperationTest.java
index 49dbd166f..ee9d28c57 100644
--- a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionOperationTest.java
+++ b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. 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,11 +22,12 @@
package org.onap.policy.controlloop.actor.xacml;
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.assertNotNull;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+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.never;
@@ -37,13 +38,14 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
@@ -57,8 +59,8 @@ import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
import org.onap.policy.simulators.XacmlSimulatorJaxRs;
-@RunWith(MockitoJUnitRunner.class)
-public class DecisionOperationTest extends BasicHttpOperation {
+@ExtendWith(MockitoExtension.class)
+ class DecisionOperationTest extends BasicHttpOperation {
private static final List<String> PROPERTY_NAMES = List.of("prop-A", "prop-B");
@Mock
@@ -72,8 +74,8 @@ public class DecisionOperationTest extends BasicHttpOperation {
/**
* Starts the simulator.
*/
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
org.onap.policy.simulators.Util.buildXacmlSim();
BusTopicParams clientParams = BusTopicParams.builder().clientName(MY_CLIENT).basePath("policy/pdpx/v1/")
@@ -82,8 +84,8 @@ public class DecisionOperationTest extends BasicHttpOperation {
HttpClientFactoryInstance.getClientFactory().build(clientParams);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
HttpClientFactoryInstance.getClientFactory().destroy();
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@@ -91,12 +93,12 @@ public class DecisionOperationTest extends BasicHttpOperation {
/**
* Sets up.
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUpBasic();
guardConfig = mock(DecisionConfig.class);
- when(guardConfig.makeRequest()).thenAnswer(args -> {
+ Mockito.lenient().when(guardConfig.makeRequest()).thenAnswer(args -> {
DecisionRequest req = new DecisionRequest();
req.setAction("guard");
req.setOnapComponent("my-onap-component");
@@ -117,7 +119,7 @@ public class DecisionOperationTest extends BasicHttpOperation {
* Tests with simulator.
*/
@Test
- public void testSimulator() throws Exception {
+ void testSimulator() throws Exception {
DecisionParams opParams = DecisionParams.builder().clientName(MY_CLIENT).path("decision").build();
config = new DecisionConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -127,22 +129,22 @@ public class DecisionOperationTest extends BasicHttpOperation {
outcome = oper.start().get();
assertEquals(OperationResult.FAILURE, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof DecisionResponse);
+ assertInstanceOf(DecisionResponse.class, outcome.getResponse());
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(PROPERTY_NAMES);
}
@Test
- public void testStartOperationAsync() throws Exception {
+ void testStartOperationAsync() throws Exception {
CompletableFuture<OperationOutcome> future2 = oper.start();
executor.runAll(100);
assertFalse(future2.isDone());
@@ -169,7 +171,7 @@ public class DecisionOperationTest extends BasicHttpOperation {
* Tests startOperationAsync() when the guard is disabled.
*/
@Test
- public void testStartOperationAsyncDisabled() throws Exception {
+ void testStartOperationAsyncDisabled() throws Exception {
// indicate that it's disabled
when(guardConfig.isDisabled()).thenReturn(true);
@@ -192,7 +194,7 @@ public class DecisionOperationTest extends BasicHttpOperation {
private class MyOper extends DecisionOperation {
- public MyOper(ControlLoopOperationParams params, HttpConfig config) {
+ MyOper(ControlLoopOperationParams params, HttpConfig config) {
super(params, config, PROPERTY_NAMES);
}
diff --git a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionOperatorTest.java b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionOperatorTest.java
index ab8535ae4..31308f7f9 100644
--- a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionOperatorTest.java
+++ b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionOperatorTest.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,24 @@
package org.onap.policy.controlloop.actor.xacml;
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.assertInstanceOf;
import static org.mockito.Mockito.when;
import java.util.Map;
-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.InjectMocks;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-@RunWith(MockitoJUnitRunner.class)
-public class DecisionOperatorTest {
+@ExtendWith(MockitoExtension.class)
+ class DecisionOperatorTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-name";
private static final String CLIENT = "my-client";
@@ -54,15 +56,15 @@ public class DecisionOperatorTest {
@Mock
private HttpClientFactory factory;
-
+ @InjectMocks
private DecisionOperator oper;
/**
* Initializes fields, including {@link #oper}, and resets the static fields used by
* the REST server.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
when(factory.get(CLIENT)).thenReturn(client);
oper = new MyOperator();
@@ -73,19 +75,19 @@ public class DecisionOperatorTest {
Map<String, Object> paramMap = Util.translateToMap(OPERATION, params);
oper.configure(paramMap);
- assertTrue(oper.makeConfiguration(paramMap) instanceof DecisionConfig);
+ assertInstanceOf(DecisionConfig.class, oper.makeConfiguration(paramMap));
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(ACTOR, oper.getActorName());
assertEquals(OPERATION, oper.getName());
assertEquals(ACTOR + "." + OPERATION, oper.getFullName());
}
@Test
- public void testDoConfigure_testGetters() {
- assertTrue(oper.getCurrentConfig() instanceof DecisionConfig);
+ void testDoConfigure_testGetters() {
+ assertInstanceOf(DecisionConfig.class, oper.getCurrentConfig());
// test invalid parameters
Map<String, Object> paramMap2 = Util.translateToMap(OPERATION, DecisionParams.builder().build());
@@ -94,7 +96,7 @@ public class DecisionOperatorTest {
private class MyOperator extends DecisionOperator {
- public MyOperator() {
+ MyOperator() {
super(ACTOR, OPERATION, null);
}
diff --git a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionParamsTest.java b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionParamsTest.java
index 658ae4f2e..141e86f08 100644
--- a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionParamsTest.java
+++ b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/DecisionParamsTest.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,18 +22,18 @@
package org.onap.policy.controlloop.actor.xacml;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.function.Function;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.controlloop.actor.xacml.DecisionParams.DecisionParamsBuilder;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams.HttpParamsBuilder;
-public class DecisionParamsTest {
+class DecisionParamsTest {
private static final String CONTAINER = "my-container";
private static final String CLIENT = "my-client";
private static final String PATH = "my-path";
@@ -44,20 +45,20 @@ public class DecisionParamsTest {
private DecisionParams params;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
params = DecisionParams.builder().onapName(ONAP_NAME).onapComponent(ONAP_COMP).onapInstance(ONAP_INST)
.action(MY_ACTION).clientName(CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
}
@Test
- public void testIsDisabled() {
+ void testIsDisabled() {
// disabled by default
assertFalse(params.isDisabled());
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
testValidateField("onapName", "null", bldr -> bldr.onapName(null));
@@ -70,7 +71,7 @@ public class DecisionParamsTest {
}
@Test
- public void testBuilder_testToBuilder() {
+ void testBuilder_testToBuilder() {
assertEquals(CLIENT, params.getClientName());
assertEquals(ONAP_NAME, params.getOnapName());
@@ -86,11 +87,11 @@ public class DecisionParamsTest {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
+ assertTrue(result.isValid(), fieldName);
// make invalid params
result = makeInvalid.apply(params.toBuilder()).build().validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
+ assertFalse(result.isValid(), fieldName);
assertThat(result.getResult()).contains(fieldName).contains(expected);
}
}
diff --git a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/GuardOperationTest.java b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/GuardOperationTest.java
index 05f64baa7..a4187b523 100644
--- a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/GuardOperationTest.java
+++ b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/GuardOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. 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.
@@ -23,23 +23,24 @@ package org.onap.policy.controlloop.actor.xacml;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Consumer;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
@@ -51,8 +52,8 @@ import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
import org.onap.policy.simulators.XacmlSimulatorJaxRs;
-@RunWith(MockitoJUnitRunner.class)
-public class GuardOperationTest extends BasicHttpOperation {
+@ExtendWith(MockitoExtension.class)
+ class GuardOperationTest extends BasicHttpOperation {
@Mock
private Consumer<OperationOutcome> started;
@@ -65,8 +66,8 @@ public class GuardOperationTest extends BasicHttpOperation {
/**
* Starts the simulator.
*/
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
org.onap.policy.simulators.Util.buildXacmlSim();
BusTopicParams clientParams = BusTopicParams.builder().clientName(MY_CLIENT).basePath("policy/pdpx/v1/")
@@ -75,8 +76,8 @@ public class GuardOperationTest extends BasicHttpOperation {
HttpClientFactoryInstance.getClientFactory().build(clientParams);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
HttpClientFactoryInstance.getClientFactory().destroy();
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@@ -84,12 +85,12 @@ public class GuardOperationTest extends BasicHttpOperation {
/**
* Sets up.
*/
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUpBasic();
guardConfig = mock(DecisionConfig.class);
- when(guardConfig.makeRequest()).thenAnswer(args -> {
+ Mockito.lenient().when(guardConfig.makeRequest()).thenAnswer(args -> {
DecisionRequest req = new DecisionRequest();
req.setAction("guard");
req.setOnapComponent("my-onap-component");
@@ -110,7 +111,7 @@ public class GuardOperationTest extends BasicHttpOperation {
* Tests "success" case with simulator.
*/
@Test
- public void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
DecisionParams opParams =
DecisionParams.builder().clientName(MY_CLIENT).path("decision").action("guard").build();
config = new DecisionConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -120,14 +121,14 @@ public class GuardOperationTest extends BasicHttpOperation {
outcome = oper.start().get();
assertEquals(OperationResult.SUCCESS, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof DecisionResponse);
+ assertInstanceOf(DecisionResponse.class, outcome.getResponse());
}
/**
* Tests "failure" case with simulator.
*/
@Test
- public void testFailure() throws Exception {
+ void testFailure() throws Exception {
DecisionParams opParams =
DecisionParams.builder().clientName(MY_CLIENT).path("decision").action("guard").build();
config = new DecisionConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
@@ -138,22 +139,22 @@ public class GuardOperationTest extends BasicHttpOperation {
outcome = oper.start().get();
assertEquals(OperationResult.FAILURE, outcome.getResult());
- assertTrue(outcome.getResponse() instanceof DecisionResponse);
+ assertInstanceOf(DecisionResponse.class, outcome.getResponse());
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEmpty();
}
@Test
- public void testMakeRequest() throws CoderException {
+ void testMakeRequest() throws CoderException {
oper.generateSubRequestId(2);
verifyPayload("makeReqStd.json", makePayload());
@@ -182,7 +183,7 @@ public class GuardOperationTest extends BasicHttpOperation {
}
@Test
- public void testPostProcessResponse() {
+ void testPostProcessResponse() {
DecisionResponse response = new DecisionResponse();
// null status
diff --git a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/XacmlActorParamsTest.java b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/XacmlActorParamsTest.java
index 4a08871d8..26549e8db 100644
--- a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/XacmlActorParamsTest.java
+++ b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/XacmlActorParamsTest.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,20 +22,20 @@
package org.onap.policy.controlloop.actor.xacml;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Consumer;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ActorParams;
-public class XacmlActorParamsTest {
+class XacmlActorParamsTest {
private static final String CONTAINER = "my-container";
private static final String CLIENT = "my-client";
private static final int TIMEOUT = 10;
@@ -55,8 +56,8 @@ public class XacmlActorParamsTest {
* Initializes {@link #operations} with two items and {@link params} with a fully
* populated object.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
operations = new TreeMap<>();
operations.put(PATH1, Map.of("path", URI1));
operations.put(PATH2, Map.of("path", URI2));
@@ -65,13 +66,13 @@ public class XacmlActorParamsTest {
}
@Test
- public void testIsDisabled() {
+ void testIsDisabled() {
// disabled by default
assertFalse(params.isDisabled());
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
// only a few fields are required
@@ -90,13 +91,13 @@ public class XacmlActorParamsTest {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
+ assertTrue(result.isValid(), fieldName);
// make invalid params
XacmlActorParams params2 = makeXacmlActorParams();
makeInvalid.accept(params2);
result = params2.validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
+ assertFalse(result.isValid(), fieldName);
assertThat(result.getResult()).contains(CONTAINER).contains(fieldName).contains(expected);
}
diff --git a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/XacmlActorTest.java b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/XacmlActorTest.java
index 5c32f92bc..3f0e52860 100644
--- a/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/XacmlActorTest.java
+++ b/models-interactions/model-actors/actor.xacml/src/test/java/org/onap/policy/controlloop/actor/xacml/XacmlActorTest.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,18 +21,19 @@
package org.onap.policy.controlloop.actor.xacml;
-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.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.actor.test.BasicActor;
-public class XacmlActorTest extends BasicActor {
+class XacmlActorTest extends BasicActor {
@Test
- public void test() {
+ void test() {
final XacmlActor prov = new XacmlActor();
// verify that it has the operators we expect
@@ -44,7 +46,7 @@ public class XacmlActorTest extends BasicActor {
// verify that it all plugs into the ActorService
verifyActorService(XacmlActor.NAME, "service.yaml");
- assertTrue(prov.getOperator(GuardOperation.NAME) instanceof DecisionOperator);
- assertTrue(prov.getOperator(ConfigureOperation.NAME) instanceof DecisionOperator);
+ assertInstanceOf(DecisionOperator.class, prov.getOperator(GuardOperation.NAME));
+ assertInstanceOf(DecisionOperator.class, prov.getOperator(ConfigureOperation.NAME));
}
}
diff --git a/models-interactions/model-actors/actorServiceProvider/pom.xml b/models-interactions/model-actors/actorServiceProvider/pom.xml
index efebac6fe..cb5a38167 100644
--- a/models-interactions/model-actors/actorServiceProvider/pom.xml
+++ b/models-interactions/model-actors/actorServiceProvider/pom.xml
@@ -60,5 +60,10 @@
<artifactId>mockito-core</artifactId>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java
index 97f6bbacf..e59c2fd89 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.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.
@@ -21,11 +22,11 @@
package org.onap.policy.controlloop.actorserviceprovider;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
@@ -42,8 +43,8 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.function.Consumer;
import java.util.stream.Collectors;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.controlloop.actorserviceprovider.impl.ActorImpl;
@@ -51,32 +52,32 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ActorParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
-public class ActorServiceTest {
- private static final String EXPECTED_EXCEPTION = "expected exception";
- private static final String ACTOR1 = "actor A";
- private static final String ACTOR2 = "actor B";
- private static final String ACTOR3 = "actor C";
- private static final String ACTOR4 = "actor D";
+class ActorServiceTest {
+ static final String EXPECTED_EXCEPTION = "expected exception";
+ static final String ACTOR1 = "actor A";
+ static final String ACTOR2 = "actor B";
+ static final String ACTOR3 = "actor C";
+ static final String ACTOR4 = "actor D";
- private Actor actor1;
- private Actor actor2;
- private Actor actor3;
- private Actor actor4;
+ Actor actor1;
+ Actor actor2;
+ Actor actor3;
+ Actor actor4;
- private Map<String, Object> sub1;
- private Map<String, Object> sub2;
- private Map<String, Object> sub3;
- private Map<String, Object> sub4;
- private Map<String, Object> params;
+ Map<String, Object> sub1;
+ Map<String, Object> sub2;
+ Map<String, Object> sub3;
+ Map<String, Object> sub4;
+ Map<String, Object> params;
- private ActorService service;
+ ActorService service;
/**
* Initializes the fields, including a fully populated {@link #service}.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
actor1 = spy(new ActorImpl(ACTOR1));
actor2 = spy(new ActorImpl(ACTOR2));
actor3 = spy(new ActorImpl(ACTOR3));
@@ -93,7 +94,7 @@ public class ActorServiceTest {
}
@Test
- public void testActorService_testBuildList() {
+ void testActorService_testBuildList() {
/*
* make a service where actors two and four have names that are duplicates of the
* others
@@ -122,7 +123,7 @@ public class ActorServiceTest {
}
@Test
- public void testDoStart() {
+ void testDoStart() {
service.configure(params);
setUpOp("testDoStart", actor -> when(actor.isConfigured()).thenReturn(false), Actor::start);
@@ -148,7 +149,7 @@ public class ActorServiceTest {
}
@Test
- public void testDoStop() {
+ void testDoStop() {
service.configure(params);
service.start();
@@ -175,7 +176,7 @@ public class ActorServiceTest {
}
@Test
- public void testDoShutdown() {
+ void testDoShutdown() {
service.configure(params);
service.start();
@@ -211,7 +212,7 @@ public class ActorServiceTest {
*/
private void setUpOp(String testName, Consumer<Actor> oper2, Consumer<Actor> oper3) {
Collection<Actor> actors = service.getActors();
- assertEquals(testName, 4, actors.size());
+ assertEquals(4, actors.size(), testName);
Iterator<Actor> iter = actors.iterator();
@@ -229,7 +230,7 @@ public class ActorServiceTest {
}
@Test
- public void testGetActor() {
+ void testGetActor() {
assertSame(actor1, service.getActor(ACTOR1));
assertSame(actor3, service.getActor(ACTOR3));
@@ -237,7 +238,7 @@ public class ActorServiceTest {
}
@Test
- public void testGetActors() {
+ void testGetActors() {
// @formatter:off
assertEquals("[actor A, actor B, actor C, actor D]",
service.getActors().stream()
@@ -249,7 +250,7 @@ public class ActorServiceTest {
}
@Test
- public void testGetActorNames() {
+ void testGetActorNames() {
// @formatter:off
assertEquals("[actor A, actor B, actor C, actor D]",
service.getActorNames().stream()
@@ -260,7 +261,7 @@ public class ActorServiceTest {
}
@Test
- public void testDoConfigure() {
+ void testDoConfigure() {
service.configure(params);
assertTrue(service.isConfigured());
@@ -279,7 +280,7 @@ public class ActorServiceTest {
* Tests doConfigure() where actors throw parameter validation and runtime exceptions.
*/
@Test
- public void testDoConfigureExceptions() {
+ void testDoConfigureExceptions() {
makeValidException(actor1);
makeRuntimeException(actor2);
makeValidException(actor3);
@@ -297,7 +298,7 @@ public class ActorServiceTest {
* </ul>
*/
@Test
- public void testDoConfigureConfigure() {
+ void testDoConfigureConfigure() {
// need mutable parameters
params = new TreeMap<>(params);
@@ -365,7 +366,7 @@ public class ActorServiceTest {
}
@Test
- public void testLoadActors() {
+ void testLoadActors() {
ActorService service = new ActorService();
assertFalse(service.getActors().isEmpty());
assertNotNull(service.getActor(DummyActor.class.getSimpleName()));
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/CallbackManagerTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/CallbackManagerTest.java
index 44606cb14..722be718c 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/CallbackManagerTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/CallbackManagerTest.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,27 +21,27 @@
package org.onap.policy.controlloop.actorserviceprovider;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.time.Instant;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class CallbackManagerTest {
+class CallbackManagerTest {
private CallbackManager mgr;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
mgr = new CallbackManager();
}
@Test
- public void testCanStart_testGetStartTime() {
+ void testCanStart_testGetStartTime() {
// null until canXxx() is called
assertNull(mgr.getStartTime());
@@ -58,7 +59,7 @@ public class CallbackManagerTest {
}
@Test
- public void testCanEnd_testGetEndTime() {
+ void testCanEnd_testGetEndTime() {
// null until canXxx() is called
assertNull(mgr.getEndTime());
assertNull(mgr.getEndTime());
@@ -77,7 +78,7 @@ public class CallbackManagerTest {
}
@Test
- public void testRun() {
+ void testRun() {
mgr.run();
assertNotNull(mgr.getStartTime());
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DelayedIdentStringTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DelayedIdentStringTest.java
index 5b9856f41..a63202024 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DelayedIdentStringTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DelayedIdentStringTest.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.
@@ -21,14 +22,14 @@
package org.onap.policy.controlloop.actorserviceprovider;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class DelayedIdentStringTest {
+class DelayedIdentStringTest {
private int countToStringCalls;
private Object object;
@@ -37,8 +38,8 @@ public class DelayedIdentStringTest {
/**
* Initializes fields, including {@link #delay}.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
countToStringCalls = 0;
object = new Object() {
@@ -53,7 +54,7 @@ public class DelayedIdentStringTest {
}
@Test
- public void testToString() {
+ void testToString() {
String delayed = delay.toString();
assertEquals(1, countToStringCalls);
@@ -86,7 +87,7 @@ public class DelayedIdentStringTest {
}
@Test
- public void testDelayedIdentString() {
+ void testDelayedIdentString() {
// should not have called the object's toString() method yet
assertEquals(0, countToStringCalls);
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DummyActor.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DummyActor.java
index f10694de6..497e4ae52 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DummyActor.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DummyActor.java
@@ -3,7 +3,7 @@
* TestActorServiceProvider
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2024 Nordix Foundation.
* Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
index 6f667bb76..61fb6a31e 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.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,17 +22,17 @@
package org.onap.policy.controlloop.actorserviceprovider;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.time.Instant;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.ControlLoopOperation;
-public class OperationOutcomeTest {
+class OperationOutcomeTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-operation";
private static final String TARGET = "my-target";
@@ -47,13 +48,13 @@ public class OperationOutcomeTest {
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
outcome = new OperationOutcome();
}
@Test
- public void testOperationOutcomeOperationOutcome() {
+ void testOperationOutcomeOperationOutcome() {
setAll();
OperationOutcome outcome2 = new OperationOutcome(outcome);
@@ -70,7 +71,7 @@ public class OperationOutcomeTest {
}
@Test
- public void testToControlLoopOperation() {
+ void testToControlLoopOperation() {
setAll();
ControlLoopOperation outcome2 = outcome.toControlLoopOperation();
@@ -89,7 +90,7 @@ public class OperationOutcomeTest {
* Tests both isFor() methods, as one invokes the other.
*/
@Test
- public void testIsFor() {
+ void testIsFor() {
setAll();
// null case
@@ -122,7 +123,7 @@ public class OperationOutcomeTest {
}
@Test
- public void testSetResult() {
+ void testSetResult() {
outcome.setResult(OperationResult.FAILURE_EXCEPTION);
assertEquals(OperationResult.FAILURE_EXCEPTION, outcome.getResult());
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/UtilTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/UtilTest.java
index 0a2a5a90e..068a72365 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/UtilTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/UtilTest.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.
@@ -22,10 +23,10 @@ package org.onap.policy.controlloop.actorserviceprovider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-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.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import ch.qos.logback.classic.Logger;
import java.util.LinkedHashMap;
@@ -35,14 +36,14 @@ import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicInteger;
import lombok.Builder;
import lombok.Data;
-import org.junit.AfterClass;
-import org.junit.Before;
-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.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.log.logback.ExtractAppender;
import org.slf4j.LoggerFactory;
-public class UtilTest {
+class UtilTest {
protected static final String EXPECTED_EXCEPTION = "expected exception";
/**
@@ -54,26 +55,26 @@ public class UtilTest {
/**
* Initializes statics.
*/
- @BeforeClass
- public static void setUpBeforeClass() {
+ @BeforeAll
+ static void setUpBeforeClass() {
appender.setContext(logger.getLoggerContext());
appender.start();
logger.addAppender(appender);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
appender.stop();
}
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
appender.clearExtractions();
}
@Test
- public void testIdent() {
+ void testIdent() {
Object object = new Object();
String result = Util.ident(object).toString();
@@ -83,7 +84,7 @@ public class UtilTest {
}
@Test
- public void testRunFunction() {
+ void testRunFunction() {
// no exception, no log
AtomicInteger count = new AtomicInteger();
Util.runFunction(() -> count.incrementAndGet(), "no error");
@@ -110,7 +111,7 @@ public class UtilTest {
}
@Test
- public void testTranslate() {
+ void testTranslate() {
// Abc => Abc
final Abc abc = Abc.builder().intValue(1).strValue("hello").anotherString("another").build();
Abc abc2 = Util.translate("abc to abc", abc, Abc.class);
@@ -137,7 +138,7 @@ public class UtilTest {
}
@Test
- public void testTranslateToMap() {
+ void testTranslateToMap() {
assertNull(Util.translateToMap("map: null", null));
// Abc => Map
@@ -155,7 +156,7 @@ public class UtilTest {
@Data
@Builder
- public static class Abc {
+ static class Abc {
private int intValue;
private String strValue;
private String anotherString;
@@ -164,17 +165,17 @@ public class UtilTest {
// this shares some fields with Abc so the data should transfer
@Data
@Builder
- public static class Similar {
+ static class Similar {
private int intValue;
private String strValue;
}
// throws an exception when getXxx() is used
- public static class DataWithException {
+ static class DataWithException {
@SuppressWarnings("unused")
private int intValue;
- public int getIntValue() {
+ int getIntValue() {
throw new IllegalStateException();
}
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java
index cf07d3b2b..1635c16ce 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.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.
@@ -22,10 +23,10 @@ package org.onap.policy.controlloop.actorserviceprovider.impl;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
@@ -37,8 +38,8 @@ import static org.mockito.Mockito.when;
import java.util.Iterator;
import java.util.Map;
import java.util.stream.Collectors;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
@@ -47,7 +48,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ActorParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-public class ActorImplTest {
+class ActorImplTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String ACTOR_NAME = "my-actor";
private static final String OPER1 = "add";
@@ -72,8 +73,8 @@ public class ActorImplTest {
/**
* Initializes the fields, including a fully populated {@link #actor}.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
oper1 = spy(new MyOper(OPER1));
oper2 = spy(new MyOper(OPER2));
oper3 = spy(new MyOper(OPER3));
@@ -90,14 +91,14 @@ public class ActorImplTest {
}
@Test
- public void testActorImpl_testGetName() {
+ void testActorImpl_testGetName() {
assertEquals(ACTOR_NAME, actor.getName());
assertEquals(4, actor.getOperationNames().size());
assertEquals(0, actor.getSequenceNumber());
}
@Test
- public void testDoStart() {
+ void testDoStart() {
actor.configure(params);
assertEquals(4, actor.getOperationNames().size());
@@ -130,7 +131,7 @@ public class ActorImplTest {
}
@Test
- public void testDoStop() {
+ void testDoStop() {
actor.configure(params);
actor.start();
assertEquals(4, actor.getOperationNames().size());
@@ -162,7 +163,7 @@ public class ActorImplTest {
}
@Test
- public void testDoShutdown() {
+ void testDoShutdown() {
actor.configure(params);
actor.start();
assertEquals(4, actor.getOperationNames().size());
@@ -194,7 +195,7 @@ public class ActorImplTest {
}
@Test
- public void testAddOperator() {
+ void testAddOperator() {
// cannot add operators if already configured
actor.configure(params);
assertThatIllegalStateException().isThrownBy(() -> actor.addOperator(oper1));
@@ -215,7 +216,7 @@ public class ActorImplTest {
}
@Test
- public void testGetOperator() {
+ void testGetOperator() {
assertSame(oper1, actor.getOperator(OPER1));
assertSame(oper3, actor.getOperator(OPER3));
@@ -223,7 +224,7 @@ public class ActorImplTest {
}
@Test
- public void testGetOperators() {
+ void testGetOperators() {
// @formatter:off
assertEquals("[add, divide, multiply, subtract]",
actor.getOperators().stream()
@@ -235,7 +236,7 @@ public class ActorImplTest {
}
@Test
- public void testGetOperationNames() {
+ void testGetOperationNames() {
// @formatter:off
assertEquals("[add, divide, multiply, subtract]",
actor.getOperationNames().stream()
@@ -246,7 +247,7 @@ public class ActorImplTest {
}
@Test
- public void testDoConfigure() {
+ void testDoConfigure() {
actor.configure(params);
assertTrue(actor.isConfigured());
@@ -266,7 +267,7 @@ public class ActorImplTest {
* exceptions.
*/
@Test
- public void testDoConfigureExceptions() {
+ void testDoConfigureExceptions() {
makeValidException(oper1);
makeRuntimeException(oper2);
makeValidException(oper3);
@@ -284,7 +285,7 @@ public class ActorImplTest {
* </ul>
*/
@Test
- public void testDoConfigureConfigure() {
+ void testDoConfigureConfigure() {
// configure one operator
oper1.configure(sub1);
@@ -349,7 +350,7 @@ public class ActorImplTest {
}
@Test
- public void testMakeOperatorParameters() {
+ void testMakeOperatorParameters() {
actor.configure(params);
// each operator should have received its own parameters
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java
index 64d530d77..5ecebd668 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.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.
@@ -22,11 +23,11 @@ package org.onap.policy.controlloop.actorserviceprovider.impl;
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.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -34,13 +35,13 @@ import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
import java.util.function.Function;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+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.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException;
import org.onap.policy.controlloop.actorserviceprovider.Util;
@@ -48,8 +49,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.Bidirectional
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
-@RunWith(MockitoJUnitRunner.class)
-public class BidirectionalTopicActorTest {
+@ExtendWith(MockitoExtension.class)
+class BidirectionalTopicActorTest {
private static final String ACTOR = "my-actor";
private static final String UNKNOWN = "unknown";
@@ -69,8 +70,8 @@ public class BidirectionalTopicActorTest {
/**
* Configures the endpoints.
*/
- @BeforeClass
- public static void setUpBeforeClass() {
+ @BeforeAll
+ static void setUpBeforeClass() {
Properties props = new Properties();
props.setProperty("noop.sink.topics", MY_SINK);
props.setProperty("noop.source.topics", MY_SOURCE1 + "," + MY_SOURCE2);
@@ -81,8 +82,8 @@ public class BidirectionalTopicActorTest {
TopicEndpointManager.getManager().addTopicSources(props);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
// clear all topics after the tests
TopicEndpointManager.getManager().shutdown();
}
@@ -90,14 +91,14 @@ public class BidirectionalTopicActorTest {
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
actor = new MyActor();
actor.configure(Util.translateToMap(ACTOR, makeParams()));
}
@Test
- public void testDoStart() throws BidirectionalTopicClientException {
+ void testDoStart() throws BidirectionalTopicClientException {
// allocate some handlers
actor.getTopicHandler(MY_SINK, MY_SOURCE1);
actor.getTopicHandler(MY_SINK, MY_SOURCE2);
@@ -116,7 +117,7 @@ public class BidirectionalTopicActorTest {
}
@Test
- public void testDoStop() throws BidirectionalTopicClientException {
+ void testDoStop() throws BidirectionalTopicClientException {
// allocate some handlers
actor.getTopicHandler(MY_SINK, MY_SOURCE1);
actor.getTopicHandler(MY_SINK, MY_SOURCE2);
@@ -135,7 +136,8 @@ public class BidirectionalTopicActorTest {
}
@Test
- public void testDoShutdown() {
+ void testDoShutdown() throws BidirectionalTopicClientException {
+
// allocate some handlers
actor.getTopicHandler(MY_SINK, MY_SOURCE1);
actor.getTopicHandler(MY_SINK, MY_SOURCE2);
@@ -154,38 +156,38 @@ public class BidirectionalTopicActorTest {
}
@Test
- public void testMakeOperatorParameters() {
+ void testMakeOperatorParameters() {
BidirectionalTopicActorParams params = makeParams();
final BidirectionalTopicActor<BidirectionalTopicActorParams> prov =
- new BidirectionalTopicActor<>(ACTOR, BidirectionalTopicActorParams.class);
+ new BidirectionalTopicActor<>(ACTOR, BidirectionalTopicActorParams.class);
Function<String, Map<String, Object>> maker =
- prov.makeOperatorParameters(Util.translateToMap(prov.getName(), params));
+ prov.makeOperatorParameters(Util.translateToMap(prov.getName(), params));
assertNull(maker.apply(UNKNOWN));
// use a TreeMap to ensure the properties are sorted
assertEquals("{sinkTopic=my-sink, sourceTopic=my-source-A, timeoutSec=10}",
- new TreeMap<>(maker.apply("operA")).toString());
+ new TreeMap<>(maker.apply("operA")).toString());
assertEquals("{sinkTopic=my-sink, sourceTopic=topicB, timeoutSec=10}",
- new TreeMap<>(maker.apply("operB")).toString());
+ new TreeMap<>(maker.apply("operB")).toString());
// with invalid actor parameters
params.setOperations(null);
Map<String, Object> map = Util.translateToMap(prov.getName(), params);
assertThatThrownBy(() -> prov.makeOperatorParameters(map))
- .isInstanceOf(ParameterValidationRuntimeException.class);
+ .isInstanceOf(ParameterValidationRuntimeException.class);
}
@Test
- public void testBidirectionalTopicActor() {
+ void testBidirectionalTopicActor() {
assertEquals(ACTOR, actor.getName());
assertEquals(ACTOR, actor.getFullName());
}
@Test
- public void testGetTopicHandler() {
+ void testGetTopicHandler() throws BidirectionalTopicClientException {
assertSame(handler1, actor.getTopicHandler(MY_SINK, MY_SOURCE1));
assertSame(handler2, actor.getTopicHandler(MY_SINK, MY_SOURCE2));
@@ -193,7 +195,7 @@ public class BidirectionalTopicActorTest {
}
@Test
- public void testMakeTopicHandler() {
+ void testMakeTopicHandler() throws BidirectionalTopicClientException {
// use a real actor
actor = new BidirectionalTopicActor<>(ACTOR, BidirectionalTopicActorParams.class);
@@ -214,21 +216,21 @@ public class BidirectionalTopicActorTest {
// @formatter:off
params.setOperations(Map.of(
- "operA", Map.of(),
- "operB", Map.of("sourceTopic", "topicB")));
+ "operA", Map.of(),
+ "operB", Map.of("sourceTopic", "topicB")));
// @formatter:on
return params;
}
private class MyActor extends BidirectionalTopicActor<BidirectionalTopicActorParams> {
- public MyActor() {
+ MyActor() {
super(ACTOR, BidirectionalTopicActorParams.class);
}
@Override
protected BidirectionalTopicHandler makeTopicHandler(String sinkTopic, String sourceTopic)
- throws BidirectionalTopicClientException {
+ throws BidirectionalTopicClientException {
if (MY_SINK.equals(sinkTopic)) {
if (MY_SOURCE1.equals(sourceTopic)) {
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
index 662f864c7..1fc8cc18e 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -23,11 +24,11 @@ package org.onap.policy.controlloop.actorserviceprovider.impl;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
@@ -42,13 +43,14 @@ import java.util.function.BiConsumer;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
-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.Captor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
@@ -62,8 +64,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder;
-@RunWith(MockitoJUnitRunner.class)
-public class BidirectionalTopicOperationTest {
+@ExtendWith(MockitoExtension.class)
+class BidirectionalTopicOperationTest {
private static final CommInfrastructure SINK_INFRA = CommInfrastructure.NOOP;
private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
private static final String ACTOR = "my-actor";
@@ -98,14 +100,14 @@ public class BidirectionalTopicOperationTest {
/**
* Sets up.
*/
- @Before
- public void setUp() throws CoderException {
- when(config.getTopicHandler()).thenReturn(handler);
- when(config.getForwarder()).thenReturn(forwarder);
- when(config.getTimeoutMs()).thenReturn(TIMEOUT_MS);
+ @BeforeEach
+ void setUp() throws CoderException {
+ Mockito.lenient().when(config.getTopicHandler()).thenReturn(handler);
+ Mockito.lenient().when(config.getForwarder()).thenReturn(forwarder);
+ Mockito.lenient().when(config.getTimeoutMs()).thenReturn(TIMEOUT_MS);
- when(handler.send(any())).thenReturn(true);
- when(handler.getSinkTopicCommInfrastructure()).thenReturn(SINK_INFRA);
+ Mockito.lenient().when(handler.send(any())).thenReturn(true);
+ Mockito.lenient().when(handler.getSinkTopicCommInfrastructure()).thenReturn(SINK_INFRA);
executor = new PseudoExecutor();
@@ -119,11 +121,11 @@ public class BidirectionalTopicOperationTest {
ntimes = 1;
- oper = new MyOperation();
+ oper = new MyOperation(params, config);
}
@Test
- public void testConstructor_testGetTopicHandler_testGetForwarder_testGetTopicParams() {
+ void testConstructor_testGetTopicHandler_testGetForwarder_testGetTopicParams() {
assertEquals(ACTOR, oper.getActorName());
assertEquals(OPERATION, oper.getName());
assertSame(handler, oper.getTopicHandler());
@@ -133,8 +135,7 @@ public class BidirectionalTopicOperationTest {
}
@Test
- public void testStartOperationAsync() throws Exception {
-
+ void testStartOperationAsync() throws Exception {
// tell it to expect three responses
ntimes = 3;
@@ -173,11 +174,11 @@ public class BidirectionalTopicOperationTest {
* Tests startOperationAsync() when processResponse() throws an exception.
*/
@Test
- public void testStartOperationAsyncProcException() throws Exception {
- oper = new MyOperation() {
+ void testStartOperationAsyncProcException() throws Exception {
+ oper = new MyOperation(params, config) {
@Override
protected OperationOutcome processResponse(OperationOutcome outcome, String rawResponse,
- StandardCoderObject scoResponse) {
+ StandardCoderObject scoResponse) {
throw EXPECTED_EXCEPTION;
}
};
@@ -201,7 +202,7 @@ public class BidirectionalTopicOperationTest {
* Tests startOperationAsync() when the publisher throws an exception.
*/
@Test
- public void testStartOperationAsyncPubException() throws Exception {
+ void testStartOperationAsyncPubException() throws Exception {
// indicate that nothing was published
when(handler.send(any())).thenReturn(false);
@@ -214,7 +215,7 @@ public class BidirectionalTopicOperationTest {
}
@Test
- public void testGetTimeoutMsInteger() {
+ void testGetTimeoutMsInteger() {
// use default
assertEquals(TIMEOUT_MS, oper.getTimeoutMs(null));
assertEquals(TIMEOUT_MS, oper.getTimeoutMs(0));
@@ -224,7 +225,7 @@ public class BidirectionalTopicOperationTest {
}
@Test
- public void testPublishRequest() {
+ void testPublishRequest() {
assertThatCode(() -> oper.publishRequest(new MyRequest())).doesNotThrowAnyException();
}
@@ -232,7 +233,7 @@ public class BidirectionalTopicOperationTest {
* Tests publishRequest() when nothing is published.
*/
@Test
- public void testPublishRequestUnpublished() {
+ void testPublishRequestUnpublished() {
when(handler.send(any())).thenReturn(false);
assertThatIllegalStateException().isThrownBy(() -> oper.publishRequest(new MyRequest()));
}
@@ -241,8 +242,8 @@ public class BidirectionalTopicOperationTest {
* Tests publishRequest() when the request type is a String.
*/
@Test
- public void testPublishRequestString() {
- MyStringOperation oper2 = new MyStringOperation();
+ void testPublishRequestString() {
+ MyStringOperation oper2 = new MyStringOperation(params, config);
assertThatCode(() -> oper2.publishRequest(TEXT)).doesNotThrowAnyException();
}
@@ -250,7 +251,7 @@ public class BidirectionalTopicOperationTest {
* Tests publishRequest() when the coder throws an exception.
*/
@Test
- public void testPublishRequestException() {
+ void testPublishRequestException() {
setOperCoderException();
assertThatIllegalArgumentException().isThrownBy(() -> oper.publishRequest(new MyRequest()));
}
@@ -259,8 +260,8 @@ public class BidirectionalTopicOperationTest {
* Tests processResponse() when it's a success and the response type is a String.
*/
@Test
- public void testProcessResponseSuccessString() {
- MyStringOperation oper2 = new MyStringOperation();
+ void testProcessResponseSuccessString() {
+ MyStringOperation oper2 = new MyStringOperation(params, config);
assertSame(outcome, oper2.processResponse(outcome, TEXT, null));
assertEquals(OperationResult.SUCCESS, outcome.getResult());
@@ -272,8 +273,8 @@ public class BidirectionalTopicOperationTest {
* StandardCoderObject.
*/
@Test
- public void testProcessResponseSuccessSco() {
- MyScoOperation oper2 = new MyScoOperation();
+ void testProcessResponseSuccessSco() {
+ MyScoOperation oper2 = new MyScoOperation(params, config);
assertSame(outcome, oper2.processResponse(outcome, responseText, stdResponse));
assertEquals(OperationResult.SUCCESS, outcome.getResult());
@@ -284,7 +285,7 @@ public class BidirectionalTopicOperationTest {
* Tests processResponse() when it's a failure.
*/
@Test
- public void testProcessResponseFailure() throws CoderException {
+ void testProcessResponseFailure() throws CoderException {
// indicate error in the response
MyResponse resp = new MyResponse();
resp.setOutput("error");
@@ -301,7 +302,7 @@ public class BidirectionalTopicOperationTest {
* Tests processResponse() when the decoder succeeds.
*/
@Test
- public void testProcessResponseDecodeOk() throws CoderException {
+ void testProcessResponseDecodeOk() throws CoderException {
assertSame(outcome, oper.processResponse(outcome, responseText, stdResponse));
assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertEquals(response, outcome.getResponse());
@@ -311,20 +312,18 @@ public class BidirectionalTopicOperationTest {
* Tests processResponse() when the decoder throws an exception.
*/
@Test
- public void testProcessResponseDecodeExcept() throws CoderException {
- // @formatter:off
+ void testProcessResponseDecodeExcept() throws CoderException {
assertThatIllegalArgumentException().isThrownBy(
() -> oper.processResponse(outcome, "{invalid json", stdResponse));
- // @formatter:on
}
@Test
- public void testPostProcessResponse() {
+ void testPostProcessResponse() {
assertThatCode(() -> oper.postProcessResponse(outcome, null, null)).doesNotThrowAnyException();
}
@Test
- public void testGetCoder() {
+ void testGetCoder() {
assertNotNull(oper.getCoder());
}
@@ -332,7 +331,7 @@ public class BidirectionalTopicOperationTest {
* Creates a new {@link #oper} whose coder will throw an exception.
*/
private void setOperCoderException() {
- oper = new MyOperation() {
+ oper = new MyOperation(params, config) {
@Override
protected Coder getCoder() {
return new StandardCoder() {
@@ -347,7 +346,7 @@ public class BidirectionalTopicOperationTest {
@Getter
@Setter
- public static class MyRequest {
+ static class MyRequest {
private String theRequestId = REQ_ID;
private String input;
}
@@ -355,7 +354,7 @@ public class BidirectionalTopicOperationTest {
@Getter
@Setter
@EqualsAndHashCode
- public static class MyResponse {
+ static class MyResponse {
private String requestId;
private String output;
}
@@ -363,8 +362,8 @@ public class BidirectionalTopicOperationTest {
private class MyStringOperation extends BidirectionalTopicOperation<String, String> {
- public MyStringOperation() {
- super(BidirectionalTopicOperationTest.this.params, config, String.class, Collections.emptyList());
+ MyStringOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config) {
+ super(params, config, String.class, Collections.emptyList());
}
@Override
@@ -385,9 +384,8 @@ public class BidirectionalTopicOperationTest {
private class MyScoOperation extends BidirectionalTopicOperation<MyRequest, StandardCoderObject> {
- public MyScoOperation() {
- super(BidirectionalTopicOperationTest.this.params, config, StandardCoderObject.class,
- Collections.emptyList());
+ MyScoOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config) {
+ super(params, config, StandardCoderObject.class, Collections.emptyList());
}
@Override
@@ -408,8 +406,8 @@ public class BidirectionalTopicOperationTest {
private class MyOperation extends BidirectionalTopicOperation<MyRequest, MyResponse> {
- public MyOperation() {
- super(BidirectionalTopicOperationTest.this.params, config, MyResponse.class, Collections.emptyList());
+ MyOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config) {
+ super(params, config, MyResponse.class, Collections.emptyList());
}
@Override
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java
index 4d19782c2..38e8a29bb 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.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.
@@ -22,20 +23,21 @@ package org.onap.policy.controlloop.actorserviceprovider.impl;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
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.assertSame;
-import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
-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.TestInstance;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams;
@@ -46,8 +48,9 @@ import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopic
import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder;
import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey;
-@RunWith(MockitoJUnitRunner.class)
-public class BidirectionalTopicOperatorTest {
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@ExtendWith(MockitoExtension.class)
+class BidirectionalTopicOperatorTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-operation";
private static final String MY_SOURCE = "my-source";
@@ -70,12 +73,12 @@ public class BidirectionalTopicOperatorTest {
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
keys = List.of(new SelectorKey(""));
- when(mgr.getTopicHandler(MY_SINK, MY_SOURCE)).thenReturn(handler);
- when(handler.addForwarder(keys)).thenReturn(forwarder);
+ Mockito.lenient().when(mgr.getTopicHandler(MY_SINK, MY_SOURCE)).thenReturn(handler);
+ Mockito.lenient().when(handler.addForwarder(keys)).thenReturn(forwarder);
oper = new MyOperator(keys);
@@ -86,14 +89,14 @@ public class BidirectionalTopicOperatorTest {
}
@Test
- public void testConstructor_testGetParams_testGetTopicHandler_testGetForwarder() {
+ void testConstructor_testGetParams_testGetTopicHandler_testGetForwarder() {
assertEquals(ACTOR, oper.getActorName());
assertEquals(OPERATION, oper.getName());
assertNotNull(oper.getCurrentConfig());
}
@Test
- public void testDoConfigure() {
+ void testDoConfigure() {
oper.stop();
// invalid parameters
@@ -104,7 +107,7 @@ public class BidirectionalTopicOperatorTest {
}
@Test
- public void testBuildOperator() {
+ void testBuildOperator() {
AtomicReference<ControlLoopOperationParams> paramsRef = new AtomicReference<>();
AtomicReference<BidirectionalTopicConfig> configRef = new AtomicReference<>();
@@ -147,7 +150,7 @@ public class BidirectionalTopicOperatorTest {
private class MyOperator extends BidirectionalTopicOperator {
- public MyOperator(List<SelectorKey> selectorKeys) {
+ MyOperator(List<SelectorKey> selectorKeys) {
super(ACTOR, OPERATION, mgr, selectorKeys);
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpActorTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpActorTest.java
index 5407f1fee..56a4c94cc 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpActorTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpActorTest.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.
@@ -21,19 +22,19 @@
package org.onap.policy.controlloop.actorserviceprovider.impl;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Function;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpActorParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-public class HttpActorTest {
+class HttpActorTest {
private static final String ACTOR = "my-actor";
private static final String UNKNOWN = "unknown";
@@ -42,13 +43,13 @@ public class HttpActorTest {
private HttpActor<HttpActorParams> actor;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
actor = new HttpActor<>(ACTOR, HttpActorParams.class);
}
@Test
- public void testMakeOperatorParameters() {
+ void testMakeOperatorParameters() {
HttpActorParams params = new HttpActorParams();
params.setClientName(CLIENT);
params.setTimeoutSec(TIMEOUT);
@@ -80,7 +81,7 @@ public class HttpActorTest {
}
@Test
- public void testHttpActor() {
+ void testHttpActor() {
assertEquals(ACTOR, actor.getName());
assertEquals(ACTOR, actor.getFullName());
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java
index 7a99a54ba..9813d1b7a 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. 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.
@@ -25,11 +25,11 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
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.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@@ -59,13 +59,15 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
import lombok.Getter;
import lombok.Setter;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams.TopicParamsBuilder;
@@ -85,8 +87,9 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
-@RunWith(MockitoJUnitRunner.class)
-public class HttpOperationTest {
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@ExtendWith(MockitoExtension.class)
+class HttpOperationTest {
private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
private static final String ACTOR = "my-actor";
@@ -129,8 +132,8 @@ public class HttpOperationTest {
/**
* Starts the simulator.
*/
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ void setUpBeforeClass() throws Exception {
// allocate a port
int port = NetworkUtil.allocPort();
@@ -160,26 +163,26 @@ public class HttpOperationTest {
/**
* Destroys the Http factories and stops the appender.
*/
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
HttpClientFactoryInstance.getClientFactory().destroy();
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
/**
- * Initializes fields, including {@link #oper}, and resets the static fields used by
+ * Initializes fields, including {@link #oper}, and resets thestatic fields used by
* the REST server.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
rejectRequest = false;
nget = 0;
npost = 0;
nput = 0;
ndelete = 0;
- when(response.readEntity(String.class)).thenReturn(TEXT);
- when(response.getStatus()).thenReturn(200);
+ Mockito.lenient().when(response.readEntity(String.class)).thenReturn(TEXT);
+ Mockito.lenient().when(response.getStatus()).thenReturn(200);
params = ControlLoopOperationParams.builder().actor(ACTOR).operation(OPERATION).requestId(REQ_ID).build();
@@ -188,7 +191,7 @@ public class HttpOperationTest {
callback = new AtomicReference<>();
future = new CompletableFuture<>();
- when(clientFactory.get(any())).thenReturn(client);
+ Mockito.lenient().when(clientFactory.get(any())).thenReturn(client);
initConfig(HTTP_CLIENT);
@@ -196,24 +199,24 @@ public class HttpOperationTest {
}
@Test
- public void testHttpOperator() {
+ void testHttpOperator() {
assertEquals(ACTOR, oper.getActorName());
assertEquals(OPERATION, oper.getName());
assertEquals(ACTOR + "." + OPERATION, oper.getFullName());
}
@Test
- public void testMakeHeaders() {
+ void testMakeHeaders() {
assertEquals(Collections.emptyMap(), oper.makeHeaders());
}
@Test
- public void testGetPath() {
+ void testGetPath() {
assertEquals(PATH, oper.getPath());
}
@Test
- public void testMakeUrl() {
+ void testMakeUrl() {
// use a real client
initRealConfig(HTTP_CLIENT);
@@ -223,7 +226,7 @@ public class HttpOperationTest {
}
@Test
- public void testDoConfigureMapOfStringObject_testGetClient_testGetPath_testGetTimeoutMs() {
+ void testDoConfigureMapOfStringObject_testGetClient_testGetPath_testGetTimeoutMs() {
// use value from operator
assertEquals(1000L, oper.getTimeoutMs(null));
@@ -237,7 +240,7 @@ public class HttpOperationTest {
* Tests handleResponse() when it completes.
*/
@Test
- public void testHandleResponseComplete() throws Exception {
+ void testHandleResponseComplete() throws Exception {
CompletableFuture<OperationOutcome> future2 = oper.handleResponse(outcome, PATH, cb -> {
callback.set(cb);
return future;
@@ -257,7 +260,7 @@ public class HttpOperationTest {
* Tests handleResponse() when it fails.
*/
@Test
- public void testHandleResponseFailed() throws Exception {
+ void testHandleResponseFailed() throws Exception {
CompletableFuture<OperationOutcome> future2 = oper.handleResponse(outcome, PATH, cb -> {
callback.set(cb);
return future;
@@ -278,7 +281,7 @@ public class HttpOperationTest {
* Tests processResponse() when it's a success and the response type is a String.
*/
@Test
- public void testProcessResponseSuccessString() throws Exception {
+ void testProcessResponseSuccessString() throws Exception {
CompletableFuture<OperationOutcome> result = oper.processResponse(outcome, PATH, response);
assertTrue(result.isDone());
assertSame(outcome, result.get());
@@ -290,7 +293,7 @@ public class HttpOperationTest {
* Tests processResponse() when it's a failure.
*/
@Test
- public void testProcessResponseFailure() throws Exception {
+ void testProcessResponseFailure() throws Exception {
when(response.getStatus()).thenReturn(555);
CompletableFuture<OperationOutcome> result = oper.processResponse(outcome, PATH, response);
assertTrue(result.isDone());
@@ -303,7 +306,7 @@ public class HttpOperationTest {
* Tests processResponse() when the decoder succeeds.
*/
@Test
- public void testProcessResponseDecodeOk() throws Exception {
+ void testProcessResponseDecodeOk() throws Exception {
when(response.readEntity(String.class)).thenReturn("10");
MyGetOperation<Integer> oper2 = new MyGetOperation<>(Integer.class);
@@ -319,19 +322,19 @@ public class HttpOperationTest {
* Tests processResponse() when the decoder throws an exception.
*/
@Test
- public void testProcessResponseDecodeExcept() throws CoderException {
+ void testProcessResponseDecodeExcept() throws CoderException {
MyGetOperation<Integer> oper2 = new MyGetOperation<>(Integer.class);
assertThatIllegalArgumentException().isThrownBy(() -> oper2.processResponse(outcome, PATH, response));
}
@Test
- public void testPostProcessResponse() {
+ void testPostProcessResponse() {
assertThatCode(() -> oper.postProcessResponse(outcome, PATH, null, null)).doesNotThrowAnyException();
}
@Test
- public void testIsSuccess() {
+ void testIsSuccess() {
when(response.getStatus()).thenReturn(200);
assertTrue(oper.isSuccess(response, null));
@@ -343,7 +346,7 @@ public class HttpOperationTest {
* Tests a GET.
*/
@Test
- public void testGet() throws Exception {
+ void testGet() throws Exception {
// use a real client
initRealConfig(HTTP_CLIENT);
@@ -360,7 +363,7 @@ public class HttpOperationTest {
* Tests a DELETE.
*/
@Test
- public void testDelete() throws Exception {
+ void testDelete() throws Exception {
// use a real client
initRealConfig(HTTP_CLIENT);
@@ -377,7 +380,7 @@ public class HttpOperationTest {
* Tests a POST.
*/
@Test
- public void testPost() throws Exception {
+ void testPost() throws Exception {
// use a real client
initRealConfig(HTTP_CLIENT);
MyPostOperation oper2 = new MyPostOperation();
@@ -393,7 +396,7 @@ public class HttpOperationTest {
* Tests a PUT.
*/
@Test
- public void testPut() throws Exception {
+ void testPut() throws Exception {
// use a real client
initRealConfig(HTTP_CLIENT);
@@ -407,7 +410,7 @@ public class HttpOperationTest {
}
@Test
- public void testMakeDecoder() {
+ void testMakeDecoder() {
assertNotNull(oper.getCoder());
}
@@ -480,18 +483,18 @@ public class HttpOperationTest {
@Getter
@Setter
- public static class MyRequest {
+ static class MyRequest {
private String input = "some input";
}
@Getter
@Setter
- public static class MyResponse {
+ static class MyResponse {
private String output = "some output";
}
private class MyGetOperation<T> extends HttpOperation<T> {
- public MyGetOperation(Class<T> responseClass) {
+ MyGetOperation(Class<T> responseClass) {
super(HttpOperationTest.this.params, HttpOperationTest.this.config, responseClass, Collections.emptyList());
}
@@ -512,7 +515,7 @@ public class HttpOperationTest {
}
private class MyPostOperation extends HttpOperation<MyResponse> {
- public MyPostOperation() {
+ MyPostOperation() {
super(HttpOperationTest.this.params, HttpOperationTest.this.config, MyResponse.class,
Collections.emptyList());
}
@@ -540,7 +543,7 @@ public class HttpOperationTest {
}
private class MyPutOperation extends HttpOperation<MyResponse> {
- public MyPutOperation() {
+ MyPutOperation() {
super(HttpOperationTest.this.params, HttpOperationTest.this.config, MyResponse.class,
Collections.emptyList());
}
@@ -568,7 +571,7 @@ public class HttpOperationTest {
}
private class MyDeleteOperation extends HttpOperation<String> {
- public MyDeleteOperation() {
+ MyDeleteOperation() {
super(HttpOperationTest.this.params, HttpOperationTest.this.config, String.class, Collections.emptyList());
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperatorTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperatorTest.java
index 35cf08227..b070a6136 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperatorTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperatorTest.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.
@@ -22,21 +23,22 @@ package org.onap.policy.controlloop.actorserviceprovider.impl;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
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.assertNotSame;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.when;
import java.util.Collections;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
-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.TestInstance;
+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.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
@@ -47,8 +49,9 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-@RunWith(MockitoJUnitRunner.class)
-public class HttpOperatorTest {
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@ExtendWith(MockitoExtension.class)
+class HttpOperatorTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-name";
@@ -68,8 +71,8 @@ public class HttpOperatorTest {
* Initializes fields, including {@link #oper}, and resets the static fields used by
* the REST server.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
when(factory.get(HTTP_CLIENT)).thenReturn(client);
oper = new MyOperator();
@@ -80,14 +83,14 @@ public class HttpOperatorTest {
}
@Test
- public void testHttpOperator() {
+ void testHttpOperator() {
assertEquals(ACTOR, oper.getActorName());
assertEquals(OPERATION, oper.getName());
assertEquals(ACTOR + "." + OPERATION, oper.getFullName());
}
@Test
- public void testDoConfigureMapOfStringObject_testGetConfig() {
+ void testDoConfigureMapOfStringObject_testGetConfig() {
// start with an UNCONFIGURED operator
oper.shutdown();
oper = new MyOperator();
@@ -106,7 +109,7 @@ public class HttpOperatorTest {
}
@Test
- public void testBuildOperation() {
+ void testBuildOperation() {
HttpOperator oper2 = new MyOperator();
assertNotNull(oper2);
assertNotNull(oper2.getClientFactory());
@@ -137,13 +140,13 @@ public class HttpOperatorTest {
}
@Test
- public void testGetClientFactory() {
+ void testGetClientFactory() {
HttpOperator oper2 = new HttpOperator(ACTOR, OPERATION);
assertNotNull(oper2.getClientFactory());
}
private class MyOperator extends HttpOperator {
- public MyOperator() {
+ MyOperator() {
super(ACTOR, OPERATION, MyOperation::new);
}
@@ -154,7 +157,7 @@ public class HttpOperatorTest {
}
private class MyOperation extends HttpOperation<String> {
- public MyOperation(ControlLoopOperationParams params, HttpConfig config) {
+ MyOperation(ControlLoopOperationParams params, HttpConfig config) {
super(params, config, String.class, Collections.emptyList());
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java
index 2f7976ce5..0850bb358 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. 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.
@@ -23,11 +23,11 @@ package org.onap.policy.controlloop.actorserviceprovider.impl;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
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.assertNull;
-import static org.junit.Assert.assertSame;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+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;
@@ -38,11 +38,13 @@ import java.util.Collections;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
-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.TestInstance;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.stubbing.Answer;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
@@ -54,8 +56,9 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingCo
/**
* Tests HttpOperation when polling is enabled.
*/
-@RunWith(MockitoJUnitRunner.class)
-public class HttpPollingOperationTest {
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@ExtendWith(MockitoExtension.class)
+class HttpPollingOperationTest {
private static final String BASE_URI = "http://my-host:6969/base-uri/";
private static final String MY_PATH = "my-path";
private static final String FULL_PATH = BASE_URI + MY_PATH;
@@ -85,19 +88,19 @@ public class HttpPollingOperationTest {
/**
* Sets up.
*/
- @Before
- public void setUp() throws Exception {
- when(client.getBaseUrl()).thenReturn(BASE_URI);
+ @BeforeEach
+ void setUp() throws Exception {
+ Mockito.lenient().when(client.getBaseUrl()).thenReturn(BASE_URI);
- when(config.getClient()).thenReturn(client);
- when(config.getMaxPolls()).thenReturn(MAX_POLLS);
- when(config.getPollPath()).thenReturn(POLL_PATH);
- when(config.getPollWaitSec()).thenReturn(POLL_WAIT_SEC);
+ Mockito.lenient().when(config.getClient()).thenReturn(client);
+ Mockito.lenient().when(config.getMaxPolls()).thenReturn(MAX_POLLS);
+ Mockito.lenient().when(config.getPollPath()).thenReturn(POLL_PATH);
+ Mockito.lenient().when(config.getPollWaitSec()).thenReturn(POLL_WAIT_SEC);
response = MY_RESPONSE;
- when(rawResponse.getStatus()).thenReturn(RESPONSE_SUCCESS);
- when(rawResponse.readEntity(String.class)).thenReturn(response);
+ Mockito.lenient().when(rawResponse.getStatus()).thenReturn(RESPONSE_SUCCESS);
+ Mockito.lenient().when(rawResponse.readEntity(String.class)).thenReturn(response);
params = ControlLoopOperationParams.builder().actor(MY_ACTOR).operation(MY_OPERATION).build();
outcome = params.makeOutcome();
@@ -106,7 +109,7 @@ public class HttpPollingOperationTest {
}
@Test
- public void testConstructor_testGetWaitMsGet() {
+ void testConstructor_testGetWaitMsGet() {
assertEquals(MY_ACTOR, oper.getActorName());
assertEquals(MY_OPERATION, oper.getName());
assertSame(config, oper.getConfig());
@@ -114,7 +117,7 @@ public class HttpPollingOperationTest {
}
@Test
- public void testSetUsePollExceptions() {
+ void testSetUsePollExceptions() {
// should be no exception
oper.setUsePolling();
@@ -125,7 +128,7 @@ public class HttpPollingOperationTest {
}
@Test
- public void testPostProcess() throws Exception {
+ void testPostProcess() throws Exception {
// completed
oper.generateSubRequestId(2);
CompletableFuture<OperationOutcome> future2 =
@@ -151,7 +154,7 @@ public class HttpPollingOperationTest {
* Tests postProcess() when the poll is repeated a couple of times.
*/
@Test
- public void testPostProcessRepeated_testResetGetCount() throws Exception {
+ void testPostProcessRepeated_testResetGetCount() throws Exception {
/*
* Two accepts and then a success - should result in two polls.
*/
@@ -193,7 +196,7 @@ public class HttpPollingOperationTest {
}
@Test
- public void testDetmStatus() {
+ void testDetmStatus() {
// make an operation that does NOT override detmStatus()
oper = new HttpOperation<String>(params, config, String.class, Collections.emptyList()) {};
@@ -228,7 +231,7 @@ public class HttpPollingOperationTest {
private static class MyOper extends HttpOperation<String> {
- public MyOper(ControlLoopOperationParams params, HttpConfig config) {
+ MyOper(ControlLoopOperationParams params, HttpConfig config) {
super(params, config, String.class, Collections.emptyList());
setUsePolling();
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.java
index f340f1972..ca81e2eb3 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.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,18 +22,20 @@
package org.onap.policy.controlloop.actorserviceprovider.impl;
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.Mockito.when;
import java.util.Collections;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+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.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.controlloop.actorserviceprovider.Util;
@@ -42,8 +45,9 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingCo
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-@RunWith(MockitoJUnitRunner.class)
-public class HttpPollingOperatorTest {
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@ExtendWith(MockitoExtension.class)
+class HttpPollingOperatorTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-name";
private static final String CLIENT = "my-client";
@@ -64,8 +68,8 @@ public class HttpPollingOperatorTest {
* Initializes fields, including {@link #oper}, and resets the static fields used by
* the REST server.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
when(factory.get(CLIENT)).thenReturn(client);
oper = new MyOperator();
@@ -77,14 +81,14 @@ public class HttpPollingOperatorTest {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(ACTOR, oper.getActorName());
assertEquals(OPERATION, oper.getName());
assertEquals(ACTOR + "." + OPERATION, oper.getFullName());
}
@Test
- public void testDoConfigure_testGetters() {
+ void testDoConfigure_testGetters() {
assertTrue(oper.getCurrentConfig() instanceof HttpPollingConfig);
// test invalid parameters
@@ -93,7 +97,7 @@ public class HttpPollingOperatorTest {
}
@Test
- public void testGetClientFactory() {
+ void testGetClientFactory() {
HttpPollingOperator oper2 = new HttpPollingOperator(ACTOR, OPERATION);
assertNotNull(oper2.getClientFactory());
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
index ae07f1f19..57dbfb141 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
@@ -23,12 +23,12 @@ package org.onap.policy.controlloop.actorserviceprovider.impl;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import ch.qos.logback.classic.Logger;
import java.time.Instant;
@@ -53,13 +53,15 @@ import java.util.function.Consumer;
import java.util.function.Supplier;
import lombok.Getter;
import lombok.Setter;
-import org.junit.AfterClass;
-import org.junit.Before;
-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.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;
import org.onap.policy.common.utils.coder.Coder;
@@ -79,8 +81,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.OperatorConfi
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.slf4j.LoggerFactory;
-@RunWith(MockitoJUnitRunner.class)
-public class OperationPartialTest {
+@ExtendWith(MockitoExtension.class)
+class OperationPartialTest {
private static final CommInfrastructure SINK_INFRA = CommInfrastructure.NOOP;
private static final CommInfrastructure SOURCE_INFRA = CommInfrastructure.NOOP;
private static final int MAX_REQUESTS = 100;
@@ -136,8 +138,8 @@ public class OperationPartialTest {
/**
* Attaches the appender to the logger.
*/
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
/*
* Attach appender to the logger.
*/
@@ -150,16 +152,16 @@ public class OperationPartialTest {
/**
* Stops the appender.
*/
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
appender.stop();
}
/**
* Initializes the fields, including {@link #oper}.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
executor = new PseudoExecutor();
params = ControlLoopOperationParams.builder().completeCallback(this::completer).requestId(REQ_ID)
@@ -180,14 +182,14 @@ public class OperationPartialTest {
}
@Test
- public void testOperatorPartial_testGetActorName_testGetName() {
+ void testOperatorPartial_testGetActorName_testGetName() {
assertEquals(ACTOR, oper.getActorName());
assertEquals(OPERATION, oper.getName());
assertEquals(ACTOR + "." + OPERATION, oper.getFullName());
}
@Test
- public void testGetBlockingThread() throws Exception {
+ void testGetBlockingThread() throws Exception {
CompletableFuture<Void> future = new CompletableFuture<>();
// use the real executor
@@ -204,12 +206,12 @@ public class OperationPartialTest {
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(PROP_NAMES);
}
@Test
- public void testGetProperty_testSetProperty_testGetRequiredProperty() {
+ void testGetProperty_testSetProperty_testGetRequiredProperty() {
oper.setProperty("propertyA", "valueA");
oper.setProperty("propertyB", "valueB");
oper.setProperty("propertyC", 20);
@@ -226,7 +228,7 @@ public class OperationPartialTest {
}
@Test
- public void testStart() {
+ void testStart() {
verifyRun("testStart", 1, 1, OperationResult.SUCCESS);
}
@@ -234,7 +236,7 @@ public class OperationPartialTest {
* Tests start() with multiple running requests.
*/
@Test
- public void testStartMultiple() {
+ void testStartMultiple() {
for (int count = 0; count < MAX_PARALLEL; ++count) {
oper.start();
}
@@ -251,7 +253,7 @@ public class OperationPartialTest {
}
@Test
- public void testStartOperationAsync() {
+ void testStartOperationAsync() {
oper.start();
assertTrue(executor.runAll(MAX_REQUESTS));
@@ -259,7 +261,7 @@ public class OperationPartialTest {
}
@Test
- public void testIsSuccess() {
+ void testIsSuccess() {
assertFalse(oper.isSuccess(null));
OperationOutcome outcome = new OperationOutcome();
@@ -269,12 +271,12 @@ public class OperationPartialTest {
for (OperationResult failure : FAILURE_RESULTS) {
outcome.setResult(failure);
- assertFalse("testIsSuccess-" + failure, oper.isSuccess(outcome));
+ assertFalse(oper.isSuccess(outcome), "testIsSuccess-" + failure);
}
}
@Test
- public void testIsActorFailed() {
+ void testIsActorFailed() {
assertFalse(oper.isActorFailed(null));
OperationOutcome outcome = params.makeOutcome();
@@ -308,7 +310,7 @@ public class OperationPartialTest {
}
@Test
- public void testDoOperation() {
+ void testDoOperation() {
/*
* Use an operation that doesn't override doOperation().
*/
@@ -322,7 +324,7 @@ public class OperationPartialTest {
}
@Test
- public void testTimeout() throws Exception {
+ void testTimeout() throws Exception {
// use a real executor
params = params.toBuilder().executor(ForkJoinPool.commonPool()).build();
@@ -360,7 +362,7 @@ public class OperationPartialTest {
* Tests retry functions, when the count is set to zero and retries are exhausted.
*/
@Test
- public void testSetRetryFlag_testRetryOnFailure_ZeroRetries_testStartOperationAttempt() {
+ void testSetRetryFlag_testRetryOnFailure_ZeroRetries_testStartOperationAttempt() {
params = params.toBuilder().retry(0).build();
// new params, thus need a new operation
@@ -375,7 +377,7 @@ public class OperationPartialTest {
* Tests retry functions, when the count is null and retries are exhausted.
*/
@Test
- public void testSetRetryFlag_testRetryOnFailure_NullRetries() {
+ void testSetRetryFlag_testRetryOnFailure_NullRetries() {
params = params.toBuilder().retry(null).build();
// new params, thus need a new operation
@@ -390,7 +392,7 @@ public class OperationPartialTest {
* Tests retry functions, when retries are exhausted.
*/
@Test
- public void testSetRetryFlag_testRetryOnFailure_RetriesExhausted() {
+ void testSetRetryFlag_testRetryOnFailure_RetriesExhausted() {
final int maxRetries = 3;
params = params.toBuilder().retry(maxRetries).build();
@@ -407,7 +409,7 @@ public class OperationPartialTest {
* Tests retry functions, when a success follows some retries.
*/
@Test
- public void testSetRetryFlag_testRetryOnFailure_SuccessAfterRetries() {
+ void testSetRetryFlag_testRetryOnFailure_SuccessAfterRetries() {
params = params.toBuilder().retry(10).build();
// new params, thus need a new operation
@@ -424,7 +426,7 @@ public class OperationPartialTest {
* Tests retry functions, when the outcome is {@code null}.
*/
@Test
- public void testSetRetryFlag_testRetryOnFailure_NullOutcome() {
+ void testSetRetryFlag_testRetryOnFailure_NullOutcome() {
// arrange to return null from doOperation()
oper = new MyOper() {
@@ -441,7 +443,7 @@ public class OperationPartialTest {
}
@Test
- public void testSleep() throws Exception {
+ void testSleep() throws Exception {
CompletableFuture<Void> future = oper.sleep(-1, TimeUnit.SECONDS);
assertTrue(future.isDone());
assertNull(future.get());
@@ -471,7 +473,7 @@ public class OperationPartialTest {
}
@Test
- public void testIsSameOperation() {
+ void testIsSameOperation() {
assertFalse(oper.isSameOperation(null));
OperationOutcome outcome = params.makeOutcome();
@@ -494,7 +496,7 @@ public class OperationPartialTest {
}
@Test
- public void testFromException() {
+ void testFromException() {
// arrange to generate an exception when operation runs
oper.setGenException(true);
@@ -505,7 +507,7 @@ public class OperationPartialTest {
* Tests fromException() when there is no exception.
*/
@Test
- public void testFromExceptionNoExcept() {
+ void testFromExceptionNoExcept() {
verifyRun("testFromExceptionNoExcept", 1, 1, OperationResult.SUCCESS);
}
@@ -513,7 +515,7 @@ public class OperationPartialTest {
* Tests both flavors of anyOf(), because one invokes the other.
*/
@Test
- public void testAnyOf() throws Exception {
+ void testAnyOf() throws Exception {
// first task completes, others do not
List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
@@ -565,7 +567,7 @@ public class OperationPartialTest {
*/
@Test
@SuppressWarnings("unchecked")
- public void testAnyOfEdge() throws Exception {
+ void testAnyOfEdge() throws Exception {
List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
// zero items: check both using a list and using an array
@@ -581,7 +583,7 @@ public class OperationPartialTest {
}
@Test
- public void testAllOfArray() throws Exception {
+ void testAllOfArray() throws Exception {
final OperationOutcome outcome = params.makeOutcome();
CompletableFuture<OperationOutcome> future1 = new CompletableFuture<>();
@@ -612,7 +614,7 @@ public class OperationPartialTest {
}
@Test
- public void testAllOfList() throws Exception {
+ void testAllOfList() throws Exception {
final OperationOutcome outcome = params.makeOutcome();
CompletableFuture<OperationOutcome> future1 = new CompletableFuture<>();
@@ -651,7 +653,7 @@ public class OperationPartialTest {
*/
@Test
@SuppressWarnings("unchecked")
- public void testAllOfEdge() throws Exception {
+ void testAllOfEdge() throws Exception {
List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
// zero items: check both using a list and using an array
@@ -667,7 +669,7 @@ public class OperationPartialTest {
}
@Test
- public void testAttachFutures() throws Exception {
+ void testAttachFutures() throws Exception {
List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
// third task throws an exception during construction
@@ -690,7 +692,7 @@ public class OperationPartialTest {
}
@Test
- public void testCombineOutcomes() throws Exception {
+ void testCombineOutcomes() throws Exception {
// only one outcome
verifyOutcomes(0, OperationResult.SUCCESS);
verifyOutcomes(0, OperationResult.FAILURE_EXCEPTION);
@@ -729,7 +731,7 @@ public class OperationPartialTest {
* Tests both flavors of sequence(), because one invokes the other.
*/
@Test
- public void testSequence() throws Exception {
+ void testSequence() throws Exception {
final OperationOutcome outcome = params.makeOutcome();
List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
@@ -770,7 +772,7 @@ public class OperationPartialTest {
*/
@Test
@SuppressWarnings("unchecked")
- public void testSequenceEdge() throws Exception {
+ void testSequenceEdge() throws Exception {
List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
// zero items: check both using a list and using an array
@@ -808,7 +810,7 @@ public class OperationPartialTest {
}
@Test
- public void testDetmPriority() throws CoderException {
+ void testDetmPriority() throws CoderException {
assertEquals(1, oper.detmPriority(null));
OperationOutcome outcome = params.makeOutcome();
@@ -819,7 +821,7 @@ public class OperationPartialTest {
for (Entry<OperationResult, Integer> ent : map.entrySet()) {
outcome.setResult(ent.getKey());
- assertEquals(ent.getKey().toString(), ent.getValue().intValue(), oper.detmPriority(outcome));
+ assertEquals(ent.getValue().intValue(), oper.detmPriority(outcome), ent.getKey().toString());
}
/*
@@ -834,7 +836,7 @@ public class OperationPartialTest {
* Tests callbackStarted() when the pipeline has already been stopped.
*/
@Test
- public void testCallbackStartedNotRunning() {
+ void testCallbackStartedNotRunning() {
AtomicReference<Future<OperationOutcome>> future = new AtomicReference<>();
/*
@@ -860,7 +862,7 @@ public class OperationPartialTest {
* Tests callbackCompleted() when the pipeline has already been stopped.
*/
@Test
- public void testCallbackCompletedNotRunning() {
+ void testCallbackCompletedNotRunning() {
AtomicReference<Future<OperationOutcome>> future = new AtomicReference<>();
// arrange to stop the controller when the start-callback is invoked
@@ -880,7 +882,7 @@ public class OperationPartialTest {
}
@Test
- public void testSetOutcomeControlLoopOperationOutcomeThrowable() {
+ void testSetOutcomeControlLoopOperationOutcomeThrowable() {
final CompletionException timex = new CompletionException(new TimeoutException(EXPECTED_EXCEPTION));
OperationOutcome outcome;
@@ -897,7 +899,7 @@ public class OperationPartialTest {
}
@Test
- public void testSetOutcomeControlLoopOperationOutcomePolicyResult() {
+ void testSetOutcomeControlLoopOperationOutcomePolicyResult() {
OperationOutcome outcome;
outcome = new OperationOutcome();
@@ -912,19 +914,19 @@ public class OperationPartialTest {
for (OperationResult result : FAILURE_RESULTS) {
outcome = new OperationOutcome();
oper.setOutcome(outcome, result);
- assertEquals(result.toString(), ControlLoopOperation.FAILED_MSG, outcome.getMessage());
- assertEquals(result.toString(), result, outcome.getResult());
+ assertEquals(ControlLoopOperation.FAILED_MSG, outcome.getMessage(), result.toString());
+ assertEquals(result, outcome.getResult(), result.toString());
}
}
@Test
- public void testMakeOutcome() {
+ void testMakeOutcome() {
oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, MY_TARGET_ENTITY);
assertEquals(MY_TARGET_ENTITY, oper.makeOutcome().getTarget());
}
@Test
- public void testIsTimeout() {
+ void testIsTimeout() {
final TimeoutException timex = new TimeoutException(EXPECTED_EXCEPTION);
assertFalse(oper.isTimeout(new IllegalStateException(EXPECTED_EXCEPTION)));
@@ -938,7 +940,7 @@ public class OperationPartialTest {
}
@Test
- public void testLogMessage() {
+ void testLogMessage() {
final String infraStr = SINK_INFRA.toString();
// log structured data
@@ -994,20 +996,20 @@ public class OperationPartialTest {
}
@Test
- public void testGetRetry() {
+ void testGetRetry() {
assertEquals(0, oper.getRetry(null));
assertEquals(10, oper.getRetry(10));
}
@Test
- public void testGetRetryWait() {
+ void testGetRetryWait() {
// need an operator that doesn't override the retry time
OperationPartial oper2 = new OperationPartial(params, config, Collections.emptyList()) {};
assertEquals(OperationPartial.DEFAULT_RETRY_WAIT_MS, oper2.getRetryWaitMs());
}
@Test
- public void testGetTimeOutMs() {
+ void testGetTimeOutMs() {
assertEquals(TIMEOUT * 1000, oper.getTimeoutMs(params.getTimeoutSec()));
params = params.toBuilder().timeoutSec(null).build();
@@ -1080,30 +1082,30 @@ public class OperationPartialTest {
manipulator.accept(future);
- assertTrue(testName, executor.runAll(MAX_REQUESTS));
+ assertTrue(executor.runAll(MAX_REQUESTS), testName);
- assertEquals(testName, expectedCallbacks, numStart);
- assertEquals(testName, expectedCallbacks, numEnd);
+ assertEquals(expectedCallbacks, numStart, testName);
+ assertEquals(expectedCallbacks, numEnd, testName);
if (expectedCallbacks > 0) {
- assertNotNull(testName, opstart);
- assertNotNull(testName, opend);
- assertEquals(testName, expectedResult, opend.getResult());
+ assertNotNull(opstart, testName);
+ assertNotNull(opend, testName);
+ assertEquals(expectedResult, opend.getResult(), testName);
- assertSame(testName, tstart, opstart.getStart());
- assertSame(testName, tstart, opend.getStart());
+ assertSame(tstart, opstart.getStart(), testName);
+ assertSame(tstart, opend.getStart(), testName);
try {
assertTrue(future.isDone());
- assertEquals(testName, opend, future.get());
+ assertEquals(opend, future.get(), testName);
// "start" is never final
for (OperationOutcome outcome : starts) {
- assertFalse(testName, outcome.isFinalOutcome());
+ assertFalse(outcome.isFinalOutcome(), testName);
}
// only the last "complete" is final
- assertTrue(testName, ends.removeLast().isFinalOutcome());
+ assertTrue(ends.removeLast().isFinalOutcome(), testName);
for (OperationOutcome outcome : ends) {
assertFalse(outcome.isFinalOutcome());
@@ -1115,12 +1117,12 @@ public class OperationPartialTest {
if (expectedOperations > 0) {
assertNotNull(testName, oper.getSubRequestId());
- assertEquals(testName + " op start", oper.getSubRequestId(), opstart.getSubRequestId());
- assertEquals(testName + " op end", oper.getSubRequestId(), opend.getSubRequestId());
+ assertEquals(oper.getSubRequestId(), opstart.getSubRequestId(), testName + " op start");
+ assertEquals(oper.getSubRequestId(), opend.getSubRequestId(), testName + " op end");
}
}
- assertEquals(testName, expectedOperations, oper.getCount());
+ assertEquals(expectedOperations, oper.getCount(), testName);
}
/**
@@ -1142,7 +1144,7 @@ public class OperationPartialTest {
@Getter
- public static class MyData {
+ static class MyData {
private String text = TEXT;
}
@@ -1159,7 +1161,7 @@ public class OperationPartialTest {
private CompletableFuture<OperationOutcome> preProc;
- public MyOper() {
+ MyOper() {
super(OperationPartialTest.this.params, config, PROP_NAMES);
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartialTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartialTest.java
index 370426fd4..20fe209fa 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartialTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartialTest.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,19 +21,19 @@
package org.onap.policy.controlloop.actorserviceprovider.impl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import java.util.Map;
import java.util.TreeMap;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-public class OperatorPartialTest {
+class OperatorPartialTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-name";
@@ -41,8 +42,8 @@ public class OperatorPartialTest {
/**
* Initializes {@link #operator}.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
operator = new OperatorPartial(ACTOR, OPERATION) {
@Override
public Operation buildOperation(ControlLoopOperationParams params) {
@@ -52,14 +53,14 @@ public class OperatorPartialTest {
}
@Test
- public void testOperatorPartial_testGetActorName_testGetName() {
+ void testOperatorPartial_testGetActorName_testGetName() {
assertEquals(ACTOR, operator.getActorName());
assertEquals(OPERATION, operator.getName());
assertEquals(ACTOR + "." + OPERATION, operator.getFullName());
}
@Test
- public void testDoStart() {
+ void testDoStart() {
operator.configure(null);
operator = spy(operator);
@@ -69,7 +70,7 @@ public class OperatorPartialTest {
}
@Test
- public void testDoStop() {
+ void testDoStop() {
operator.configure(null);
operator.start();
@@ -80,7 +81,7 @@ public class OperatorPartialTest {
}
@Test
- public void testDoShutdown() {
+ void testDoShutdown() {
operator.configure(null);
operator.start();
@@ -91,7 +92,7 @@ public class OperatorPartialTest {
}
@Test
- public void testDoConfigureMapOfStringObject() {
+ void testDoConfigureMapOfStringObject() {
operator = spy(operator);
Map<String, Object> params = new TreeMap<>();
@@ -101,7 +102,7 @@ public class OperatorPartialTest {
}
@Test
- public void testGetBlockingExecutor() {
+ void testGetBlockingExecutor() {
assertNotNull(operator.getBlockingExecutor());
}
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartialTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartialTest.java
index 7a822c1d9..209cb495f 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartialTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartialTest.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.
@@ -22,18 +23,18 @@ package org.onap.policy.controlloop.actorserviceprovider.impl;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class StartConfigPartialTest {
+class StartConfigPartialTest {
private static final IllegalArgumentException EXPECTED_EXCEPTION =
new IllegalArgumentException("expected exception");
private static final String MY_NAME = "my-name";
@@ -46,8 +47,8 @@ public class StartConfigPartialTest {
/**
* Creates a config whose doXxx() methods do nothing.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
config = new StartConfigPartial<>(MY_NAME) {
@Override
protected void doConfigure(String parameters) {
@@ -74,17 +75,17 @@ public class StartConfigPartialTest {
}
@Test
- public void testConfigImpl_testGetFullName() {
+ void testConfigImpl_testGetFullName() {
assertEquals(MY_NAME, config.getFullName());
}
@Test
- public void testIsAlive() {
+ void testIsAlive() {
assertFalse(config.isAlive());
}
@Test
- public void testIsConfigured_testConfigure() {
+ void testIsConfigured_testConfigure() {
// throw an exception during doConfigure(), but should remain unconfigured
assertFalse(config.isConfigured());
doThrow(EXPECTED_EXCEPTION).when(config).doConfigure(PARAMSX);
@@ -114,7 +115,7 @@ public class StartConfigPartialTest {
}
@Test
- public void testStart() {
+ void testStart() {
assertFalse(config.isAlive());
// can't start if not configured yet
@@ -147,7 +148,7 @@ public class StartConfigPartialTest {
}
@Test
- public void testStop() {
+ void testStop() {
config.configure(PARAMS);
// ok to stop if not running, but shouldn't invoke doStop()
@@ -179,7 +180,7 @@ public class StartConfigPartialTest {
}
@Test
- public void testShutdown() {
+ void testShutdown() {
config.configure(PARAMS);
// ok to shutdown if not running, but shouldn't invoke doShutdown()
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ActorParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ActorParamsTest.java
index 0304ef3be..3999ecf74 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ActorParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ActorParamsTest.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.
@@ -23,23 +24,23 @@ package org.onap.policy.controlloop.actorserviceprovider.parameters;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Consumer;
import java.util.function.Function;
import lombok.Setter;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-public class ActorParamsTest {
+class ActorParamsTest {
private static final String CONTAINER = "my-container";
@@ -58,8 +59,8 @@ public class ActorParamsTest {
* Initializes {@link #operations} with two items and {@link params} with a fully
* populated object.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
operations = new TreeMap<>();
operations.put(PATH1, Map.of("path", URI1));
operations.put(PATH2, Map.of("path", URI2, "text2", TEXT2B));
@@ -68,7 +69,7 @@ public class ActorParamsTest {
}
@Test
- public void testMakeOperationParameters() {
+ void testMakeOperationParameters() {
Function<String, Map<String, Object>> maker = params.makeOperationParameters(CONTAINER);
assertNull(maker.apply("unknown-operation"));
@@ -82,7 +83,7 @@ public class ActorParamsTest {
}
@Test
- public void testDoValidation() {
+ void testDoValidation() {
assertThatCode(() -> params.doValidation(CONTAINER)).doesNotThrowAnyException();
// invalid param
@@ -92,7 +93,7 @@ public class ActorParamsTest {
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
// only a few fields are required
@@ -108,13 +109,13 @@ public class ActorParamsTest {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
+ assertTrue(result.isValid(), fieldName);
// make invalid params
ActorParams params2 = makeActorParams();
makeInvalid.accept(params2);
result = params2.validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
+ assertFalse(result.isValid(), fieldName);
assertThat(result.getResult()).contains(CONTAINER).contains(fieldName).contains(expected);
}
@@ -128,7 +129,7 @@ public class ActorParamsTest {
}
@Setter
- public static class MyParams extends ActorParams {
+ static class MyParams extends ActorParams {
@SuppressWarnings("unused")
private String text1;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParamsTest.java
index 769e0fca5..5c8b659fa 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParamsTest.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.
@@ -21,18 +22,18 @@
package org.onap.policy.controlloop.actorserviceprovider.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-public class BidirectionalTopicActorParamsTest {
+class BidirectionalTopicActorParamsTest {
private static final String CONTAINER = "my-container";
private static final String DFLT_SOURCE = "default-source";
@@ -58,8 +59,8 @@ public class BidirectionalTopicActorParamsTest {
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
BidirectionalTopicParams oper1 = BidirectionalTopicParams.builder().sourceTopic(OPER1_SOURCE)
.sinkTopic(OPER1_SINK).timeoutSec(OPER1_TIMEOUT).build();
@@ -72,7 +73,7 @@ public class BidirectionalTopicActorParamsTest {
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
// only a few fields are required
@@ -97,13 +98,13 @@ public class BidirectionalTopicActorParamsTest {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
+ assertTrue(result.isValid(), fieldName);
// make invalid params
BidirectionalTopicActorParams params2 = makeBidirectionalTopicActorParams();
makeInvalid.accept(params2);
result = params2.validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
+ assertFalse(result.isValid(), fieldName);
assertThat(result.getResult()).contains(CONTAINER).contains(fieldName).contains(expected);
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicConfigTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicConfigTest.java
index 7b44333f9..8f833b700 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicConfigTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicConfigTest.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,25 +21,27 @@
package org.onap.policy.controlloop.actorserviceprovider.parameters;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executor;
-import org.junit.Before;
-import org.junit.Test;
+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;
import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder;
import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey;
-@RunWith(MockitoJUnitRunner.class)
-public class BidirectionalTopicConfigTest {
+@ExtendWith(MockitoExtension.class)
+class BidirectionalTopicConfigTest {
private static final String MY_SINK = "my-sink";
private static final String MY_SOURCE = "my-source";
private static final int TIMEOUT_SEC = 10;
@@ -57,8 +60,8 @@ public class BidirectionalTopicConfigTest {
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
List<SelectorKey> keys = Arrays.asList(new SelectorKey(""));
when(topicManager.getTopicHandler(MY_SINK, MY_SOURCE)).thenReturn(topicHandler);
@@ -70,7 +73,7 @@ public class BidirectionalTopicConfigTest {
}
@Test
- public void test() {
+ void test() {
assertSame(executor, config.getBlockingExecutor());
assertSame(topicHandler, config.getTopicHandler());
assertSame(forwarder, config.getForwarder());
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParamsTest.java
index 0ec0bb57c..99915ac1a 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParamsTest.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.
@@ -21,17 +22,17 @@
package org.onap.policy.controlloop.actorserviceprovider.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.function.Function;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams.BidirectionalTopicParamsBuilder;
-public class BidirectionalTopicParamsTest {
+class BidirectionalTopicParamsTest {
private static final String CONTAINER = "my-container";
private static final String SINK = "my-sink";
@@ -40,13 +41,13 @@ public class BidirectionalTopicParamsTest {
private BidirectionalTopicParams params;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
params = BidirectionalTopicParams.builder().sinkTopic(SINK).sourceTopic(SOURCE).timeoutSec(TIMEOUT).build();
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
testValidateField("sink", "null", bldr -> bldr.sinkTopic(null));
@@ -59,7 +60,7 @@ public class BidirectionalTopicParamsTest {
}
@Test
- public void testBuilder_testToBuilder() {
+ void testBuilder_testToBuilder() {
assertEquals(SINK, params.getSinkTopic());
assertEquals(SOURCE, params.getSourceTopic());
assertEquals(TIMEOUT, params.getTimeoutSec());
@@ -75,11 +76,11 @@ public class BidirectionalTopicParamsTest {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
+ assertTrue(result.isValid(), fieldName);
// make invalid params
result = makeInvalid.apply(params.toBuilder()).build().validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
+ assertFalse(result.isValid(), fieldName);
assertThat(result.getResult()).contains(fieldName).contains(expected);
}
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParamsTest.java
index bdf6b307a..55597611f 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParamsTest.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.
@@ -22,18 +23,17 @@ package org.onap.policy.controlloop.actorserviceprovider.parameters;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
import java.util.Map;
import java.util.TreeMap;
@@ -44,11 +44,13 @@ import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Function;
-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.TestInstance;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.ActorService;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
@@ -57,8 +59,9 @@ import org.onap.policy.controlloop.actorserviceprovider.Operator;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams.ControlLoopOperationParamsBuilder;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
-@RunWith(MockitoJUnitRunner.class)
-public class ControlLoopOperationParamsTest {
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@ExtendWith(MockitoExtension.class)
+class ControlLoopOperationParamsTest {
private static final String NULL_MSG = "null";
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String ACTOR = "my-actor";
@@ -100,12 +103,12 @@ public class ControlLoopOperationParamsTest {
/**
* Initializes mocks and sets {@link #params} to a fully-loaded set of parameters.
*/
- @Before
- public void setUp() {
- when(actorService.getActor(ACTOR)).thenReturn(actor);
- when(actor.getOperator(OPERATION)).thenReturn(operator);
- when(operator.buildOperation(any())).thenReturn(operation);
- when(operation.start()).thenReturn(operFuture);
+ @BeforeEach
+ void setUp() {
+ Mockito.lenient().when(actorService.getActor(ACTOR)).thenReturn(actor);
+ Mockito.lenient().when(actor.getOperator(OPERATION)).thenReturn(operator);
+ Mockito.lenient().when(operator.buildOperation(any())).thenReturn(operation);
+ Mockito.lenient().when(operation.start()).thenReturn(operFuture);
payload = new TreeMap<>();
@@ -118,26 +121,26 @@ public class ControlLoopOperationParamsTest {
}
@Test
- public void testStart() {
+ void testStart() {
assertThatIllegalArgumentException().isThrownBy(() -> params.toBuilder().requestId(null).build().start());
assertSame(operFuture, params.start());
}
@Test
- public void testBuild() {
+ void testBuild() {
assertThatIllegalArgumentException().isThrownBy(() -> params.toBuilder().requestId(null).build().build());
assertSame(operation, params.build());
}
@Test
- public void testGetRequestId() {
+ void testGetRequestId() {
assertSame(REQ_ID, params.getRequestId());
}
@Test
- public void testMakeOutcome() {
+ void testMakeOutcome() {
assertEquals(ACTOR, outcome.getActor());
assertEquals(OPERATION, outcome.getOperation());
assertNull(outcome.getStart());
@@ -148,7 +151,7 @@ public class ControlLoopOperationParamsTest {
}
@Test
- public void testCallbackStarted() {
+ void testCallbackStarted() {
params.callbackStarted(outcome);
verify(starter).accept(outcome);
@@ -173,7 +176,7 @@ public class ControlLoopOperationParamsTest {
}
@Test
- public void testCallbackCompleted() {
+ void testCallbackCompleted() {
params.callbackCompleted(outcome);
verify(completer).accept(outcome);
@@ -198,7 +201,7 @@ public class ControlLoopOperationParamsTest {
}
@Test
- public void testValidateFields() {
+ void testValidateFields() {
testValidate("actor", NULL_MSG, bldr -> bldr.actor(null));
testValidate("actorService", NULL_MSG, bldr -> bldr.actorService(null));
testValidate("executor", NULL_MSG, bldr -> bldr.executor(null));
@@ -226,31 +229,31 @@ public class ControlLoopOperationParamsTest {
// original params should be valid
BeanValidationResult result = params.validate();
- assertTrue(fieldName, result.isValid());
+ assertTrue(result.isValid(), fieldName);
// make invalid params
result = makeInvalid.apply(params.toBuilder()).build().validate();
- assertFalse(fieldName, result.isValid());
+ assertFalse(result.isValid(), fieldName);
assertThat(result.getResult()).contains(fieldName).contains(expected);
}
@Test
- public void testBuilder_testToBuilder() {
+ void testBuilder_testToBuilder() {
assertEquals(params, params.toBuilder().build());
}
@Test
- public void testGetActor() {
+ void testGetActor() {
assertSame(ACTOR, params.getActor());
}
@Test
- public void testGetActorService() {
+ void testGetActorService() {
assertSame(actorService, params.getActorService());
}
@Test
- public void testGetExecutor() {
+ void testGetExecutor() {
assertSame(executor, params.getExecutor());
// should use default when unspecified
@@ -258,12 +261,12 @@ public class ControlLoopOperationParamsTest {
}
@Test
- public void testGetOperation() {
+ void testGetOperation() {
assertSame(OPERATION, params.getOperation());
}
@Test
- public void testGetPayload() {
+ void testGetPayload() {
assertSame(payload, params.getPayload());
// should be null when unspecified
@@ -271,7 +274,7 @@ public class ControlLoopOperationParamsTest {
}
@Test
- public void testGetRetry() {
+ void testGetRetry() {
assertSame(RETRY, params.getRetry());
// should be null when unspecified
@@ -279,7 +282,7 @@ public class ControlLoopOperationParamsTest {
}
@Test
- public void testGetTimeoutSec() {
+ void testGetTimeoutSec() {
assertSame(TIMEOUT, params.getTimeoutSec());
// should be 300 when unspecified
@@ -290,12 +293,12 @@ public class ControlLoopOperationParamsTest {
}
@Test
- public void testGetStartCallback() {
+ void testGetStartCallback() {
assertSame(starter, params.getStartCallback());
}
@Test
- public void testGetCompleteCallback() {
+ void testGetCompleteCallback() {
assertSame(completer, params.getCompleteCallback());
}
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParamsTest.java
index 5812b0437..3e460bac3 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParamsTest.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.
@@ -21,18 +22,18 @@
package org.onap.policy.controlloop.actorserviceprovider.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Consumer;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-public class HttpActorParamsTest {
+class HttpActorParamsTest {
private static final String CONTAINER = "my-container";
private static final String CLIENT = "my-client";
@@ -50,8 +51,8 @@ public class HttpActorParamsTest {
* Initializes {@link #operations} with two items and {@link params} with a fully
* populated object.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
operations = new TreeMap<>();
operations.put(PATH1, Map.of("path", URI1));
operations.put(PATH2, Map.of("path", URI2));
@@ -60,7 +61,7 @@ public class HttpActorParamsTest {
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
// only a few fields are required
@@ -83,13 +84,13 @@ public class HttpActorParamsTest {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
+ assertTrue(result.isValid(), fieldName);
// make invalid params
HttpActorParams params2 = makeHttpActorParams();
makeInvalid.accept(params2);
result = params2.validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
+ assertFalse(result.isValid(), fieldName);
assertThat(result.getResult()).contains(CONTAINER).contains(fieldName).contains(expected);
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpConfigTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpConfigTest.java
index 181e0ba67..e43cd8c62 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpConfigTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpConfigTest.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,21 +21,21 @@
package org.onap.policy.controlloop.actorserviceprovider.parameters;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.when;
import java.util.concurrent.Executor;
-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.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
-@RunWith(MockitoJUnitRunner.class)
-public class HttpConfigTest {
+@ExtendWith(MockitoExtension.class)
+class HttpConfigTest {
private static final String MY_CLIENT = "my-client";
private static final String MY_PATH = "my-path";
private static final int TIMEOUT_SEC = 10;
@@ -51,8 +52,8 @@ public class HttpConfigTest {
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
when(factory.get(MY_CLIENT)).thenReturn(client);
HttpParams params = HttpParams.builder().clientName(MY_CLIENT).path(MY_PATH).timeoutSec(TIMEOUT_SEC).build();
@@ -60,7 +61,7 @@ public class HttpConfigTest {
}
@Test
- public void test() {
+ void test() {
assertSame(executor, config.getBlockingExecutor());
assertSame(client, config.getClient());
assertEquals(MY_PATH, config.getPath());
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParamsTest.java
index f4c6a2089..f0611a79b 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParamsTest.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.
@@ -21,17 +22,17 @@
package org.onap.policy.controlloop.actorserviceprovider.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.function.Function;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams.HttpParamsBuilder;
-public class HttpParamsTest {
+class HttpParamsTest {
private static final String CONTAINER = "my-container";
private static final String CLIENT = "my-client";
@@ -40,13 +41,13 @@ public class HttpParamsTest {
private HttpParams params;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
params = HttpParams.builder().clientName(CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
testValidateField("clientName", "null", bldr -> bldr.clientName(null));
@@ -63,7 +64,7 @@ public class HttpParamsTest {
}
@Test
- public void testBuilder_testToBuilder() {
+ void testBuilder_testToBuilder() {
assertEquals(CLIENT, params.getClientName());
assertEquals(PATH, params.getPath());
assertEquals(TIMEOUT, params.getTimeoutSec());
@@ -76,11 +77,11 @@ public class HttpParamsTest {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
+ assertTrue(result.isValid(), fieldName);
// make invalid params
result = makeInvalid.apply(params.toBuilder()).build().validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
+ assertFalse(result.isValid(), fieldName);
assertThat(result.getResult()).contains(fieldName).contains(expected);
}
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingActorParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingActorParamsTest.java
index 3202c2e54..f59887b91 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingActorParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingActorParamsTest.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.
@@ -21,19 +22,19 @@
package org.onap.policy.controlloop.actorserviceprovider.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Consumer;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-public class HttpPollingActorParamsTest {
+class HttpPollingActorParamsTest {
private static final String CONTAINER = "my-container";
private static final String CLIENT = "my-client";
private static final String POLL_PATH = "my-poll-path";
@@ -53,8 +54,8 @@ public class HttpPollingActorParamsTest {
* Initializes {@link #operations} with two items and {@link params} with a fully
* populated object.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
operations = new TreeMap<>();
operations.put(PATH1, Map.of("path", URI1));
operations.put(PATH2, Map.of("path", URI2));
@@ -63,7 +64,7 @@ public class HttpPollingActorParamsTest {
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
// only a few fields are required
@@ -92,13 +93,13 @@ public class HttpPollingActorParamsTest {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
+ assertTrue(result.isValid(), fieldName);
// make invalid params
HttpPollingActorParams params2 = makeHttpPollingActorParams();
makeInvalid.accept(params2);
result = params2.validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
+ assertFalse(result.isValid(), fieldName);
assertThat(result.getResult()).contains(CONTAINER).contains(fieldName).contains(expected);
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingConfigTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingConfigTest.java
index 65fd308fe..0fcf39ed4 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingConfigTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingConfigTest.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,21 +21,21 @@
package org.onap.policy.controlloop.actorserviceprovider.parameters;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.when;
import java.util.concurrent.Executor;
-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.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
-@RunWith(MockitoJUnitRunner.class)
-public class HttpPollingConfigTest {
+@ExtendWith(MockitoExtension.class)
+class HttpPollingConfigTest {
private static final String MY_CLIENT = "my-client";
private static final String MY_PATH = "my-path";
private static final String POLL_PATH = "poll-path";
@@ -55,8 +56,8 @@ public class HttpPollingConfigTest {
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
when(factory.get(MY_CLIENT)).thenReturn(client);
params = HttpPollingParams.builder().maxPolls(MAX_POLLS).pollPath(POLL_PATH).pollWaitSec(WAIT_SEC)
@@ -65,7 +66,7 @@ public class HttpPollingConfigTest {
}
@Test
- public void test() {
+ void test() {
assertEquals(POLL_PATH + "/", config.getPollPath());
assertEquals(MAX_POLLS, config.getMaxPolls());
assertEquals(WAIT_SEC, config.getPollWaitSec());
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingParamsTest.java
index 42a8717bd..6131dea04 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingParamsTest.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.
@@ -21,17 +22,17 @@
package org.onap.policy.controlloop.actorserviceprovider.parameters;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.function.Function;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams.HttpPollingParamsBuilder;
-public class HttpPollingParamsTest {
+class HttpPollingParamsTest {
private static final String CONTAINER = "my-container";
private static final String CLIENT = "my-client";
private static final String PATH = "my-path";
@@ -42,14 +43,14 @@ public class HttpPollingParamsTest {
private HttpPollingParams params;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
params = HttpPollingParams.builder().pollPath(POLL_PATH).maxPolls(MAX_POLLS).pollWaitSec(POLL_WAIT_SEC)
.clientName(CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
testValidateField("pollPath", "null", bldr -> bldr.pollPath(null));
@@ -66,7 +67,7 @@ public class HttpPollingParamsTest {
}
@Test
- public void testBuilder_testToBuilder() {
+ void testBuilder_testToBuilder() {
assertEquals(CLIENT, params.getClientName());
assertEquals(POLL_PATH, params.getPollPath());
@@ -81,11 +82,11 @@ public class HttpPollingParamsTest {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
+ assertTrue(result.isValid(), fieldName);
// make invalid params
result = makeInvalid.apply(params.toBuilder()).build().validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
+ assertFalse(result.isValid(), fieldName);
assertThat(result.getResult()).contains(fieldName).contains(expected);
}
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ParameterValidationRuntimeExceptionTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ParameterValidationRuntimeExceptionTest.java
index 328e4facb..dca27fb15 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ParameterValidationRuntimeExceptionTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ParameterValidationRuntimeExceptionTest.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,44 +21,44 @@
package org.onap.policy.controlloop.actorserviceprovider.parameters;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
-public class ParameterValidationRuntimeExceptionTest {
+class ParameterValidationRuntimeExceptionTest {
private static final String THE_MESSAGE = "the message";
private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
private ValidationResult result;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
result = new ObjectValidationResult("param", null, ValidationStatus.INVALID, "null");
}
@Test
- public void testParameterValidationExceptionValidationResult() {
+ void testParameterValidationExceptionValidationResult() {
ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(result);
assertSame(result, ex.getResult());
assertNull(ex.getMessage());
}
@Test
- public void testParameterValidationExceptionValidationResultString() {
+ void testParameterValidationExceptionValidationResultString() {
ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(THE_MESSAGE, result);
assertSame(result, ex.getResult());
assertEquals(THE_MESSAGE, ex.getMessage());
}
@Test
- public void testParameterValidationExceptionValidationResultThrowable() {
+ void testParameterValidationExceptionValidationResultThrowable() {
ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(EXPECTED_EXCEPTION, result);
assertSame(result, ex.getResult());
assertEquals(EXPECTED_EXCEPTION.toString(), ex.getMessage());
@@ -65,7 +66,7 @@ public class ParameterValidationRuntimeExceptionTest {
}
@Test
- public void testParameterValidationExceptionValidationResultStringThrowable() {
+ void testParameterValidationExceptionValidationResultStringThrowable() {
ParameterValidationRuntimeException ex =
new ParameterValidationRuntimeException(THE_MESSAGE, EXPECTED_EXCEPTION, result);
assertSame(result, ex.getResult());
@@ -74,7 +75,7 @@ public class ParameterValidationRuntimeExceptionTest {
}
@Test
- public void testGetResult() {
+ void testGetResult() {
ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(result);
assertSame(result, ex.getResult());
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/FutureManagerTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/FutureManagerTest.java
index eff3dbb18..f97ff9ac1 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/FutureManagerTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/FutureManagerTest.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,22 +21,24 @@
package org.onap.policy.controlloop.actorserviceprovider.pipeline;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.concurrent.Future;
-import org.junit.Before;
-import org.junit.Test;
+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;
-@RunWith(MockitoJUnitRunner.class)
-public class FutureManagerTest {
+@ExtendWith(MockitoExtension.class)
+class FutureManagerTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
@@ -53,13 +56,13 @@ public class FutureManagerTest {
/**
* Initializes fields, including {@link #mgr}.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
mgr = new FutureManager();
}
@Test
- public void testStop() {
+ void testStop() {
mgr.add(future1);
mgr.add(future2);
mgr.add(future3);
@@ -96,7 +99,7 @@ public class FutureManagerTest {
}
@Test
- public void testAdd() {
+ void testAdd() {
// still running - this should not be invoked
mgr.add(future1);
verify(future1, never()).cancel(anyBoolean());
@@ -119,7 +122,7 @@ public class FutureManagerTest {
}
@Test
- public void testRemove() {
+ void testRemove() {
mgr.add(future1);
mgr.add(future2);
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/ListenerManagerTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/ListenerManagerTest.java
index bbd82cbd1..882a8b0f8 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/ListenerManagerTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/ListenerManagerTest.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.controlloop.actorserviceprovider.pipeline;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doThrow;
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;
-@RunWith(MockitoJUnitRunner.class)
-public class ListenerManagerTest {
+@ExtendWith(MockitoExtension.class)
+class ListenerManagerTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
@@ -51,13 +52,13 @@ public class ListenerManagerTest {
/**
* Initializes fields, including {@link #mgr}.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
mgr = new ListenerManager();
}
@Test
- public void testStop_testIsRunning() {
+ void testStop_testIsRunning() {
mgr.add(runnable1);
mgr.add(runnable2);
mgr.add(runnable3);
@@ -92,7 +93,7 @@ public class ListenerManagerTest {
}
@Test
- public void testAdd() {
+ void testAdd() {
// still running - this should not be invoked
mgr.add(runnable1);
verify(runnable1, never()).run();
@@ -111,7 +112,7 @@ public class ListenerManagerTest {
}
@Test
- public void testRemove() {
+ void testRemove() {
mgr.add(runnable1);
mgr.add(runnable2);
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java
index 44c9e20af..c0d3a0df8 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.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,12 +22,12 @@
package org.onap.policy.controlloop.actorserviceprovider.pipeline;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -41,15 +42,15 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import java.util.function.Function;
-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;
-@RunWith(MockitoJUnitRunner.class)
-public class PipelineControllerFutureTest {
+@ExtendWith(MockitoExtension.class)
+class PipelineControllerFutureTest {
private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
private static final String TEXT = "some text";
@@ -77,8 +78,8 @@ public class PipelineControllerFutureTest {
* Initializes fields, including {@link #controller}. Adds all runners and futures to
* the controller.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
compFuture = spy(new CompletableFuture<>());
controller = new PipelineControllerFuture<>();
@@ -90,7 +91,7 @@ public class PipelineControllerFutureTest {
}
@Test
- public void testCancel_testAddFutureOfFBoolean_testAddRunnable__testIsRunning() {
+ void testCancel_testAddFutureOfFBoolean_testAddRunnable__testIsRunning() {
assertTrue(controller.isRunning());
assertTrue(controller.cancel(false));
@@ -110,7 +111,7 @@ public class PipelineControllerFutureTest {
}
@Test
- public void testCompleteT() throws Exception {
+ void testCompleteT() throws Exception {
assertTrue(controller.complete(TEXT));
assertEquals(TEXT, controller.get());
@@ -121,7 +122,7 @@ public class PipelineControllerFutureTest {
}
@Test
- public void testCompleteExceptionallyThrowable() {
+ void testCompleteExceptionallyThrowable() {
assertTrue(controller.completeExceptionally(EXPECTED_EXCEPTION));
assertThatThrownBy(() -> controller.get()).hasCause(EXPECTED_EXCEPTION);
@@ -132,7 +133,7 @@ public class PipelineControllerFutureTest {
}
@Test
- public void testCompleteAsyncSupplierOfQextendsTExecutor() throws Exception {
+ void testCompleteAsyncSupplierOfQextendsTExecutor() throws Exception {
CompletableFuture<String> future = controller.completeAsync(() -> TEXT, executor);
// haven't stopped anything yet
@@ -156,7 +157,7 @@ public class PipelineControllerFutureTest {
* Tests completeAsync(executor) when canceled before execution.
*/
@Test
- public void testCompleteAsyncSupplierOfQextendsTExecutorCanceled() throws Exception {
+ void testCompleteAsyncSupplierOfQextendsTExecutorCanceled() throws Exception {
CompletableFuture<String> future = controller.completeAsync(() -> TEXT, executor);
assertTrue(future.cancel(false));
@@ -169,7 +170,7 @@ public class PipelineControllerFutureTest {
}
@Test
- public void testCompleteAsyncSupplierOfQextendsT() throws Exception {
+ void testCompleteAsyncSupplierOfQextendsT() throws Exception {
CompletableFuture<String> future = controller.completeAsync(() -> TEXT);
assertEquals(TEXT, future.get());
@@ -180,7 +181,7 @@ public class PipelineControllerFutureTest {
* Tests completeAsync() when canceled.
*/
@Test
- public void testCompleteAsyncSupplierOfQextendsTCanceled() throws Exception {
+ void testCompleteAsyncSupplierOfQextendsTCanceled() throws Exception {
CountDownLatch canceled = new CountDownLatch(1);
// run async, but await until canceled
@@ -207,7 +208,7 @@ public class PipelineControllerFutureTest {
}
@Test
- public void testCompleteOnTimeoutTLongTimeUnit() throws Exception {
+ void testCompleteOnTimeoutTLongTimeUnit() throws Exception {
CountDownLatch stopped = new CountDownLatch(1);
controller.add(() -> stopped.countDown());
@@ -226,7 +227,7 @@ public class PipelineControllerFutureTest {
* Tests completeOnTimeout() when completed before the timeout.
*/
@Test
- public void testCompleteOnTimeoutTLongTimeUnitNoTimeout() throws Exception {
+ void testCompleteOnTimeoutTLongTimeUnitNoTimeout() throws Exception {
CompletableFuture<String> future = controller.completeOnTimeout("timed out", 5, TimeUnit.SECONDS);
controller.complete(TEXT);
@@ -239,7 +240,7 @@ public class PipelineControllerFutureTest {
* Tests completeOnTimeout() when canceled before the timeout.
*/
@Test
- public void testCompleteOnTimeoutTLongTimeUnitCanceled() {
+ void testCompleteOnTimeoutTLongTimeUnitCanceled() {
CompletableFuture<String> future = controller.completeOnTimeout(TEXT, 5, TimeUnit.SECONDS);
assertTrue(future.cancel(true));
@@ -249,7 +250,7 @@ public class PipelineControllerFutureTest {
}
@Test
- public void testNewIncompleteFuture() {
+ void testNewIncompleteFuture() {
PipelineControllerFuture<String> future = controller.newIncompleteFuture();
assertNotNull(future);
assertTrue(future instanceof PipelineControllerFuture);
@@ -258,7 +259,7 @@ public class PipelineControllerFutureTest {
}
@Test
- public void testDelayedComplete() throws Exception {
+ void testDelayedComplete() throws Exception {
controller.add(runnable1);
BiConsumer<String, Throwable> stopper = controller.delayedComplete();
@@ -287,7 +288,7 @@ public class PipelineControllerFutureTest {
* Tests delayedComplete() when an exception is generated.
*/
@Test
- public void testDelayedCompleteWithException() throws Exception {
+ void testDelayedCompleteWithException() throws Exception {
controller.add(runnable1);
BiConsumer<String, Throwable> stopper = controller.delayedComplete();
@@ -313,7 +314,7 @@ public class PipelineControllerFutureTest {
}
@Test
- public void testDelayedRemoveFutureOfF() throws Exception {
+ void testDelayedRemoveFutureOfF() throws Exception {
BiConsumer<String, Throwable> remover = controller.delayedRemove(future1);
remover.accept(TEXT, EXPECTED_EXCEPTION);
@@ -330,7 +331,7 @@ public class PipelineControllerFutureTest {
}
@Test
- public void testDelayedRemoveRunnable() throws Exception {
+ void testDelayedRemoveRunnable() throws Exception {
BiConsumer<String, Throwable> remover = controller.delayedRemove(runnable1);
remover.accept(TEXT, EXPECTED_EXCEPTION);
@@ -347,7 +348,7 @@ public class PipelineControllerFutureTest {
}
@Test
- public void testRemoveFutureOfF_testRemoveRunnable() {
+ void testRemoveFutureOfF_testRemoveRunnable() {
controller.remove(runnable2);
controller.remove(future1);
@@ -363,7 +364,7 @@ public class PipelineControllerFutureTest {
* Tests both wrap() methods.
*/
@Test
- public void testWrap() throws Exception {
+ void testWrap() throws Exception {
controller = spy(controller);
CompletableFuture<String> future = controller.wrap(compFuture);
@@ -379,7 +380,7 @@ public class PipelineControllerFutureTest {
* Tests wrap(), when the controller is not running.
*/
@Test
- public void testWrapNotRunning() throws Exception {
+ void testWrapNotRunning() throws Exception {
controller.cancel(false);
controller = spy(controller);
@@ -394,7 +395,7 @@ public class PipelineControllerFutureTest {
* Tests wrap(), when the future throws an exception.
*/
@Test
- public void testWrapException() throws Exception {
+ void testWrapException() throws Exception {
controller = spy(controller);
CompletableFuture<String> future = controller.wrap(compFuture);
@@ -407,7 +408,7 @@ public class PipelineControllerFutureTest {
}
@Test
- public void testWrapFunction() throws Exception {
+ void testWrapFunction() throws Exception {
Function<String, CompletableFuture<String>> func = controller.wrap(input -> {
compFuture.complete(input);
@@ -427,7 +428,7 @@ public class PipelineControllerFutureTest {
* Tests wrap(Function) when the controller is canceled after the future is added.
*/
@Test
- public void testWrapFunctionCancel() throws Exception {
+ void testWrapFunctionCancel() throws Exception {
Function<String, CompletableFuture<String>> func = controller.wrap(input -> compFuture);
CompletableFuture<String> future = func.apply(TEXT);
@@ -445,7 +446,7 @@ public class PipelineControllerFutureTest {
* Tests wrap(Function) when the controller is not running.
*/
@Test
- public void testWrapFunctionNotRunning() {
+ void testWrapFunctionNotRunning() {
AtomicReference<String> value = new AtomicReference<>();
Function<String, CompletableFuture<String>> func = controller.wrap(input -> {
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtilTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtilTest.java
index fbcacbf30..aef170ba7 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtilTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtilTest.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.
@@ -22,13 +23,13 @@ package org.onap.policy.controlloop.actorserviceprovider.pipeline;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-public class PipelineUtilTest {
+class PipelineUtilTest {
@Test
- public void testPipelineUtil() {
+ void testPipelineUtil() {
ControlLoopOperationParams params = ControlLoopOperationParams.builder().build();
PipelineUtil util = new PipelineUtil(params);
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java
index f96fc0fdc..862e6c49d 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.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,28 +22,30 @@
package org.onap.policy.controlloop.actorserviceprovider.topic;
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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Arrays;
-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.TestInstance;
+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.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException;
-@RunWith(MockitoJUnitRunner.class)
-public class BidirectionalTopicHandlerTest {
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@ExtendWith(MockitoExtension.class)
+class BidirectionalTopicHandlerTest {
private static final String UNKNOWN = "unknown";
private static final String MY_SOURCE = "my-source";
private static final String MY_SINK = "my-sink";
@@ -64,8 +67,8 @@ public class BidirectionalTopicHandlerTest {
/**
* Sets up.
*/
- @Before
- public void setUp() throws BidirectionalTopicClientException {
+ @BeforeEach
+ void setUp() throws BidirectionalTopicClientException {
when(mgr.getTopicSinks(MY_SINK)).thenReturn(Arrays.asList(publisher));
when(mgr.getTopicSources(Arrays.asList(MY_SOURCE))).thenReturn(Arrays.asList(subscriber));
@@ -77,7 +80,7 @@ public class BidirectionalTopicHandlerTest {
}
@Test
- public void testBidirectionalTopicHandler_testGetSource_testGetTarget() {
+ void testBidirectionalTopicHandler_testGetSource_testGetTarget() {
assertEquals(MY_SOURCE, handler.getSourceTopic());
assertEquals(MY_SINK, handler.getSinkTopic());
@@ -96,24 +99,24 @@ public class BidirectionalTopicHandlerTest {
}
@Test
- public void testShutdown() {
+ void testShutdown() {
handler.shutdown();
verify(subscriber).unregister(any());
}
@Test
- public void testStart() {
+ void testStart() {
verify(subscriber).register(any());
}
@Test
- public void testStop() {
+ void testStop() {
handler.stop();
verify(subscriber).unregister(any());
}
@Test
- public void testAddForwarder() {
+ void testAddForwarder() {
// array form
Forwarder forwarder = handler.addForwarder(new SelectorKey(KEY1), new SelectorKey(KEY2));
assertNotNull(forwarder);
@@ -123,7 +126,7 @@ public class BidirectionalTopicHandlerTest {
}
@Test
- public void testGetTopicEndpointManager() {
+ void testGetTopicEndpointManager() {
// setting "mgr" to null should cause it to use the superclass' method
mgr = null;
assertNotNull(handler.getTopicEndpointManager());
@@ -131,7 +134,7 @@ public class BidirectionalTopicHandlerTest {
private class MyTopicHandler extends BidirectionalTopicHandler {
- public MyTopicHandler(String sinkTopic, String sourceTopic) throws BidirectionalTopicClientException {
+ MyTopicHandler(String sinkTopic, String sourceTopic) throws BidirectionalTopicClientException {
super(sinkTopic, sourceTopic);
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/ForwarderTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/ForwarderTest.java
index 3b368e225..e050416f5 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/ForwarderTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/ForwarderTest.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.
@@ -30,16 +31,19 @@ import static org.mockito.Mockito.verify;
import java.util.Arrays;
import java.util.Map;
import java.util.function.BiConsumer;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+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.utils.coder.StandardCoderObject;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-@RunWith(MockitoJUnitRunner.class)
-public class ForwarderTest {
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@ExtendWith(MockitoExtension.class)
+class ForwarderTest {
private static final String TEXT = "some text";
private static final String KEY1 = "requestId";
@@ -75,8 +79,8 @@ public class ForwarderTest {
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
forwarder = new Forwarder(Arrays.asList(new SelectorKey(KEY1), new SelectorKey(KEY2, SUBKEY)));
forwarder.register(Arrays.asList(VALUEA_REQID, VALUEA_SUBREQID), listener1);
@@ -86,7 +90,7 @@ public class ForwarderTest {
}
@Test
- public void testRegister() {
+ void testRegister() {
// key size mismatches
assertThatIllegalArgumentException().isThrownBy(() -> forwarder.register(Arrays.asList(), listener1))
.withMessage("key/value mismatch");
@@ -96,7 +100,7 @@ public class ForwarderTest {
}
@Test
- public void testUnregister() {
+ void testUnregister() {
// remove listener1b
forwarder.unregister(Arrays.asList(VALUEA_REQID, VALUEA_SUBREQID), listener1b);
@@ -121,7 +125,7 @@ public class ForwarderTest {
}
@Test
- public void testOnMessage() {
+ void testOnMessage() {
StandardCoderObject sco = makeMessage(Map.of(KEY1, VALUEA_REQID, KEY2, Map.of(SUBKEY, VALUEA_SUBREQID)));
forwarder.onMessage(TEXT, sco);
@@ -166,7 +170,7 @@ public class ForwarderTest {
* Tests onMessage() when listener1 throws an exception.
*/
@Test
- public void testOnMessageListenerException1() {
+ void testOnMessageListenerException1() {
doThrow(new IllegalStateException("expected exception")).when(listener1).accept(any(), any());
StandardCoderObject sco = makeMessage(Map.of(KEY1, VALUEA_REQID, KEY2, Map.of(SUBKEY, VALUEA_SUBREQID)));
@@ -179,7 +183,7 @@ public class ForwarderTest {
* Tests onMessage() when listener1b throws an exception.
*/
@Test
- public void testOnMessageListenerException1b() {
+ void testOnMessageListenerException1b() {
doThrow(new IllegalStateException("expected exception")).when(listener1b).accept(any(), any());
StandardCoderObject sco = makeMessage(Map.of(KEY1, VALUEA_REQID, KEY2, Map.of(SUBKEY, VALUEA_SUBREQID)));
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/SelectorKeyTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/SelectorKeyTest.java
index 5ffcbf7dc..dd39a03c6 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/SelectorKeyTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/SelectorKeyTest.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,34 +21,34 @@
package org.onap.policy.controlloop.actorserviceprovider.topic;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.Map;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-public class SelectorKeyTest {
+class SelectorKeyTest {
private static final String FIELD1 = "map";
private static final String FIELD2 = "abc";
private static final String FIELDX = "abd";
private SelectorKey key;
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
key = new SelectorKey(FIELD1, FIELD2);
}
@Test
- public void testHashCode_testEquals() {
+ void testHashCode_testEquals() {
SelectorKey key2 = new SelectorKey(FIELD1, FIELD2);
assertEquals(key, key2);
assertEquals(key.hashCode(), key2.hashCode());
@@ -64,7 +65,7 @@ public class SelectorKeyTest {
}
@Test
- public void testExtractField() {
+ void testExtractField() {
Map<String, Object> map = Map.of("hello", "world", FIELD1, Map.of("another", "", FIELD2, "value B"));
StandardCoderObject sco = Util.translate("", map, StandardCoderObject.class);
@@ -84,7 +85,7 @@ public class SelectorKeyTest {
}
@Test
- public void testToString() {
+ void testToString() {
assertEquals("[map, abc]", key.toString());
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImplTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImplTest.java
index 9e3b476e9..3044a1e44 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImplTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/TopicListenerImplTest.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,9 +21,9 @@
package org.onap.policy.controlloop.actorserviceprovider.topic;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
@@ -31,18 +32,20 @@ import static org.mockito.Mockito.verify;
import java.util.Arrays;
import java.util.Map;
import java.util.function.BiConsumer;
-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.TestInstance;
+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.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.StandardCoderObject;
-@RunWith(MockitoJUnitRunner.class)
-public class TopicListenerImplTest {
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@ExtendWith(MockitoExtension.class)
+class TopicListenerImplTest {
private static final StandardCoder coder = new StandardCoder();
private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
private static final String MY_TOPIC = "my-topic";
@@ -72,8 +75,8 @@ public class TopicListenerImplTest {
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
topic = new TopicListenerImpl();
forwarder1 = topic.addForwarder(new SelectorKey(KEY1));
@@ -89,7 +92,7 @@ public class TopicListenerImplTest {
}
@Test
- public void testShutdown() {
+ void testShutdown() {
// shut it down, which should clear all forwarders
topic.shutdown();
@@ -103,13 +106,13 @@ public class TopicListenerImplTest {
}
@Test
- public void testAddForwarder() {
+ void testAddForwarder() {
assertSame(forwarder1, topic.addForwarder(new SelectorKey(KEY1)));
assertSame(forwarder2, topic.addForwarder(new SelectorKey(KEY1), new SelectorKey(KEY2, SUBKEY)));
}
@Test
- public void testOnTopicEvent() {
+ void testOnTopicEvent() {
/*
* send a message that should go to listener1 on forwarder1 and listener2 on
* forwarder2