summaryrefslogtreecommitdiffstats
path: root/sdnr/northbound/ranSlice/provider/src/test/java
diff options
context:
space:
mode:
authorSandeep Shah <sandeeplinux1068@gmail.com>2020-08-15 20:21:18 -0500
committerSandeep Shah <sandeeplinux1068@gmail.com>2020-08-17 21:45:07 -0500
commit94bf6cb9d8a780b38b860acab89d32e50ce16391 (patch)
treea2d64f47b2fcf41b015d574d7bbf2a37c0931496 /sdnr/northbound/ranSlice/provider/src/test/java
parente0ba85f7ef526aaa270f8a6cd5baad8e32eb920e (diff)
RAN Slice YANG Model and Associated Feature code
This includes YANG models to be used for RAN Slice use case/POC in Gulian, and associated ranSlice Karaf feature code. Issue-ID: CCSDK-2661 SIgned-off-by: SandeepLinux <Sandeep.Shah@ibm.com> Change-Id: I75ab8860c67bd25b7fdbcb5da734d705bfdce1b6
Diffstat (limited to 'sdnr/northbound/ranSlice/provider/src/test/java')
-rw-r--r--sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceProviderTest.java366
-rw-r--r--sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/TestRANSliceRpcInvocationException.java42
2 files changed, 408 insertions, 0 deletions
diff --git a/sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceProviderTest.java b/sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceProviderTest.java
new file mode 100644
index 000000000..f1e1524ec
--- /dev/null
+++ b/sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceProviderTest.java
@@ -0,0 +1,366 @@
+/*-
+ * ============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.sdnr.northbound.ranSlice;
+
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicLoader;
+import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
+import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
+import org.onap.ccsdk.sli.core.sli.provider.SvcLogicClassResolver;
+import org.onap.ccsdk.sli.core.sli.provider.SvcLogicPropertiesProviderImpl;
+import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl;
+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.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.*;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.common.header.CommonHeaderBuilder;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RANSliceProviderTest {
+
+ Logger LOG = LoggerFactory.getLogger(RANSliceProvider.class);
+ private RANSliceProvider provider;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ DataBroker dataBroker = mock(DataBroker.class);
+ NotificationPublishService notifyService = mock(NotificationPublishService.class);
+ RpcProviderRegistry rpcRegistry = mock(RpcProviderRegistry.class);
+ BindingAwareBroker.RpcRegistration<RanSliceApiService> rpcRegistration = (BindingAwareBroker.RpcRegistration<RanSliceApiService>) mock(BindingAwareBroker.RpcRegistration.class);
+ when(rpcRegistry.addRpcImplementation(any(Class.class), any(RanSliceApiService.class))).thenReturn(rpcRegistration);
+
+
+ // Load svclogic.properties and get a SvcLogicStore
+ InputStream propStr = RANSliceProviderTest.class.getResourceAsStream("/svclogic.properties");
+ Properties svcprops = new Properties();
+ svcprops.load(propStr);
+
+ SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops);
+
+ assertNotNull(store);
+
+ URL graphUrl = RANSliceProviderTest.class.getClassLoader().getResource("graphs");
+ LOG.info("Graph URL:" + graphUrl);
+
+
+ if (graphUrl == null) {
+ fail("Cannot find graphs directory");
+ }
+
+ SvcLogicLoader loader = new SvcLogicLoader(graphUrl.getPath(), store);
+ loader.loadAndActivate();
+
+ // Create a ServiceLogicService
+ SvcLogicServiceImpl svc = new SvcLogicServiceImpl(new SvcLogicPropertiesProviderImpl(),
+ new SvcLogicClassResolver());
+
+ // Finally ready to create sliapiProvider
+ RANSliceClient client = new RANSliceClient(svc);
+ provider = new RANSliceProvider(dataBroker, notifyService, rpcRegistry, client);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ provider.close();
+ }
+
+
+ @Test
+ public void testConfigureNearRTRIC() {
+ ConfigureNearRTRICInputBuilder builder = new ConfigureNearRTRICInputBuilder();
+
+ CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder();
+ hdrBuilder.setApiVer("1");
+ hdrBuilder.setFlags(null);
+ hdrBuilder.setOriginatorId("jUnit");
+ hdrBuilder.setRequestId("123");
+ hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date())));
+ builder.setCommonHeader(hdrBuilder.build());
+
+ builder.setAction(Action.Reconfigure);
+
+ try {
+ ConfigureNearRTRICOutput results = provider.configureNearRTRIC(builder.build()).get().getResult();
+ LOG.info("configureNearRTRIC returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage());
+ assert(results.getStatus().getCode() == 400);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Caught exception", e);
+ fail("configureNearRTRIC threw exception");
+ }
+
+ }
+
+
+ @Test
+ public void testInstantiateRANSlice() {
+ InstantiateRANSliceInputBuilder builder = new InstantiateRANSliceInputBuilder();
+
+ CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder();
+ hdrBuilder.setApiVer("1");
+ hdrBuilder.setFlags(null);
+ hdrBuilder.setOriginatorId("jUnit");
+ hdrBuilder.setRequestId("123");
+ hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date())));
+ builder.setCommonHeader(hdrBuilder.build());
+
+ builder.setAction(Action.Reconfigure);
+
+ try {
+ InstantiateRANSliceOutput results = provider.instantiateRANSlice(builder.build()).get().getResult();
+ LOG.info("instantiateRANSlice returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage());
+ assert(results.getStatus().getCode() == 400);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Caught exception", e);
+ fail("instantiateRANSlice threw exception");
+ }
+
+ }
+
+
+ @Test
+ public void testConfigureRANSliceInstance() {
+ ConfigureRANSliceInstanceInputBuilder builder = new ConfigureRANSliceInstanceInputBuilder();
+
+ CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder();
+ hdrBuilder.setApiVer("1");
+ hdrBuilder.setFlags(null);
+ hdrBuilder.setOriginatorId("jUnit");
+ hdrBuilder.setRequestId("123");
+ hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date())));
+ builder.setCommonHeader(hdrBuilder.build());
+
+ builder.setAction(Action.Reconfigure);
+
+ try {
+ ConfigureRANSliceInstanceOutput results = provider.configureRANSliceInstance(builder.build()).get().getResult();
+ LOG.info("configureRANSliceInstance returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage());
+ assert(results.getStatus().getCode() == 400);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Caught exception", e);
+ fail("configureRANSliceInstance threw exception");
+ }
+
+ }
+
+ @Test
+ public void testConfigureCU() {
+ ConfigureCUInputBuilder builder = new ConfigureCUInputBuilder();
+
+ CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder();
+ hdrBuilder.setApiVer("1");
+ hdrBuilder.setFlags(null);
+ hdrBuilder.setOriginatorId("jUnit");
+ hdrBuilder.setRequestId("123");
+ hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date())));
+ builder.setCommonHeader(hdrBuilder.build());
+
+ builder.setAction(Action.Reconfigure);
+
+ try {
+ ConfigureCUOutput results = provider.configureCU(builder.build()).get().getResult();
+ LOG.info("configureCU returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage());
+ assert(results.getStatus().getCode() == 400);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Caught exception", e);
+ fail("configureCU threw exception");
+ }
+
+ }
+
+
+ @Test
+ public void testConfigureDU() {
+ ConfigureDUInputBuilder builder = new ConfigureDUInputBuilder();
+
+ CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder();
+ hdrBuilder.setApiVer("1");
+ hdrBuilder.setFlags(null);
+ hdrBuilder.setOriginatorId("jUnit");
+ hdrBuilder.setRequestId("123");
+ hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date())));
+ builder.setCommonHeader(hdrBuilder.build());
+
+ builder.setAction(Action.Reconfigure);
+
+ try {
+ ConfigureDUOutput results = provider.configureDU(builder.build()).get().getResult();
+ LOG.info("configureDU returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage());
+ assert(results.getStatus().getCode() == 400);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Caught exception", e);
+ fail("configureDU threw exception");
+ }
+
+ }
+
+ @Test
+ public void testActivateRANSliceInstance() {
+ ActivateRANSliceInstanceInputBuilder builder = new ActivateRANSliceInstanceInputBuilder();
+
+ CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder();
+ hdrBuilder.setApiVer("1");
+ hdrBuilder.setFlags(null);
+ hdrBuilder.setOriginatorId("jUnit");
+ hdrBuilder.setRequestId("123");
+ hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date())));
+ builder.setCommonHeader(hdrBuilder.build());
+
+ builder.setAction(Action.Reconfigure);
+
+ try {
+ ActivateRANSliceInstanceOutput results = provider.activateRANSliceInstance(builder.build()).get().getResult();
+ LOG.info("activateRANSliceInstance returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage());
+ assert(results.getStatus().getCode() == 400);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Caught exception", e);
+ fail("activateRANSliceInstance threw exception");
+ }
+
+ }
+
+
+ @Test
+ public void testDeactivateRANSliceInstance() {
+ DeactivateRANSliceInstanceInputBuilder builder = new DeactivateRANSliceInstanceInputBuilder();
+
+ CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder();
+ hdrBuilder.setApiVer("1");
+ hdrBuilder.setFlags(null);
+ hdrBuilder.setOriginatorId("jUnit");
+ hdrBuilder.setRequestId("123");
+ hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date())));
+ builder.setCommonHeader(hdrBuilder.build());
+
+ builder.setAction(Action.Reconfigure);
+
+ try {
+ DeactivateRANSliceInstanceOutput results = provider.deactivateRANSliceInstance(builder.build()).get().getResult();
+ LOG.info("deactivateRANSliceInstance returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage());
+ assert(results.getStatus().getCode() == 400);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Caught exception", e);
+ fail("deactivateRANSliceInstance threw exception");
+ }
+
+ }
+
+ @Test
+ public void testTerminateRANSliceInstance() {
+ TerminateRANSliceInstanceInputBuilder builder = new TerminateRANSliceInstanceInputBuilder();
+
+ CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder();
+ hdrBuilder.setApiVer("1");
+ hdrBuilder.setFlags(null);
+ hdrBuilder.setOriginatorId("jUnit");
+ hdrBuilder.setRequestId("123");
+ hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date())));
+ builder.setCommonHeader(hdrBuilder.build());
+
+ builder.setAction(Action.Reconfigure);
+
+ try {
+ TerminateRANSliceInstanceOutput results = provider.terminateRANSliceInstance(builder.build()).get().getResult();
+ LOG.info("terminateRANSliceInstance returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage());
+ assert(results.getStatus().getCode() == 400);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Caught exception", e);
+ fail("terminateRANSliceInstance threw exception");
+ }
+
+ }
+
+ @Test
+ public void testDetermineRANSliceResources() {
+ DetermineRANSliceResourcesInputBuilder builder = new DetermineRANSliceResourcesInputBuilder();
+
+ CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder();
+ hdrBuilder.setApiVer("1");
+ hdrBuilder.setFlags(null);
+ hdrBuilder.setOriginatorId("jUnit");
+ hdrBuilder.setRequestId("123");
+ hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date())));
+ builder.setCommonHeader(hdrBuilder.build());
+
+ builder.setAction(Action.Reconfigure);
+
+ try {
+ DetermineRANSliceResourcesOutput results = provider.determineRANSliceResources(builder.build()).get().getResult();
+ LOG.info("determineRANSliceResources returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage());
+ assert(results.getStatus().getCode() == 400);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Caught exception", e);
+ fail("determineRANSliceResources threw exception");
+ }
+
+ }
+
+
+ @Test
+ public void testConfigNotification() {
+ ConfigNotificationInputBuilder builder = new ConfigNotificationInputBuilder();
+
+ CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder();
+ hdrBuilder.setApiVer("1");
+ hdrBuilder.setFlags(null);
+ hdrBuilder.setOriginatorId("jUnit");
+ hdrBuilder.setRequestId("123");
+ hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date())));
+ builder.setCommonHeader(hdrBuilder.build());
+
+ builder.setAction(Action.Reconfigure);
+
+ try {
+ ConfigNotificationOutput results = provider.configNotification(builder.build()).get().getResult();
+ LOG.info("configNotification returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage());
+ assert(results.getStatus().getCode() == 400);
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Caught exception", e);
+ fail("configNotification threw exception");
+ }
+
+ }
+
+
+ }
diff --git a/sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/TestRANSliceRpcInvocationException.java b/sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/TestRANSliceRpcInvocationException.java
new file mode 100644
index 000000000..4c32c22bf
--- /dev/null
+++ b/sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/TestRANSliceRpcInvocationException.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.sdnr.northbound.ranSlice;
+
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.status.Status;
+
+
+public class TestRANSliceRpcInvocationException {
+
+ @Test(expected = SvcLogicException.class)
+ public void testRANSliceRpcInvocationException() throws SvcLogicException{
+ Status status = null;
+ CommonHeader commonHeader = null;
+ RANSliceRpcInvocationException exception = new RANSliceRpcInvocationException(status, commonHeader);
+ assert(exception.getStatus() == status);
+ assert(exception.getCommonHeader() == commonHeader);
+ throw exception;
+ }
+}