* 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.
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());
}
@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
* 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.
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());
* 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.
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;
/**
* Initializes mocks and sets up.
*/
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUpBasic();
response = new PciMessage();
status.setValue(StatusCodeEnum.SUCCESS.toString());
}
- public void tearDown() {
+ void tearDown() {
super.tearDownBasic();
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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
* 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.
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;
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;
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);
* 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());
}
@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));
}
@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));
}
@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 {
* 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.
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;
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);
}
@Test
- public void testAddHeaders() {
+ void testAddHeaders() {
Builder bldr = mock(Builder.class);
oper.addHeaders(bldr, Map.of("hdrA", "valA", "hdrB", "valB"));
}
@Test
- public void testGetRetry() {
+ void testGetRetry() {
// use default if null retry
assertEquals(AaiGetOperation.DEFAULT_RETRY, oper.getRetry(null));
}
@Test
- public void testMakeHeaders() {
+ void testMakeHeaders() {
verifyHeaders(oper.makeHeaders());
}
}
* 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.
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;
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;
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));
}
* 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());
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());
@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);
*/
@Test
@SuppressWarnings("unchecked")
- public void testStartOperationAsyncFailure() throws Exception {
+ void testStartOperationAsyncFailure() throws Exception {
when(rawResponse.getStatus()).thenReturn(500);
when(rawResponse.readEntity(String.class)).thenReturn("");
* 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);
}
@Test
- public void testGetKey() {
+ void testGetKey() {
assertEquals("AAI.Pnf." + TARGET_ENTITY, AaiGetPnfOperation.getKey(TARGET_ENTITY));
}
}
* 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.
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;
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;
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));
}
* 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());
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());
@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);
*/
@Test
@SuppressWarnings("unchecked")
- public void testStartOperationAsyncFailure() throws Exception {
+ void testStartOperationAsyncFailure() throws Exception {
when(rawResponse.getStatus()).thenReturn(500);
when(rawResponse.readEntity(String.class)).thenReturn("");
* 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);
}
@Test
- public void testGetKey() {
+ void testGetKey() {
assertEquals("AAI.Tenant." + TARGET_ENTITY, AaiGetTenantOperation.getKey(TARGET_ENTITY));
}
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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);
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
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());
}
@Test
- public void testActorService() {
+ void testActorService() {
// verify that it all plugs into the ActorService
verifyActorService(AppcActor.NAME, "service.yaml");
}
* 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.
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;
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);
}
@Test
- public void testConvertPayload() {
+ void testConvertPayload() {
Request request = oper.makeRequest(genvnf);
// @formatter:off
}
@Test
- public void testGetExpectedKeyValues() {
+ void testGetExpectedKeyValues() {
oper.generateSubRequestId(2);
Request request = oper.makeRequest(genvnf);
assertEquals(Arrays.asList(request.getCommonHeader().getSubRequestId()),
}
@Test
- public void testDetmStatusStringResponse() {
+ void testDetmStatusStringResponse() {
final ResponseStatus status = response.getStatus();
// null status (i.e., it's a Request, not a Response)
}
@Test
- public void testSetOutcome() {
+ void testSetOutcome() {
final ResponseStatus status = response.getStatus();
// null status
private class MyOper extends AppcOperation {
- public MyOper(ControlLoopOperationParams params, BidirectionalTopicConfig config) {
+ MyOper(ControlLoopOperationParams params, BidirectionalTopicConfig config) {
super(params, config, Collections.emptyList());
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
/**
* Initializes mocks and sets up.
*/
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUpBasic();
response = new Response();
genvnf.setVnfId(MY_VNF);
}
- public void tearDown() {
+ void tearDown() {
super.tearDownBasic();
}
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();
}
* 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);
}
@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);
* 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.
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());
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;
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";
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();
oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, TARGET_ENTITY);
}
- @After
- public void tearDown() {
+ @AfterEach
+ void tearDown() {
super.tearDownBasic();
}
* 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);
}
@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);
* 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);
}
@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);
}
@Test
- public void testGetExpectedKeyValues() {
+ void testGetExpectedKeyValues() {
oper.generateSubRequestId(2);
AppcLcmMessageWrapper request = oper.makeRequest(2);
assertEquals(List.of(request.getBody().getInput().getCommonHeader().getSubRequestId()),
}
@Test
- public void testDetmStatus() {
+ void testDetmStatus() {
assertEquals(Status.SUCCESS, oper.detmStatus(null, response));
// failure
}
@Test
- public void testSetOutcome() {
+ void testSetOutcome() {
oper.setOutcome(outcome, OperationResult.SUCCESS, response);
assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertEquals(MY_MESSAGE, outcome.getMessage());
}
@Test
- public void testGetStatus() {
+ void testGetStatus() {
assertNotNull(oper.getStatus(response));
// null status
}
@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
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
*
* ================================================================================
* 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.
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";
}
@Test
- public void testShouldReturnCapitalizedBodySingleWordRecipe() {
+ void testShouldReturnCapitalizedBodySingleWordRecipe() {
// given
AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("moDify");
String expectedRecipe = "Modify";
}
@Test
- public void testShouldReturnCapitalizeAndJoinedBodyMultiWordRecipe() {
+ void testShouldReturnCapitalizeAndJoinedBodyMultiWordRecipe() {
// given
AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("coNfig-moDify");
String expectedRecipe = "ConfigModify";
}
@Test
- public void testShouldReturnLowercasedUrlSingleWordRecipe() {
+ void testShouldReturnLowercasedUrlSingleWordRecipe() {
// given
AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("ModIfy");
String expectedRecipe = "modify";
}
@Test
- public void testShouldReturnLowercasedDashJoinedUrlMultiWordRecipe() {
+ void testShouldReturnLowercasedDashJoinedUrlMultiWordRecipe() {
// given
AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("Config-MoDify");
String expectedRecipe = "config-modify";
/*-
* ============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");
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
* ============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.
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;
/**
* 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();
}
@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();
}
@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();
}
@Test
- public void testOnError() throws InterruptedException, ExecutionException, TimeoutException {
+ void testOnError() throws InterruptedException, ExecutionException, TimeoutException {
Exception exception = new Exception("something failed");
manager.onError(exception);
* ============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.
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;
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;
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";
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");
* 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")
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
*/
}
@Test
- public void testGetServiceInstanceId() {
+ void testGetServiceInstanceId() {
params = params.toBuilder().targetType(TargetType.VNF).targetEntityIds(targetEntityIds).build();
operation = new GrpcOperation(params, config);
loadVnfData();
}
@Test
- public void testGetVnfId() {
+ void testGetVnfId() {
params = params.toBuilder().targetType(TargetType.VNF).targetEntityIds(targetEntityIds).build();
operation = new GrpcOperation(params, config);
loadVnfData();
}
@Test
- public void testStartOperationAsync() {
+ void testStartOperationAsync() {
ControlLoopOperationParams clop =
ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
.operation(GrpcOperation.NAME)
* 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)
}
@Test
- public void testStartOperationAsyncError() {
+ void testStartOperationAsyncError() {
operation = new GrpcOperation(params, config);
assertThatIllegalArgumentException()
.isThrownBy(() -> operation.startOperationAsync(1, params.makeOutcome()));
* ============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.
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;
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;
/**
* 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();
}
@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());
@Test
- public void testDoConfigure() {
+ void testDoConfigure() {
operation.doConfigure(paramMap);
assertEquals(30000, operation.getCurrentConfig().getTimeoutMs());
}
@Test
- public void testBuildOperation() {
+ void testBuildOperation() {
ControlLoopOperationParams params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
.operation(GrpcOperation.NAME).requestId(UUID.randomUUID()).build();
/*-
* ============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.
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;
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)
/*-
* ============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.
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;
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)
/*-
* ============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.
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());
/*-
* ============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.
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;
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)
/*-
* ============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.
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();
/**
* Setup the CdsActionRequest object.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
req.setActionName(TEST_ACTION_NAME);
req.setResolutionKey("1234567890");
}
@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);
}
@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);
}
@Test
- public void testGenerateCdsPayloadWhenPolicyPayloadIsNull() throws CoderException {
+ void testGenerateCdsPayloadWhenPolicyPayloadIsNull() throws CoderException {
Map<String, String> payloadProps = new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
{
* 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.
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;
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";
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();
}
* 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(
* 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());
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);
*/
@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);
}
@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);
}
@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);
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
/**
* 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.
*/
/**
* Constructs the object using a default actor and operation name.
*/
- public BasicSdncOperation() {
+ BasicSdncOperation() {
super();
}
* @param actor actor name
* @param operation operation name
*/
- public BasicSdncOperation(String actor, String operation) {
+ BasicSdncOperation(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 SdncResponse();
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));
}
/**
* 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.
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;
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();
}
* Set up.
*/
@Override
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUp();
oper = new RerouteOperation(params, config);
}
* 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());
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(
}
@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);
* ================================================================================
* 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.
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
* 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.
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";
* Sets up.
*/
@Override
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUp();
request = new SdncRequest();
}
@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));
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
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();
}
* @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();
status.setValue(StatusCodeEnum.SUCCESS.toString());
}
- public void tearDown() {
+ void tearDown() {
super.tearDownBasic();
}
* @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);
* ================================================================================
* 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.
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());
}
@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
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;
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);
* Tests makeRequest() when a property is missing.
*/
@Test
- public void testMakeRequestMissingProperty() {
+ void testMakeRequestMissingProperty() {
operation = new SdnrOperation(params, config);
operation.generateSubRequestId(1);
}
@Test
- public void testGetExpectedKeyValues() {
+ void testGetExpectedKeyValues() {
operation.generateSubRequestId(1);
PciMessage request = operation.makeRequest(1);
* 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);
}
@Test
- public void testDetmStatusStringResponse() {
+ void testDetmStatusStringResponse() {
final org.onap.policy.sdnr.Status status = response.getBody().getOutput().getStatus();
// null status
}
@Test
- public void testSetOutcome() {
+ void testSetOutcome() {
// with a status value
checkOutcome();
assertEquals(StatusCodeEnum.SUCCESS.toString(), outcome.getMessage());
* 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.
/**
* 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;
/**
* Constructs the object using a default actor and operation name.
*/
- public BasicSoOperation() {
+ BasicSoOperation() {
super();
}
* @param actor actor name
* @param operation operation name
*/
- public BasicSoOperation(String actor, String operation) {
+ BasicSoOperation(String actor, String operation) {
super(actor, operation);
}
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);
/**
* Initializes mocks and sets up.
*/
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUpBasic();
response = new SoResponse();
* 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.
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;
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();
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(ModifyCll.NAME, oper.getName());
assertFalse(oper.isUsePolling());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.EVENT_PAYLOAD));
}
* 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())
* ================================================================================
* 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.
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;
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());
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());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.EVENT_PAYLOAD));
}
* 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())
* 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.
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;
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);
@Test
@SuppressWarnings("unchecked")
- public void testUnsupported() {
+ void testUnsupported() {
GenericType<String> generic = GenericType.forInstance(String.class);
assertThatThrownBy(() -> resp.hasEntity()).isInstanceOf(UnsupportedOperationException.class);
* ================================================================================
* 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");
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");
}
* ================================================================================
* 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.
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;
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;
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();
* Sets up.
*/
@Override
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUp();
initConfig();
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
assertSame(config, oper.getConfig());
}
@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);
}
@Test
- public void testGetRequestState() {
+ void testGetRequestState() {
SoResponse resp = new SoResponse();
assertNull(oper.getRequestState(resp));
}
@Test
- public void testIsSuccess() {
+ void testIsSuccess() {
// always true
assertTrue(oper.isSuccess(rawResponse, response));
}
@Test
- public void testSetOutcome() {
+ void testSetOutcome() {
// success case
lenient().when(rawResponse.getStatus()).thenReturn(200);
assertSame(outcome, oper.setOutcome(outcome, OperationResult.SUCCESS, rawResponse, response));
}
@Test
- public void testPrepareSoModelInfo() throws CoderException {
+ void testPrepareSoModelInfo() throws CoderException {
// valid data
SoModelInfo info = oper.prepareSoModelInfo();
verifyRequest("model.json", info);
}
@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());
}
@Test
- public void testBuildConfigurationParameters() {
+ void testBuildConfigurationParameters() {
// valid data
assertEquals(List.of(Collections.emptyMap()), oper.buildConfigurationParameters().get());
}
@Test
- public void testConstructCloudConfiguration() throws Exception {
+ void testConstructCloudConfiguration() throws Exception {
Tenant tenantItem = new Tenant();
tenantItem.setTenantId("my-tenant-id");
}
@Test
- public void testGetRequiredText() throws Exception {
+ void testGetRequiredText() throws Exception {
assertThatCode(() -> oper.getRequiredText("some value", "my value")).doesNotThrowAnyException();
}
@Test
- public void testGetCoder() throws CoderException {
+ void testGetCoder() throws CoderException {
Coder opcoder = oper.getCoder();
// ensure we can decode an SO timestamp
* ================================================================================
* 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.
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;
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;
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";
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();
* 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();
// 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());
// 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
* 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));
}
@Test
- public void testMakeRequest() throws CoderException {
+ void testMakeRequest() throws CoderException {
Pair<String, SoRequest> pair = oper.makeRequest();
// @formatter:off
* 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() {
* ================================================================================
* 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.
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;
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;
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";
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();
}
* Sets up.
*/
@Override
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() throws Exception {
super.setUp();
initHostPort();
* 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();
// 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());
// 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();
* 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"));
}
@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());
}
@Test
- public void testDelete() throws Exception {
+ void testDelete() throws Exception {
SoRequest req = new SoRequest();
req.setRequestId(REQ_ID);
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());
*/
@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
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());
* 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");
* 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);
* 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);
* 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());
}
private class MyOperation extends VfModuleDelete {
- public MyOperation(ControlLoopOperationParams params, HttpPollingConfig config) {
+ MyOperation(ControlLoopOperationParams params, HttpPollingConfig config) {
super(params, config);
}
<version>${policy.common.version}</version>
<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>
<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>
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
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;
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;
* 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.
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");
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();
}
@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());
}
@Test
- public void testProvideResponse() {
+ void testProvideResponse() {
String response = "{\"input\": 10}";
oper.provideResponse(listener, response);
* 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.
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());
}
@Test
- public void testInitOperator() throws Exception {
+ void testInitOperator() throws Exception {
oper.initConfig();
assertSame(oper.client, oper.config.getClient());
}
@Test
- public void testProvideResponse() throws Exception {
+ void testProvideResponse() throws Exception {
InvocationCallback<Response> cb = new InvocationCallback<>() {
@Override
public void completed(Response response) {
* 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.
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());
}
@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");
}
* 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.
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.
* 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.
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);
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
* 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.
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;
/**
* Constructs the object using a default actor and operation name.
*/
- public BasicVfcOperation() {
+ BasicVfcOperation() {
super();
}
* @param actor actor name
* @param operation operation name
*/
- public BasicVfcOperation(String actor, String operation) {
+ BasicVfcOperation(String actor, String operation) {
super(actor, operation);
}
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);
}
/**
* Initializes mocks and sets up.
*/
- public void setUp() throws Exception {
+ void setUp() throws Exception {
super.setUpBasic();
response = new VfcResponse();
* 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.
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;
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";
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);
* 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());
}
@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(
}
@Test
- public void testMakeRequest() {
+ void testMakeRequest() {
Pair<String, VfcRequest> resultPair = restartOper.makeRequest();
assertNotNull(resultPair.getLeft());
assertNotNull(resultPair.getRight());
* ================================================================================
* 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.
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());
}
@Test
- public void testActorService() {
+ void testActorService() {
// verify that it all plugs into the ActorService
verifyActorService(VfcActor.NAME, "service.yaml");
}
* 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.
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();
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
assertSame(config, oper.getConfig());
}
@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));
}
@Test
- public void testIsSuccess() {
+ void testIsSuccess() {
assertTrue(oper.isSuccess(rawResponse, response));
}
}
<version>${project.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>compile</scope>
- </dependency>
</dependencies>
</project>
* 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.
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;
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;
/**
* 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/")
HttpClientFactoryInstance.getClientFactory().build(clientParams);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
HttpClientFactoryInstance.getClientFactory().destroy();
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
super.setUpBasic();
operConfig = mock(DecisionConfig.class);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
}
* 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());
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");
}
* 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());
assertEquals(OperationResult.FAILURE, outcome.getResult());
DecisionResponse response = outcome.getResponse();
- assertTrue(response instanceof DecisionResponse);
+ assertInstanceOf(DecisionResponse.class, response);
assertNotNull(response.getPolicies());
assertThat(response.getPolicies()).isEmpty();
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
/**
* 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)
}
@Test
- public void test() {
+ void test() {
DecisionRequest expected = new DecisionRequest();
expected.setOnapComponent(ONAP_COMP);
expected.setOnapInstance(ONAP_INST);
* 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.
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;
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;
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
/**
* 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/")
HttpClientFactoryInstance.getClientFactory().build(clientParams);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
HttpClientFactoryInstance.getClientFactory().destroy();
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
/**
* 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");
* 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());
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());
* 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);
private class MyOper extends DecisionOperation {
- public MyOper(ControlLoopOperationParams params, HttpConfig config) {
+ MyOper(ControlLoopOperationParams params, HttpConfig config) {
super(params, config, PROPERTY_NAMES);
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
@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();
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());
private class MyOperator extends DecisionOperator {
- public MyOperator() {
+ MyOperator() {
super(ACTOR, OPERATION, null);
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
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));
}
@Test
- public void testBuilder_testToBuilder() {
+ void testBuilder_testToBuilder() {
assertEquals(CLIENT, params.getClientName());
assertEquals(ONAP_NAME, params.getOnapName());
// 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);
}
}
* 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.
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;
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;
/**
* 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/")
HttpClientFactoryInstance.getClientFactory().build(clientParams);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
HttpClientFactoryInstance.getClientFactory().destroy();
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
/**
* 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");
* 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());
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());
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());
}
@Test
- public void testPostProcessResponse() {
+ void testPostProcessResponse() {
DecisionResponse response = new DecisionResponse();
// null status
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
* 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));
}
@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
// 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);
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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
// 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));
}
}
<artifactId>mockito-core</artifactId>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
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;
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));
}
@Test
- public void testActorService_testBuildList() {
+ void testActorService_testBuildList() {
/*
* make a service where actors two and four have names that are duplicates of the
* others
}
@Test
- public void testDoStart() {
+ void testDoStart() {
service.configure(params);
setUpOp("testDoStart", actor -> when(actor.isConfigured()).thenReturn(false), Actor::start);
}
@Test
- public void testDoStop() {
+ void testDoStop() {
service.configure(params);
service.start();
}
@Test
- public void testDoShutdown() {
+ void testDoShutdown() {
service.configure(params);
service.start();
*/
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();
}
@Test
- public void testGetActor() {
+ void testGetActor() {
assertSame(actor1, service.getActor(ACTOR1));
assertSame(actor3, service.getActor(ACTOR3));
}
@Test
- public void testGetActors() {
+ void testGetActors() {
// @formatter:off
assertEquals("[actor A, actor B, actor C, actor D]",
service.getActors().stream()
}
@Test
- public void testGetActorNames() {
+ void testGetActorNames() {
// @formatter:off
assertEquals("[actor A, actor B, actor C, actor D]",
service.getActorNames().stream()
}
@Test
- public void testDoConfigure() {
+ void testDoConfigure() {
service.configure(params);
assertTrue(service.isConfigured());
* Tests doConfigure() where actors throw parameter validation and runtime exceptions.
*/
@Test
- public void testDoConfigureExceptions() {
+ void testDoConfigureExceptions() {
makeValidException(actor1);
makeRuntimeException(actor2);
makeValidException(actor3);
* </ul>
*/
@Test
- public void testDoConfigureConfigure() {
+ void testDoConfigureConfigure() {
// need mutable parameters
params = new TreeMap<>(params);
}
@Test
- public void testLoadActors() {
+ void testLoadActors() {
ActorService service = new ActorService();
assertFalse(service.getActors().isEmpty());
assertNotNull(service.getActor(DummyActor.class.getSimpleName()));
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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());
}
@Test
- public void testCanEnd_testGetEndTime() {
+ void testCanEnd_testGetEndTime() {
// null until canXxx() is called
assertNull(mgr.getEndTime());
assertNull(mgr.getEndTime());
}
@Test
- public void testRun() {
+ void testRun() {
mgr.run();
assertNotNull(mgr.getStartTime());
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
/**
* Initializes fields, including {@link #delay}.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
countToStringCalls = 0;
object = new Object() {
}
@Test
- public void testToString() {
+ void testToString() {
String delayed = delay.toString();
assertEquals(1, countToStringCalls);
}
@Test
- public void testDelayedIdentString() {
+ void testDelayedIdentString() {
// should not have called the object's toString() method yet
assertEquals(0, countToStringCalls);
}
* 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");
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
outcome = new OperationOutcome();
}
@Test
- public void testOperationOutcomeOperationOutcome() {
+ void testOperationOutcomeOperationOutcome() {
setAll();
OperationOutcome outcome2 = new OperationOutcome(outcome);
}
@Test
- public void testToControlLoopOperation() {
+ void testToControlLoopOperation() {
setAll();
ControlLoopOperation outcome2 = outcome.toControlLoopOperation();
* Tests both isFor() methods, as one invokes the other.
*/
@Test
- public void testIsFor() {
+ void testIsFor() {
setAll();
// null case
}
@Test
- public void testSetResult() {
+ void testSetResult() {
outcome.setResult(OperationResult.FAILURE_EXCEPTION);
assertEquals(OperationResult.FAILURE_EXCEPTION, outcome.getResult());
* 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.
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;
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";
/**
/**
* 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();
}
@Test
- public void testRunFunction() {
+ void testRunFunction() {
// no exception, no log
AtomicInteger count = new AtomicInteger();
Util.runFunction(() -> count.incrementAndGet(), "no error");
}
@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);
}
@Test
- public void testTranslateToMap() {
+ void testTranslateToMap() {
assertNull(Util.translateToMap("map: null", null));
// Abc => Map
@Data
@Builder
- public static class Abc {
+ static class Abc {
private int intValue;
private String strValue;
private String anotherString;
// 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();
}
}
* 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.
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;
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;
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";
/**
* 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));
}
@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());
}
@Test
- public void testDoStop() {
+ void testDoStop() {
actor.configure(params);
actor.start();
assertEquals(4, actor.getOperationNames().size());
}
@Test
- public void testDoShutdown() {
+ void testDoShutdown() {
actor.configure(params);
actor.start();
assertEquals(4, actor.getOperationNames().size());
}
@Test
- public void testAddOperator() {
+ void testAddOperator() {
// cannot add operators if already configured
actor.configure(params);
assertThatIllegalStateException().isThrownBy(() -> actor.addOperator(oper1));
}
@Test
- public void testGetOperator() {
+ void testGetOperator() {
assertSame(oper1, actor.getOperator(OPER1));
assertSame(oper3, actor.getOperator(OPER3));
}
@Test
- public void testGetOperators() {
+ void testGetOperators() {
// @formatter:off
assertEquals("[add, divide, multiply, subtract]",
actor.getOperators().stream()
}
@Test
- public void testGetOperationNames() {
+ void testGetOperationNames() {
// @formatter:off
assertEquals("[add, divide, multiply, subtract]",
actor.getOperationNames().stream()
}
@Test
- public void testDoConfigure() {
+ void testDoConfigure() {
actor.configure(params);
assertTrue(actor.isConfigured());
* exceptions.
*/
@Test
- public void testDoConfigureExceptions() {
+ void testDoConfigureExceptions() {
makeValidException(oper1);
makeRuntimeException(oper2);
makeValidException(oper3);
* </ul>
*/
@Test
- public void testDoConfigureConfigure() {
+ void testDoConfigureConfigure() {
// configure one operator
oper1.configure(sub1);
}
@Test
- public void testMakeOperatorParameters() {
+ void testMakeOperatorParameters() {
actor.configure(params);
// each operator should have received its own parameters
* 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.
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;
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;
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";
/**
* 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);
TopicEndpointManager.getManager().addTopicSources(props);
}
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
// clear all topics after the tests
TopicEndpointManager.getManager().shutdown();
}
/**
* 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);
}
@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);
}
@Test
- public void testDoShutdown() {
+ void testDoShutdown() throws BidirectionalTopicClientException {
+
// allocate some handlers
actor.getTopicHandler(MY_SINK, MY_SOURCE1);
actor.getTopicHandler(MY_SINK, MY_SOURCE2);
}
@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));
}
@Test
- public void testMakeTopicHandler() {
+ void testMakeTopicHandler() throws BidirectionalTopicClientException {
// use a real actor
actor = new BidirectionalTopicActor<>(ACTOR, BidirectionalTopicActorParams.class);
// @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)) {
* 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.
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;
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;
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";
/**
* 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();
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());
}
@Test
- public void testStartOperationAsync() throws Exception {
-
+ void testStartOperationAsync() throws Exception {
// tell it to expect three responses
ntimes = 3;
* 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;
}
};
* 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);
}
@Test
- public void testGetTimeoutMsInteger() {
+ void testGetTimeoutMsInteger() {
// use default
assertEquals(TIMEOUT_MS, oper.getTimeoutMs(null));
assertEquals(TIMEOUT_MS, oper.getTimeoutMs(0));
}
@Test
- public void testPublishRequest() {
+ void testPublishRequest() {
assertThatCode(() -> oper.publishRequest(new MyRequest())).doesNotThrowAnyException();
}
* Tests publishRequest() when nothing is published.
*/
@Test
- public void testPublishRequestUnpublished() {
+ void testPublishRequestUnpublished() {
when(handler.send(any())).thenReturn(false);
assertThatIllegalStateException().isThrownBy(() -> oper.publishRequest(new MyRequest()));
}
* 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();
}
* Tests publishRequest() when the coder throws an exception.
*/
@Test
- public void testPublishRequestException() {
+ void testPublishRequestException() {
setOperCoderException();
assertThatIllegalArgumentException().isThrownBy(() -> oper.publishRequest(new MyRequest()));
}
* 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());
* 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());
* 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");
* 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());
* 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());
}
* 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() {
@Getter
@Setter
- public static class MyRequest {
+ static class MyRequest {
private String theRequestId = REQ_ID;
private String input;
}
@Getter
@Setter
@EqualsAndHashCode
- public static class MyResponse {
+ static class MyResponse {
private String requestId;
private String output;
}
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
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
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
* 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.
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;
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";
/**
* 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);
}
@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
}
@Test
- public void testBuildOperator() {
+ void testBuildOperator() {
AtomicReference<ControlLoopOperationParams> paramsRef = new AtomicReference<>();
AtomicReference<BidirectionalTopicConfig> configRef = new AtomicReference<>();
private class MyOperator extends BidirectionalTopicOperator {
- public MyOperator(List<SelectorKey> selectorKeys) {
+ MyOperator(List<SelectorKey> selectorKeys) {
super(ACTOR, OPERATION, mgr, selectorKeys);
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
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);
}
@Test
- public void testHttpActor() {
+ void testHttpActor() {
assertEquals(ACTOR, actor.getName());
assertEquals(ACTOR, actor.getFullName());
}
* 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.
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;
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;
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";
/**
* Starts the simulator.
*/
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ void setUpBeforeClass() throws Exception {
// allocate a port
int port = NetworkUtil.allocPort();
/**
* 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();
callback = new AtomicReference<>();
future = new CompletableFuture<>();
- when(clientFactory.get(any())).thenReturn(client);
+ Mockito.lenient().when(clientFactory.get(any())).thenReturn(client);
initConfig(HTTP_CLIENT);
}
@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);
}
@Test
- public void testDoConfigureMapOfStringObject_testGetClient_testGetPath_testGetTimeoutMs() {
+ void testDoConfigureMapOfStringObject_testGetClient_testGetPath_testGetTimeoutMs() {
// use value from operator
assertEquals(1000L, oper.getTimeoutMs(null));
* 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;
* 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;
* 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());
* 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());
* 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);
* 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));
* Tests a GET.
*/
@Test
- public void testGet() throws Exception {
+ void testGet() throws Exception {
// use a real client
initRealConfig(HTTP_CLIENT);
* Tests a DELETE.
*/
@Test
- public void testDelete() throws Exception {
+ void testDelete() throws Exception {
// use a real client
initRealConfig(HTTP_CLIENT);
* Tests a POST.
*/
@Test
- public void testPost() throws Exception {
+ void testPost() throws Exception {
// use a real client
initRealConfig(HTTP_CLIENT);
MyPostOperation oper2 = new MyPostOperation();
* Tests a PUT.
*/
@Test
- public void testPut() throws Exception {
+ void testPut() throws Exception {
// use a real client
initRealConfig(HTTP_CLIENT);
}
@Test
- public void testMakeDecoder() {
+ void testMakeDecoder() {
assertNotNull(oper.getCoder());
}
@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());
}
}
private class MyPostOperation extends HttpOperation<MyResponse> {
- public MyPostOperation() {
+ MyPostOperation() {
super(HttpOperationTest.this.params, HttpOperationTest.this.config, MyResponse.class,
Collections.emptyList());
}
}
private class MyPutOperation extends HttpOperation<MyResponse> {
- public MyPutOperation() {
+ MyPutOperation() {
super(HttpOperationTest.this.params, HttpOperationTest.this.config, MyResponse.class,
Collections.emptyList());
}
}
private class MyDeleteOperation extends HttpOperation<String> {
- public MyDeleteOperation() {
+ MyDeleteOperation() {
super(HttpOperationTest.this.params, HttpOperationTest.this.config, String.class, Collections.emptyList());
}
* 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.
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;
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";
* 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();
}
@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();
}
@Test
- public void testBuildOperation() {
+ void testBuildOperation() {
HttpOperator oper2 = new MyOperator();
assertNotNull(oper2);
assertNotNull(oper2.getClientFactory());
}
@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);
}
}
private class MyOperation extends HttpOperation<String> {
- public MyOperation(ControlLoopOperationParams params, HttpConfig config) {
+ MyOperation(ControlLoopOperationParams params, HttpConfig config) {
super(params, config, String.class, Collections.emptyList());
}
* 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.
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;
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;
/**
* 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;
/**
* 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();
}
@Test
- public void testConstructor_testGetWaitMsGet() {
+ void testConstructor_testGetWaitMsGet() {
assertEquals(MY_ACTOR, oper.getActorName());
assertEquals(MY_OPERATION, oper.getName());
assertSame(config, oper.getConfig());
}
@Test
- public void testSetUsePollExceptions() {
+ void testSetUsePollExceptions() {
// should be no exception
oper.setUsePolling();
}
@Test
- public void testPostProcess() throws Exception {
+ void testPostProcess() throws Exception {
// completed
oper.generateSubRequestId(2);
CompletableFuture<OperationOutcome> future2 =
* 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.
*/
}
@Test
- public void testDetmStatus() {
+ void testDetmStatus() {
// make an operation that does NOT override detmStatus()
oper = new HttpOperation<String>(params, config, String.class, Collections.emptyList()) {};
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();
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
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";
* 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();
}
@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
}
@Test
- public void testGetClientFactory() {
+ void testGetClientFactory() {
HttpPollingOperator oper2 = new HttpPollingOperator(ACTOR, OPERATION);
assertNotNull(oper2.getClientFactory());
}
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;
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;
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;
/**
* Attaches the appender to the logger.
*/
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
+ @BeforeAll
+ static void setUpBeforeClass() throws Exception {
/*
* Attach appender to the logger.
*/
/**
* 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)
}
@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
}
@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);
}
@Test
- public void testStart() {
+ void testStart() {
verifyRun("testStart", 1, 1, OperationResult.SUCCESS);
}
* Tests start() with multiple running requests.
*/
@Test
- public void testStartMultiple() {
+ void testStartMultiple() {
for (int count = 0; count < MAX_PARALLEL; ++count) {
oper.start();
}
}
@Test
- public void testStartOperationAsync() {
+ void testStartOperationAsync() {
oper.start();
assertTrue(executor.runAll(MAX_REQUESTS));
}
@Test
- public void testIsSuccess() {
+ void testIsSuccess() {
assertFalse(oper.isSuccess(null));
OperationOutcome outcome = new OperationOutcome();
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();
}
@Test
- public void testDoOperation() {
+ void testDoOperation() {
/*
* Use an operation that doesn't override doOperation().
*/
}
@Test
- public void testTimeout() throws Exception {
+ void testTimeout() throws Exception {
// use a real executor
params = params.toBuilder().executor(ForkJoinPool.commonPool()).build();
* 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
* 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
* 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();
* 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
* 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() {
}
@Test
- public void testSleep() throws Exception {
+ void testSleep() throws Exception {
CompletableFuture<Void> future = oper.sleep(-1, TimeUnit.SECONDS);
assertTrue(future.isDone());
assertNull(future.get());
}
@Test
- public void testIsSameOperation() {
+ void testIsSameOperation() {
assertFalse(oper.isSameOperation(null));
OperationOutcome outcome = params.makeOutcome();
}
@Test
- public void testFromException() {
+ void testFromException() {
// arrange to generate an exception when operation runs
oper.setGenException(true);
* Tests fromException() when there is no exception.
*/
@Test
- public void testFromExceptionNoExcept() {
+ void testFromExceptionNoExcept() {
verifyRun("testFromExceptionNoExcept", 1, 1, OperationResult.SUCCESS);
}
* 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<>();
*/
@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
}
@Test
- public void testAllOfArray() throws Exception {
+ void testAllOfArray() throws Exception {
final OperationOutcome outcome = params.makeOutcome();
CompletableFuture<OperationOutcome> future1 = new CompletableFuture<>();
}
@Test
- public void testAllOfList() throws Exception {
+ void testAllOfList() throws Exception {
final OperationOutcome outcome = params.makeOutcome();
CompletableFuture<OperationOutcome> future1 = new CompletableFuture<>();
*/
@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
}
@Test
- public void testAttachFutures() throws Exception {
+ void testAttachFutures() throws Exception {
List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
// third task throws an exception during construction
}
@Test
- public void testCombineOutcomes() throws Exception {
+ void testCombineOutcomes() throws Exception {
// only one outcome
verifyOutcomes(0, OperationResult.SUCCESS);
verifyOutcomes(0, OperationResult.FAILURE_EXCEPTION);
* 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<>();
*/
@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
}
@Test
- public void testDetmPriority() throws CoderException {
+ void testDetmPriority() throws CoderException {
assertEquals(1, oper.detmPriority(null));
OperationOutcome outcome = params.makeOutcome();
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());
}
/*
* Tests callbackStarted() when the pipeline has already been stopped.
*/
@Test
- public void testCallbackStartedNotRunning() {
+ void testCallbackStartedNotRunning() {
AtomicReference<Future<OperationOutcome>> future = new AtomicReference<>();
/*
* 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
}
@Test
- public void testSetOutcomeControlLoopOperationOutcomeThrowable() {
+ void testSetOutcomeControlLoopOperationOutcomeThrowable() {
final CompletionException timex = new CompletionException(new TimeoutException(EXPECTED_EXCEPTION));
OperationOutcome outcome;
}
@Test
- public void testSetOutcomeControlLoopOperationOutcomePolicyResult() {
+ void testSetOutcomeControlLoopOperationOutcomePolicyResult() {
OperationOutcome outcome;
outcome = new OperationOutcome();
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)));
}
@Test
- public void testLogMessage() {
+ void testLogMessage() {
final String infraStr = SINK_INFRA.toString();
// log structured data
}
@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();
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());
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);
}
/**
@Getter
- public static class MyData {
+ static class MyData {
private String text = TEXT;
}
private CompletableFuture<OperationOutcome> preProc;
- public MyOper() {
+ MyOper() {
super(OperationPartialTest.this.params, config, PROP_NAMES);
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
/**
* Initializes {@link #operator}.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
operator = new OperatorPartial(ACTOR, OPERATION) {
@Override
public Operation buildOperation(ControlLoopOperationParams params) {
}
@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);
}
@Test
- public void testDoStop() {
+ void testDoStop() {
operator.configure(null);
operator.start();
}
@Test
- public void testDoShutdown() {
+ void testDoShutdown() {
operator.configure(null);
operator.start();
}
@Test
- public void testDoConfigureMapOfStringObject() {
+ void testDoConfigureMapOfStringObject() {
operator = spy(operator);
Map<String, Object> params = new TreeMap<>();
}
@Test
- public void testGetBlockingExecutor() {
+ void testGetBlockingExecutor() {
assertNotNull(operator.getBlockingExecutor());
}
}
* 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.
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";
/**
* 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) {
}
@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);
}
@Test
- public void testStart() {
+ void testStart() {
assertFalse(config.isAlive());
// can't start if not configured yet
}
@Test
- public void testStop() {
+ void testStop() {
config.configure(PARAMS);
// ok to stop if not running, but shouldn't invoke doStop()
}
@Test
- public void testShutdown() {
+ void testShutdown() {
config.configure(PARAMS);
// ok to shutdown if not running, but shouldn't invoke doShutdown()
* 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.
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";
* 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));
}
@Test
- public void testMakeOperationParameters() {
+ void testMakeOperationParameters() {
Function<String, Map<String, Object>> maker = params.makeOperationParameters(CONTAINER);
assertNull(maker.apply("unknown-operation"));
}
@Test
- public void testDoValidation() {
+ void testDoValidation() {
assertThatCode(() -> params.doValidation(CONTAINER)).doesNotThrowAnyException();
// invalid param
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
// only a few fields are required
// 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);
}
}
@Setter
- public static class MyParams extends ActorParams {
+ static class MyParams extends ActorParams {
@SuppressWarnings("unused")
private String text1;
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
BidirectionalTopicParams oper1 = BidirectionalTopicParams.builder().sourceTopic(OPER1_SOURCE)
.sinkTopic(OPER1_SINK).timeoutSec(OPER1_TIMEOUT).build();
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
// only a few fields are required
// 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);
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
/**
* 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);
}
@Test
- public void test() {
+ void test() {
assertSame(executor, config.getBlockingExecutor());
assertSame(topicHandler, config.getTopicHandler());
assertSame(forwarder, config.getForwarder());
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
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));
}
@Test
- public void testBuilder_testToBuilder() {
+ void testBuilder_testToBuilder() {
assertEquals(SINK, params.getSinkTopic());
assertEquals(SOURCE, params.getSourceTopic());
assertEquals(TIMEOUT, params.getTimeoutSec());
// 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);
}
}
* 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.
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;
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;
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";
/**
* 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<>();
}
@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());
}
@Test
- public void testCallbackStarted() {
+ void testCallbackStarted() {
params.callbackStarted(outcome);
verify(starter).accept(outcome);
}
@Test
- public void testCallbackCompleted() {
+ void testCallbackCompleted() {
params.callbackCompleted(outcome);
verify(completer).accept(outcome);
}
@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));
// 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
}
@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
}
@Test
- public void testGetRetry() {
+ void testGetRetry() {
assertSame(RETRY, params.getRetry());
// should be null when unspecified
}
@Test
- public void testGetTimeoutSec() {
+ void testGetTimeoutSec() {
assertSame(TIMEOUT, params.getTimeoutSec());
// should be 300 when unspecified
}
@Test
- public void testGetStartCallback() {
+ void testGetStartCallback() {
assertSame(starter, params.getStartCallback());
}
@Test
- public void testGetCompleteCallback() {
+ void testGetCompleteCallback() {
assertSame(completer, params.getCompleteCallback());
}
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
* 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));
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
// only a few fields are required
// 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);
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
/**
* 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();
}
@Test
- public void test() {
+ void test() {
assertSame(executor, config.getBlockingExecutor());
assertSame(client, config.getClient());
assertEquals(MY_PATH, config.getPath());
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
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));
}
@Test
- public void testBuilder_testToBuilder() {
+ void testBuilder_testToBuilder() {
assertEquals(CLIENT, params.getClientName());
assertEquals(PATH, params.getPath());
assertEquals(TIMEOUT, params.getTimeoutSec());
// 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);
}
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
* 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));
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
// only a few fields are required
// 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);
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
/**
* 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)
}
@Test
- public void test() {
+ void test() {
assertEquals(POLL_PATH + "/", config.getPollPath());
assertEquals(MAX_POLLS, config.getMaxPolls());
assertEquals(WAIT_SEC, config.getPollWaitSec());
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
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));
}
@Test
- public void testBuilder_testToBuilder() {
+ void testBuilder_testToBuilder() {
assertEquals(CLIENT, params.getClientName());
assertEquals(POLL_PATH, params.getPollPath());
// 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);
}
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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());
}
@Test
- public void testParameterValidationExceptionValidationResultStringThrowable() {
+ void testParameterValidationExceptionValidationResultStringThrowable() {
ParameterValidationRuntimeException ex =
new ParameterValidationRuntimeException(THE_MESSAGE, EXPECTED_EXCEPTION, result);
assertSame(result, ex.getResult());
}
@Test
- public void testGetResult() {
+ void testGetResult() {
ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(result);
assertSame(result, ex.getResult());
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
/**
* 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);
}
@Test
- public void testAdd() {
+ void testAdd() {
// still running - this should not be invoked
mgr.add(future1);
verify(future1, never()).cancel(anyBoolean());
}
@Test
- public void testRemove() {
+ void testRemove() {
mgr.add(future1);
mgr.add(future2);
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
/**
* 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);
}
@Test
- public void testAdd() {
+ void testAdd() {
// still running - this should not be invoked
mgr.add(runnable1);
verify(runnable1, never()).run();
}
@Test
- public void testRemove() {
+ void testRemove() {
mgr.add(runnable1);
mgr.add(runnable2);
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
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";
* 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<>();
}
@Test
- public void testCancel_testAddFutureOfFBoolean_testAddRunnable__testIsRunning() {
+ void testCancel_testAddFutureOfFBoolean_testAddRunnable__testIsRunning() {
assertTrue(controller.isRunning());
assertTrue(controller.cancel(false));
}
@Test
- public void testCompleteT() throws Exception {
+ void testCompleteT() throws Exception {
assertTrue(controller.complete(TEXT));
assertEquals(TEXT, controller.get());
}
@Test
- public void testCompleteExceptionallyThrowable() {
+ void testCompleteExceptionallyThrowable() {
assertTrue(controller.completeExceptionally(EXPECTED_EXCEPTION));
assertThatThrownBy(() -> controller.get()).hasCause(EXPECTED_EXCEPTION);
}
@Test
- public void testCompleteAsyncSupplierOfQextendsTExecutor() throws Exception {
+ void testCompleteAsyncSupplierOfQextendsTExecutor() throws Exception {
CompletableFuture<String> future = controller.completeAsync(() -> TEXT, executor);
// haven't stopped anything yet
* 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));
}
@Test
- public void testCompleteAsyncSupplierOfQextendsT() throws Exception {
+ void testCompleteAsyncSupplierOfQextendsT() throws Exception {
CompletableFuture<String> future = controller.completeAsync(() -> TEXT);
assertEquals(TEXT, future.get());
* 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
}
@Test
- public void testCompleteOnTimeoutTLongTimeUnit() throws Exception {
+ void testCompleteOnTimeoutTLongTimeUnit() throws Exception {
CountDownLatch stopped = new CountDownLatch(1);
controller.add(() -> stopped.countDown());
* 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);
* 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));
}
@Test
- public void testNewIncompleteFuture() {
+ void testNewIncompleteFuture() {
PipelineControllerFuture<String> future = controller.newIncompleteFuture();
assertNotNull(future);
assertTrue(future instanceof PipelineControllerFuture);
}
@Test
- public void testDelayedComplete() throws Exception {
+ void testDelayedComplete() throws Exception {
controller.add(runnable1);
BiConsumer<String, Throwable> stopper = controller.delayedComplete();
* 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();
}
@Test
- public void testDelayedRemoveFutureOfF() throws Exception {
+ void testDelayedRemoveFutureOfF() throws Exception {
BiConsumer<String, Throwable> remover = controller.delayedRemove(future1);
remover.accept(TEXT, EXPECTED_EXCEPTION);
}
@Test
- public void testDelayedRemoveRunnable() throws Exception {
+ void testDelayedRemoveRunnable() throws Exception {
BiConsumer<String, Throwable> remover = controller.delayedRemove(runnable1);
remover.accept(TEXT, EXPECTED_EXCEPTION);
}
@Test
- public void testRemoveFutureOfF_testRemoveRunnable() {
+ void testRemoveFutureOfF_testRemoveRunnable() {
controller.remove(runnable2);
controller.remove(future1);
* Tests both wrap() methods.
*/
@Test
- public void testWrap() throws Exception {
+ void testWrap() throws Exception {
controller = spy(controller);
CompletableFuture<String> future = controller.wrap(compFuture);
* Tests wrap(), when the controller is not running.
*/
@Test
- public void testWrapNotRunning() throws Exception {
+ void testWrapNotRunning() throws Exception {
controller.cancel(false);
controller = spy(controller);
* 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);
}
@Test
- public void testWrapFunction() throws Exception {
+ void testWrapFunction() throws Exception {
Function<String, CompletableFuture<String>> func = controller.wrap(input -> {
compFuture.complete(input);
* 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);
* 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 -> {
* 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.
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);
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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";
/**
* 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));
}
@Test
- public void testBidirectionalTopicHandler_testGetSource_testGetTarget() {
+ void testBidirectionalTopicHandler_testGetSource_testGetTarget() {
assertEquals(MY_SOURCE, handler.getSourceTopic());
assertEquals(MY_SINK, handler.getSinkTopic());
}
@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);
}
@Test
- public void testGetTopicEndpointManager() {
+ void testGetTopicEndpointManager() {
// setting "mgr" to null should cause it to use the superclass' method
mgr = null;
assertNotNull(handler.getTopicEndpointManager());
private class MyTopicHandler extends BidirectionalTopicHandler {
- public MyTopicHandler(String sinkTopic, String sourceTopic) throws BidirectionalTopicClientException {
+ MyTopicHandler(String sinkTopic, String sourceTopic) throws BidirectionalTopicClientException {
super(sinkTopic, sourceTopic);
}
* 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.
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";
/**
* 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);
}
@Test
- public void testRegister() {
+ void testRegister() {
// key size mismatches
assertThatIllegalArgumentException().isThrownBy(() -> forwarder.register(Arrays.asList(), listener1))
.withMessage("key/value mismatch");
}
@Test
- public void testUnregister() {
+ void testUnregister() {
// remove listener1b
forwarder.unregister(Arrays.asList(VALUEA_REQID, VALUEA_SUBREQID), listener1b);
}
@Test
- public void testOnMessage() {
+ void testOnMessage() {
StandardCoderObject sco = makeMessage(Map.of(KEY1, VALUEA_REQID, KEY2, Map.of(SUBKEY, VALUEA_SUBREQID)));
forwarder.onMessage(TEXT, sco);
* 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)));
* 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)));
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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());
}
@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);
}
@Test
- public void testToString() {
+ void testToString() {
assertEquals("[map, abc]", key.toString());
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.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;
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";
/**
* Sets up.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
topic = new TopicListenerImpl();
forwarder1 = topic.addForwarder(new SelectorKey(KEY1));
}
@Test
- public void testShutdown() {
+ void testShutdown() {
// shut it down, which should clear all forwarders
topic.shutdown();
}
@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
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>