aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.aai/src/test
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/model-actors/actor.aai/src/test
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/model-actors/actor.aai/src/test')
-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
7 files changed, 124 insertions, 118 deletions
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;