summaryrefslogtreecommitdiffstats
path: root/a1-adapter/a1-adapter-api/provider/src/test
diff options
context:
space:
mode:
authorLathish <lathishbabu.ganesan@est.tech>2020-08-14 17:18:05 +0100
committerLathish <lathishbabu.ganesan@est.tech>2020-08-17 09:48:07 +0100
commit00d7a8cf9bf7ff836abb0c758e1a0ec9498c779e (patch)
tree2cd2953ce602dddd8561e9848caccebe7a7b8ff1 /a1-adapter/a1-adapter-api/provider/src/test
parent5d0ad5f3d3158357183849ca329ac6999be6281d (diff)
Add A1 implementation
Issue-ID: CCSDK-2604 Change-Id: Iad40153e7a8a0468c4512ae284de47cf42ee31bd Signed-off-by: Lathish <lathishbabu.ganesan@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.java124
-rw-r--r--a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProviderTest.java144
2 files changed, 226 insertions, 42 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
new file mode 100644
index 00000000..5c4b2857
--- /dev/null
+++ b/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterClientTest.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.features.a1.adapter;
+
+import static org.junit.Assert.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.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+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;
+import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyStatusOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyTypeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyOutputBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class Tests all the methods in A1AdapterClientTest
+ *
+ */
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class A1AdapterClientTest {
+
+ protected static final Logger LOG = LoggerFactory.getLogger(A1AdapterClientTest.class);
+
+ @Mock
+ private SvcLogicService svcLogicService = null;
+ private A1AdapterClient a1AdapterClient;
+ private static String module = "A1-ADAPTER-API";
+ private static String mode = "sync";
+
+ @Before
+ public void setUp() throws Exception {
+ a1AdapterClient = new A1AdapterClient(svcLogicService);
+ }
+
+ @Test
+ public void test_execute_getPolicyType() throws SvcLogicException, InterruptedException, ExecutionException {
+ String rpc = "deleteA1Policy";
+ Properties params = new Properties();
+ Properties respProps = new Properties();
+ GetA1PolicyTypeOutputBuilder serviceData = new GetA1PolicyTypeOutputBuilder();
+ when(svcLogicService.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Properties.class)))
+ .thenReturn(respProps);
+ Properties response = a1AdapterClient.execute(module, rpc, null, mode, serviceData, params);
+ assertNotNull(response);
+ }
+
+ @Test
+ public void test_execute_getPolicyStatus() throws SvcLogicException, InterruptedException, ExecutionException {
+ String rpc = "getA1PolicyStatus";
+ Properties params = new Properties();
+ Properties respProps = new Properties();
+ GetA1PolicyStatusOutputBuilder serviceData = new GetA1PolicyStatusOutputBuilder();
+ when(svcLogicService.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Properties.class)))
+ .thenReturn(respProps);
+ Properties response = a1AdapterClient.execute(module, rpc, null, mode, serviceData, params);
+ assertNotNull(response);
+ }
+
+ @Test
+ public void test_execute_getPolicy() throws SvcLogicException, InterruptedException, ExecutionException {
+ String rpc = "getA1Policy";
+ Properties params = new Properties();
+ Properties respProps = new Properties();
+ GetA1PolicyOutputBuilder serviceData = new GetA1PolicyOutputBuilder();
+ when(svcLogicService.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Properties.class)))
+ .thenReturn(respProps);
+ Properties response = a1AdapterClient.execute(module, rpc, null, mode, serviceData, params);
+ assertNotNull(response);
+ }
+
+ @Test
+ public void test_execute_deletePolicy() throws SvcLogicException, InterruptedException, ExecutionException {
+ String rpc = "deleteA1Policy";
+ Properties params = new Properties();
+ Properties respProps = new Properties();
+ DeleteA1PolicyOutputBuilder serviceData = new DeleteA1PolicyOutputBuilder();
+ when(svcLogicService.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Properties.class)))
+ .thenReturn(respProps);
+ Properties response = a1AdapterClient.execute(module, rpc, null, mode, serviceData, params);
+ assertNotNull(response);
+ }
+
+ @Test
+ public void test_execute_putPolicy() throws SvcLogicException, InterruptedException, ExecutionException {
+ String rpc = "putA1Policy";
+ Properties params = new Properties();
+ Properties respProps = new Properties();
+ PutA1PolicyOutputBuilder serviceData = new PutA1PolicyOutputBuilder();
+ when(svcLogicService.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Properties.class)))
+ .thenReturn(respProps);
+ Properties response = a1AdapterClient.execute(module, rpc, null, mode, serviceData, params);
+ assertNotNull(response);
+ }
+}
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 901bc008..8901ab07 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
@@ -37,9 +37,21 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
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.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,50 +64,98 @@ import org.slf4j.LoggerFactory;
@RunWith(MockitoJUnitRunner.Silent.class)
public class A1AdapterProviderTest {
- protected static final Logger LOG = LoggerFactory.getLogger(A1AdapterProviderTest.class);
+ protected static final Logger LOG = LoggerFactory.getLogger(A1AdapterProviderTest.class);
- class A1AdapterProviderMock extends A1AdapterProvider {
+ class A1AdapterProviderMock extends A1AdapterProvider {
- A1AdapterProviderMock(final DataBroker dataBroker,
- final NotificationPublishService notificationPublishService,
- final RpcProviderRegistry rpcProviderRegistry, final A1AdapterClient A1AdapterClient) {
- super(dataBroker, mockNotificationPublishService, mockRpcProviderRegistry, a1AdapterClient);
+ 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;
+ @Mock
+ private NotificationPublishService mockNotificationPublishService;
+ @Mock
+ private RpcProviderRegistry mockRpcProviderRegistry;
+ @Mock
+ private A1AdapterClient a1AdapterClient;
+ 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);
+
+ }
+
+ @Test
+ public void test_deleteA1PolicyType() throws SvcLogicException, InterruptedException, ExecutionException {
+ String rpc = "deleteA1Policy";
+ Properties respProps = new Properties();
+ 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);
+ ListenableFuture<RpcResult<DeleteA1PolicyOutput>> result =
+ a1AdapterProviderMock.deleteA1Policy(inputBuilder.build());
+ assertEquals("200", String.valueOf(result.get().getResult().getHttpStatus()));
}
- }
-
- private A1AdapterProviderMock a1AdapterProviderMock = null;
- @Mock
- private DataBroker dataBroker;
- @Mock
- private NotificationPublishService mockNotificationPublishService;
- @Mock
- private RpcProviderRegistry mockRpcProviderRegistry;
- @Mock
- private A1AdapterClient a1AdapterClient;
- 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);
-
- }
-
- @Test
- public void test_getA1PolicyType()
- throws SvcLogicException, InterruptedException, ExecutionException {
- String rpc = "getA1PolicyType";
- Properties respProps = new Properties();
- 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);
- ListenableFuture<RpcResult<GetA1PolicyTypeOutput>> result =
- a1AdapterProviderMock.getA1PolicyType(inputBuilder.build());
- assertEquals("200", String.valueOf(result.get().getResult().getHttpStatus()));
- }
+ @Test
+ public void test_getA1Policy() throws SvcLogicException, InterruptedException, ExecutionException {
+ String rpc = "getA1Policy";
+ Properties respProps = new Properties();
+ 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);
+ ListenableFuture<RpcResult<GetA1PolicyOutput>> result = a1AdapterProviderMock.getA1Policy(inputBuilder.build());
+ assertEquals("200", String.valueOf(result.get().getResult().getHttpStatus()));
+ }
+
+ @Test
+ public void test_getA1PolicyType() throws SvcLogicException, InterruptedException, ExecutionException {
+ String rpc = "getA1PolicyType";
+ Properties respProps = new Properties();
+ 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);
+ ListenableFuture<RpcResult<GetA1PolicyTypeOutput>> result =
+ a1AdapterProviderMock.getA1PolicyType(inputBuilder.build());
+ assertEquals("200", String.valueOf(result.get().getResult().getHttpStatus()));
+ }
+
+ @Test
+ public void test_getA1PolicyStatus() throws SvcLogicException, InterruptedException, ExecutionException {
+ String rpc = "getA1PolicyStatus";
+ Properties respProps = new Properties();
+ 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);
+ ListenableFuture<RpcResult<GetA1PolicyStatusOutput>> result =
+ a1AdapterProviderMock.getA1PolicyStatus(inputBuilder.build());
+ assertEquals("200", String.valueOf(result.get().getResult().getHttpStatus()));
+ }
+
+ @Test
+ public void test_putA1Policy() throws SvcLogicException, InterruptedException, ExecutionException {
+ String rpc = "putA1Policy";
+ Properties respProps = new Properties();
+ 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);
+ ListenableFuture<RpcResult<PutA1PolicyOutput>> result = a1AdapterProviderMock.putA1Policy(inputBuilder.build());
+ assertEquals("200", String.valueOf(result.get().getResult().getHttpStatus()));
+ }
}