diff options
author | Lathish <lathishbabu.ganesan@est.tech> | 2020-08-06 10:19:33 +0100 |
---|---|---|
committer | Lathish <lathishbabu.ganesan@est.tech> | 2020-08-13 22:29:47 +0100 |
commit | 5d0ad5f3d3158357183849ca329ac6999be6281d (patch) | |
tree | afd019d339ef1e9f872d2e5fbb5b6cbafb97038d /a1-adapter/a1-adapter-api/provider/src/test/java | |
parent | 0e3740a9011f59e18b0e65230d1ba61ec6ab8ba6 (diff) |
Initial A1 adapter api implmentation
Issue-ID: CCSDK-2604
Change-Id: If946b4f0cc92410e6b903928fd9cb2fd79996dc3
Signed-off-by: Lathish <lathishbabu.ganesan@est.tech>
Diffstat (limited to 'a1-adapter/a1-adapter-api/provider/src/test/java')
-rw-r--r-- | a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProviderTest.java | 101 |
1 files changed, 101 insertions, 0 deletions
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 new file mode 100644 index 00000000..901bc008 --- /dev/null +++ b/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProviderTest.java @@ -0,0 +1,101 @@ +/*- + * ============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.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.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.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.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.yangtools.yang.common.RpcResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class Tests all the methods in A1AdapterProvider + * + */ + +@RunWith(MockitoJUnitRunner.Silent.class) +public class A1AdapterProviderTest { + + 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; + @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())); + } +} |