summaryrefslogtreecommitdiffstats
path: root/a1-adapter/a1-adapter-api/provider/src/test
diff options
context:
space:
mode:
authorelinuxhenrik <henrik.b.andersson@est.tech>2020-09-10 12:46:50 +0200
committerelinuxhenrik <henrik.b.andersson@est.tech>2020-09-17 09:36:19 +0200
commit85d051e896e58f6dc8e34b7121963a768307ae69 (patch)
treec097a921a49409f2fbeebba5a4d7183b861cc816 /a1-adapter/a1-adapter-api/provider/src/test
parent28d357836d89914e241c0fcd20239aff7498568e (diff)
Remove Sonar issues
Change-Id: I4e9b737e110f83a32512c3f5f98bf1a784e6c5ee Issue-ID: CCSDK-2604 Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Diffstat (limited to 'a1-adapter/a1-adapter-api/provider/src/test')
-rw-r--r--a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterClientTest.java34
-rw-r--r--a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProviderTest.java115
2 files changed, 64 insertions, 85 deletions
diff --git a/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterClientTest.java b/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterClientTest.java
index 5c4b2857..50f44f0a 100644
--- a/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterClientTest.java
+++ b/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterClientTest.java
@@ -20,17 +20,18 @@
package org.onap.ccsdk.features.a1.adapter;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
+
import java.util.Properties;
import java.util.concurrent.ExecutionException;
-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.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.DeleteA1PolicyOutputBuilder;
@@ -41,13 +42,8 @@ import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyOut
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * This class Tests all the methods in A1AdapterClientTest
- *
- */
-
-@RunWith(MockitoJUnitRunner.Silent.class)
-public class A1AdapterClientTest {
+@ExtendWith(MockitoExtension.class)
+class A1AdapterClientTest {
protected static final Logger LOG = LoggerFactory.getLogger(A1AdapterClientTest.class);
@@ -57,13 +53,13 @@ public class A1AdapterClientTest {
private static String module = "A1-ADAPTER-API";
private static String mode = "sync";
- @Before
- public void setUp() throws Exception {
+ @BeforeEach
+ void setUp() {
a1AdapterClient = new A1AdapterClient(svcLogicService);
}
@Test
- public void test_execute_getPolicyType() throws SvcLogicException, InterruptedException, ExecutionException {
+ void getPolicyType() throws Exception {
String rpc = "deleteA1Policy";
Properties params = new Properties();
Properties respProps = new Properties();
@@ -75,7 +71,7 @@ public class A1AdapterClientTest {
}
@Test
- public void test_execute_getPolicyStatus() throws SvcLogicException, InterruptedException, ExecutionException {
+ void getPolicyStatus() throws Exception {
String rpc = "getA1PolicyStatus";
Properties params = new Properties();
Properties respProps = new Properties();
@@ -87,7 +83,7 @@ public class A1AdapterClientTest {
}
@Test
- public void test_execute_getPolicy() throws SvcLogicException, InterruptedException, ExecutionException {
+ void getPolicy() throws Exception {
String rpc = "getA1Policy";
Properties params = new Properties();
Properties respProps = new Properties();
@@ -99,7 +95,7 @@ public class A1AdapterClientTest {
}
@Test
- public void test_execute_deletePolicy() throws SvcLogicException, InterruptedException, ExecutionException {
+ void deletePolicy() throws Exception {
String rpc = "deleteA1Policy";
Properties params = new Properties();
Properties respProps = new Properties();
@@ -111,7 +107,7 @@ public class A1AdapterClientTest {
}
@Test
- public void test_execute_putPolicy() throws SvcLogicException, InterruptedException, ExecutionException {
+ void putPolicy() throws Exception {
String rpc = "putA1Policy";
Properties params = new Properties();
Properties respProps = new Properties();
diff --git a/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProviderTest.java b/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProviderTest.java
index a6588ea8..96bad81b 100644
--- a/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProviderTest.java
+++ b/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProviderTest.java
@@ -20,64 +20,45 @@
package org.onap.ccsdk.features.a1.adapter;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
+
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Properties;
-import java.util.concurrent.ExecutionException;
-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.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.DeleteA1PolicyInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.DeleteA1PolicyOutput;
-import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.DeleteA1PolicyOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyOutput;
-import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyStatusInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyStatusOutput;
-import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyStatusOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyTypeInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyTypeOutput;
-import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyTypeOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyOutput;
-import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyOutputBuilder;
+import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * This class Tests all the methods in A1AdapterProvider
- *
- */
+@ExtendWith(MockitoExtension.class)
+class A1AdapterProviderTest {
-@RunWith(MockitoJUnitRunner.Silent.class)
-public class A1AdapterProviderTest {
+ private static final String RESPONSE_CODE = "response-code";
+ private static final String OK_RESPONSE = "200";
protected static final Logger LOG = LoggerFactory.getLogger(A1AdapterProviderTest.class);
- class A1AdapterProviderMock extends A1AdapterProvider {
-
- A1AdapterProviderMock(final DataBroker dataBroker, final NotificationPublishService notificationPublishService,
- final RpcProviderRegistry rpcProviderRegistry, final A1AdapterClient A1AdapterClient) {
- super(dataBroker, mockNotificationPublishService, mockRpcProviderRegistry, a1AdapterClient);
- }
-
- }
-
- private A1AdapterProviderMock a1AdapterProviderMock = null;
- @Mock
- private DataBroker dataBroker;
+ private A1AdapterProvider a1AdapterProviderMock = null;
@Mock
private NotificationPublishService mockNotificationPublishService;
@Mock
@@ -87,80 +68,82 @@ public class A1AdapterProviderTest {
private static String module = "A1-ADAPTER-API";
private static String mode = "sync";
- @Before
- public void setUp() throws Exception {
-
- a1AdapterProviderMock = new A1AdapterProviderMock(dataBroker, mockNotificationPublishService,
- mockRpcProviderRegistry, a1AdapterClient);
- a1AdapterProviderMock = Mockito.spy(a1AdapterProviderMock);
-
+ @BeforeEach
+ void setUp() {
+ a1AdapterProviderMock = Mockito.spy(new A1AdapterProvider(mockNotificationPublishService,
+ mockRpcProviderRegistry, a1AdapterClient));
}
@Test
- public void test_deleteA1PolicyType() throws SvcLogicException, InterruptedException, ExecutionException {
+ void deleteA1PolicyType() throws Exception {
String rpc = "deleteA1Policy";
Properties respProps = new Properties();
- respProps.setProperty("response-code", "200");
+ respProps.setProperty(RESPONSE_CODE, OK_RESPONSE);
DeleteA1PolicyInputBuilder inputBuilder = new DeleteA1PolicyInputBuilder();
when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
- when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(DeleteA1PolicyOutputBuilder.class),
- any(Properties.class))).thenReturn(respProps);
+ when(
+ a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Builder.class), any(Properties.class)))
+ .thenReturn(respProps);
ListenableFuture<RpcResult<DeleteA1PolicyOutput>> result =
- a1AdapterProviderMock.deleteA1Policy(inputBuilder.build());
- assertEquals("200", String.valueOf(result.get().getResult().getHttpStatus()));
+ a1AdapterProviderMock.deleteA1Policy(inputBuilder.build());
+ assertEquals(OK_RESPONSE, String.valueOf(result.get().getResult().getHttpStatus()));
}
@Test
- public void test_getA1Policy() throws SvcLogicException, InterruptedException, ExecutionException {
+ void getA1Policy() throws Exception {
String rpc = "getA1Policy";
Properties respProps = new Properties();
- respProps.setProperty("response-code", "200");
+ respProps.setProperty(RESPONSE_CODE, OK_RESPONSE);
GetA1PolicyInputBuilder inputBuilder = new GetA1PolicyInputBuilder();
when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
- when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetA1PolicyOutputBuilder.class),
- any(Properties.class))).thenReturn(respProps);
+ when(
+ a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Builder.class), any(Properties.class)))
+ .thenReturn(respProps);
ListenableFuture<RpcResult<GetA1PolicyOutput>> result = a1AdapterProviderMock.getA1Policy(inputBuilder.build());
- assertEquals("200", String.valueOf(result.get().getResult().getHttpStatus()));
+ assertEquals(OK_RESPONSE, String.valueOf(result.get().getResult().getHttpStatus()));
}
@Test
- public void test_getA1PolicyType() throws SvcLogicException, InterruptedException, ExecutionException {
+ void getA1PolicyType() throws Exception {
String rpc = "getA1PolicyType";
Properties respProps = new Properties();
- respProps.setProperty("response-code", "200");
+ respProps.setProperty(RESPONSE_CODE, OK_RESPONSE);
GetA1PolicyTypeInputBuilder inputBuilder = new GetA1PolicyTypeInputBuilder();
when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
- when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetA1PolicyTypeOutputBuilder.class),
- any(Properties.class))).thenReturn(respProps);
+ when(
+ a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Builder.class), any(Properties.class)))
+ .thenReturn(respProps);
ListenableFuture<RpcResult<GetA1PolicyTypeOutput>> result =
- a1AdapterProviderMock.getA1PolicyType(inputBuilder.build());
- assertEquals("200", String.valueOf(result.get().getResult().getHttpStatus()));
+ a1AdapterProviderMock.getA1PolicyType(inputBuilder.build());
+ assertEquals(OK_RESPONSE, String.valueOf(result.get().getResult().getHttpStatus()));
}
@Test
- public void test_getA1PolicyStatus() throws SvcLogicException, InterruptedException, ExecutionException {
+ void getA1PolicyStatus() throws Exception {
String rpc = "getA1PolicyStatus";
Properties respProps = new Properties();
- respProps.setProperty("response-code", "200");
+ respProps.setProperty(RESPONSE_CODE, OK_RESPONSE);
GetA1PolicyStatusInputBuilder inputBuilder = new GetA1PolicyStatusInputBuilder();
when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
- when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetA1PolicyStatusOutputBuilder.class),
- any(Properties.class))).thenReturn(respProps);
+ when(
+ a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Builder.class), any(Properties.class)))
+ .thenReturn(respProps);
ListenableFuture<RpcResult<GetA1PolicyStatusOutput>> result =
- a1AdapterProviderMock.getA1PolicyStatus(inputBuilder.build());
- assertEquals("200", String.valueOf(result.get().getResult().getHttpStatus()));
+ a1AdapterProviderMock.getA1PolicyStatus(inputBuilder.build());
+ assertEquals(OK_RESPONSE, String.valueOf(result.get().getResult().getHttpStatus()));
}
@Test
- public void test_putA1Policy() throws SvcLogicException, InterruptedException, ExecutionException {
+ void putA1Policy() throws Exception {
String rpc = "putA1Policy";
Properties respProps = new Properties();
- respProps.setProperty("response-code", "200");
+ respProps.setProperty(RESPONSE_CODE, OK_RESPONSE);
PutA1PolicyInputBuilder inputBuilder = new PutA1PolicyInputBuilder();
when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
- when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(PutA1PolicyOutputBuilder.class),
- any(Properties.class))).thenReturn(respProps);
+ when(
+ a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Builder.class), any(Properties.class)))
+ .thenReturn(respProps);
ListenableFuture<RpcResult<PutA1PolicyOutput>> result = a1AdapterProviderMock.putA1Policy(inputBuilder.build());
- assertEquals("200", String.valueOf(result.get().getResult().getHttpStatus()));
+ assertEquals(OK_RESPONSE, String.valueOf(result.get().getResult().getHttpStatus()));
}
}