summaryrefslogtreecommitdiffstats
path: root/northbound/asdcApi
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2021-01-29 17:42:42 +0000
committerDan Timoney <dtimoney@att.com>2021-01-29 17:42:42 +0000
commit0e4e58bf061df695341ac250beb97a978cefdaf7 (patch)
tree06539b81ae2f3bbeddd3f7f30199cdd200a8480c /northbound/asdcApi
parentce4e5f9a00d2677495240ad367b9bfc4b74752d0 (diff)
Revert "migrate sli to alu-SR1"
This reverts commit ce4e5f9a00d2677495240ad367b9bfc4b74752d0. Reason for revert: ODL upgrade changes need to be backed out until issues in ccsdk/features are resolved. Change-Id: I168e2519e37f3eee61609d0da890c14db49ec49e
Diffstat (limited to 'northbound/asdcApi')
-rwxr-xr-xnorthbound/asdcApi/provider/pom.xml20
-rw-r--r--northbound/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiProvider.java49
-rw-r--r--northbound/asdcApi/provider/src/main/resources/OSGI-INF/blueprint/asdc-blueprint.xml32
-rw-r--r--northbound/asdcApi/provider/src/main/resources/org/opendaylight/blueprint/asdc-blueprint.xml9
-rw-r--r--northbound/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java203
5 files changed, 188 insertions, 125 deletions
diff --git a/northbound/asdcApi/provider/pom.xml b/northbound/asdcApi/provider/pom.xml
index a7ced7ad2..19e5660f7 100755
--- a/northbound/asdcApi/provider/pom.xml
+++ b/northbound/asdcApi/provider/pom.xml
@@ -35,8 +35,8 @@
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-api</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-api</artifactId>
</dependency>
<dependency>
@@ -54,18 +54,24 @@
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-test-model</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-test-model</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-binding-dom-adapter</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <type>test-jar</type>
+ <classifier>tests</classifier>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
diff --git a/northbound/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiProvider.java b/northbound/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiProvider.java
index d8cf963b5..1a79f8c41 100644
--- a/northbound/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiProvider.java
+++ b/northbound/asdcApi/provider/src/main/java/org/onap/ccsdk/sli/northbound/asdcapi/AsdcApiProvider.java
@@ -8,9 +8,9 @@
* 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.
@@ -21,22 +21,19 @@
package org.onap.ccsdk.sli.northbound.asdcapi;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.RpcProviderService;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.yang.gen.v1.http.xmlns.onap.org.asdc.license.model._1._0.rev160427.vf.license.model.grouping.VfLicenseModel;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.ASDCAPIService;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.Artifacts;
@@ -52,13 +49,17 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.artifacts.ArtifactB
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.artifacts.ArtifactKey;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.vf.license.model.versions.VfLicenseModelVersion;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.vf.license.model.versions.VfLicenseModelVersionBuilder;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+
/**
* Defines a base implementation for your provider. This class extends from a helper class
* which provides storage for the most commonly used components of the MD-SAL. Additionally the
@@ -103,14 +104,14 @@ public class AsdcApiProvider implements AutoCloseable, ASDCAPIService {
private final ExecutorService executor;
protected DataBroker dataBroker;
protected NotificationPublishService notificationService;
- protected RpcProviderService rpcRegistry;
+ protected RpcProviderRegistry rpcRegistry;
private final AsdcApiSliClient asdcApiSliClient;
- protected ObjectRegistration<ASDCAPIService> rpcRegistration;
+ protected BindingAwareBroker.RpcRegistration<ASDCAPIService> rpcRegistration;
public AsdcApiProvider(final DataBroker dataBroker,
final NotificationPublishService notificationPublishService,
- final RpcProviderService rpcProviderRegistry,
+ final RpcProviderRegistry rpcProviderRegistry,
final AsdcApiSliClient asdcApiSliClient) {
LOG.info("Creating provider for {}", APPLICATION_NAME);
@@ -129,7 +130,7 @@ public class AsdcApiProvider implements AutoCloseable, ASDCAPIService {
if (rpcRegistration == null) {
if (rpcRegistry != null) {
- rpcRegistration = rpcRegistry.registerRpcImplementation(
+ rpcRegistration = rpcRegistry.addRpcImplementation(
ASDCAPIService.class, this);
LOG.info("Initialization complete for {}", APPLICATION_NAME);
} else {
@@ -151,7 +152,7 @@ public class AsdcApiProvider implements AutoCloseable, ASDCAPIService {
try {
- FluentFuture<? extends @NonNull CommitInfo> checkedFuture = t.commit();
+ CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = t.submit();
checkedFuture.get();
LOG.info("Create Containers succeeded!: ");
@@ -179,7 +180,7 @@ public class AsdcApiProvider implements AutoCloseable, ASDCAPIService {
InstanceIdentifier.<Artifacts>builder(Artifacts.class)
.child(Artifact.class, new ArtifactKey(aName, aVersion)).build();
Optional<Artifact> data = null;
- try(ReadTransaction readTx = dataBroker.newReadOnlyTransaction()) {
+ try(ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction()) {
data = (Optional<Artifact>) readTx.read(LogicalDatastoreType.CONFIGURATION, artifactInstanceId).get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Caught Exception reading MD-SAL for ["+aName+","+ aVersion+"] " ,e);
@@ -210,7 +211,7 @@ public class AsdcApiProvider implements AutoCloseable, ASDCAPIService {
tx.merge(LogicalDatastoreType.CONFIGURATION, path,
artifact);
- tx.commit().get();
+ tx.submit().checkedGet();
} catch (Exception e) {
LOG.error("Caught exception trying to add artifact entry", e);
}
@@ -244,7 +245,7 @@ public class AsdcApiProvider implements AutoCloseable, ASDCAPIService {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.merge(LogicalDatastoreType.CONFIGURATION, path,
version);
- tx.commit().get();
+ tx.submit().checkedGet();
} catch (Exception e) {
LOG.error(
"Caught exception trying to save entry to MD-SAL",
@@ -271,7 +272,7 @@ public class AsdcApiProvider implements AutoCloseable, ASDCAPIService {
tx.merge(LogicalDatastoreType.CONFIGURATION, path,
version);
- tx.commit().get();
+ tx.submit().checkedGet();
} catch (Exception e) {
LOG.error(
"Caught exception trying to save entry to MD-SAL",
diff --git a/northbound/asdcApi/provider/src/main/resources/OSGI-INF/blueprint/asdc-blueprint.xml b/northbound/asdcApi/provider/src/main/resources/OSGI-INF/blueprint/asdc-blueprint.xml
new file mode 100644
index 000000000..9ad08d3db
--- /dev/null
+++ b/northbound/asdcApi/provider/src/main/resources/OSGI-INF/blueprint/asdc-blueprint.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <reference id="svcLogicService"
+ interface="org.onap.ccsdk.sli.core.sli.provider.SvcLogicService" />
+
+ <bean id="client" class="org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiSliClient">
+ <argument ref="svcLogicService" />
+ </bean>
+
+ <reference id="dataBroker"
+ interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+ odl:type="default" />
+
+ <reference id="notificationService"
+ interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"
+ odl:type="default" />
+
+ <reference id="rpcRegistry"
+ interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"
+ odl:type="default" />
+
+ <bean id="provider" class="org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiProvider">
+ <argument ref="dataBroker" />
+ <argument ref="notificationService" />
+ <argument ref="rpcRegistry" />
+ <argument ref="client" />
+ </bean>
+
+</blueprint> \ No newline at end of file
diff --git a/northbound/asdcApi/provider/src/main/resources/org/opendaylight/blueprint/asdc-blueprint.xml b/northbound/asdcApi/provider/src/main/resources/org/opendaylight/blueprint/asdc-blueprint.xml
index 68925b115..9ad08d3db 100644
--- a/northbound/asdcApi/provider/src/main/resources/org/opendaylight/blueprint/asdc-blueprint.xml
+++ b/northbound/asdcApi/provider/src/main/resources/org/opendaylight/blueprint/asdc-blueprint.xml
@@ -11,13 +11,16 @@
</bean>
<reference id="dataBroker"
- interface="org.opendaylight.mdsal.binding.api.DataBroker" />
+ interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+ odl:type="default" />
<reference id="notificationService"
- interface="org.opendaylight.mdsal.binding.api.NotificationPublishService" />
+ interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"
+ odl:type="default" />
<reference id="rpcRegistry"
- interface="org.opendaylight.mdsal.binding.api.RpcProviderService" />
+ interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"
+ odl:type="default" />
<bean id="provider" class="org.onap.ccsdk.sli.northbound.asdcapi.AsdcApiProvider">
<argument ref="dataBroker" />
diff --git a/northbound/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java b/northbound/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java
index 15ed92776..1f266365c 100644
--- a/northbound/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java
+++ b/northbound/asdcApi/provider/src/test/java/org/onap/ccsdk/sli/northbound/asdcapi/TestAsdcApiApi.java
@@ -21,95 +21,116 @@
package org.onap.ccsdk.sli.northbound.asdcapi;
-public class TestAsdcApiApi {//extends AbstractConcurrentDataBrokerTest {
-
-// private AsdcApiProvider asdcApiProvider;
-// private static final Logger LOG = LoggerFactory.getLogger(AsdcApiProvider.class);
-//
-// @Before
-// public void setUp() throws Exception {
-// if (null == asdcApiProvider) {
-// DataBroker dataBroker = getDataBroker();
-// NotificationPublishService mockNotification = mock(NotificationPublishService.class);
-// RpcProviderService mockRpcRegistry = mock(RpcProviderService.class);
-// AsdcApiSliClient mockSliClient = mock(AsdcApiSliClient.class);
-// Properties respProps = new Properties();
-// respProps.setProperty("error-code", "200");
-// respProps.setProperty("error-message", "Success");
-//
-// when(mockSliClient.hasGraph("ASDC-API", "vf-license-model-update" , null, "sync")).thenReturn(true);
-// when(mockSliClient.execute("ASDC-API", "vf-license-model-update", null, "sync", respProps)).thenReturn(respProps);
-//
-// asdcApiProvider = new AsdcApiProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient);
-// }
-// }
-//
-// //Testcase should return error 503 when No service logic active for ASDC-API.
-// @Test
-// public void testVfLicenseModelUpdate() {
-//
-// VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder();
-//
-// inputBuilder.setArtifactName("abc");
-// inputBuilder.setArtifactVersion("1");
-//
-// // TODO: currently initialize SvcLogicServiceClient is failing, need to fix
-// java.util.concurrent.Future<RpcResult<VfLicenseModelUpdateOutput>> future = asdcApiProvider
-// .vfLicenseModelUpdate(inputBuilder.build());
-// RpcResult<VfLicenseModelUpdateOutput> rpcResult = null;
-// try {
-// rpcResult = future.get();
-// } catch (Exception e) {
-// fail("Error : " + e);
-// }
-// LOG.info("result: {}", rpcResult);
-// assertEquals("200", rpcResult.getResult().getAsdcApiResponseCode());
-// }
-//
-// //Input parameter validation
-// @Test
-// public void testVfLicenseModelUpdateInputValidation() {
-//
-// VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder();
-//
-// inputBuilder.setArtifactName("abc");
-// inputBuilder.setArtifactVersion("1");
-//
-// java.util.concurrent.Future<RpcResult<VfLicenseModelUpdateOutput>> future = asdcApiProvider
-// .vfLicenseModelUpdate(null);
-// assertNull(future);
-// }
-//
-// @Test
-// public void testVfLicenseModelUpdateValidation1() {
-//
-// VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder();
-//
-// inputBuilder.setArtifactName("license1");
-// inputBuilder.setArtifactVersion("version1");
-//
-// VfLicenseModelBuilder vfLicenseModelBuilder = new VfLicenseModelBuilder();
-// vfLicenseModelBuilder.setVfId("123");
-// vfLicenseModelBuilder.setVendorName("acme");
-// inputBuilder.setVfLicenseModel(vfLicenseModelBuilder.build());
-//
-//
-// java.util.concurrent.Future<RpcResult<VfLicenseModelUpdateOutput>> future = asdcApiProvider
-// .vfLicenseModelUpdate(inputBuilder.build());
-// RpcResult<VfLicenseModelUpdateOutput> rpcResult = null;
-// try {
-// rpcResult = future.get();
-// } catch (Exception e) {
-// fail("Error : " + e);
-// }
-// }
-//
-//
-//
-//
-// @Test
-// public void testAddArtifactVersion() {
-// asdcApiProvider.addArtifactVersion("artifact1",
-// "version1");
-// }
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.http.xmlns.onap.org.asdc.license.model._1._0.rev160427.vf.license.model.grouping.VfLicenseModelBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev170201.VfLicenseModelUpdateOutput;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Properties;
+
+public class TestAsdcApiApi extends AbstractConcurrentDataBrokerTest {
+
+ private AsdcApiProvider asdcApiProvider;
+ private static final Logger LOG = LoggerFactory.getLogger(AsdcApiProvider.class);
+
+ @Before
+ public void setUp() throws Exception {
+ if (null == asdcApiProvider) {
+ DataBroker dataBroker = getDataBroker();
+ NotificationPublishService mockNotification = mock(NotificationPublishService.class);
+ RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class);
+ AsdcApiSliClient mockSliClient = mock(AsdcApiSliClient.class);
+ Properties respProps = new Properties();
+ respProps.setProperty("error-code", "200");
+ respProps.setProperty("error-message", "Success");
+
+ when(mockSliClient.hasGraph("ASDC-API", "vf-license-model-update" , null, "sync")).thenReturn(true);
+ when(mockSliClient.execute("ASDC-API", "vf-license-model-update", null, "sync", respProps)).thenReturn(respProps);
+
+ asdcApiProvider = new AsdcApiProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient);
+ }
+ }
+
+ //Testcase should return error 503 when No service logic active for ASDC-API.
+ @Test
+ public void testVfLicenseModelUpdate() {
+
+ VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder();
+
+ inputBuilder.setArtifactName("abc");
+ inputBuilder.setArtifactVersion("1");
+
+ // TODO: currently initialize SvcLogicServiceClient is failing, need to fix
+ java.util.concurrent.Future<RpcResult<VfLicenseModelUpdateOutput>> future = asdcApiProvider
+ .vfLicenseModelUpdate(inputBuilder.build());
+ RpcResult<VfLicenseModelUpdateOutput> rpcResult = null;
+ try {
+ rpcResult = future.get();
+ } catch (Exception e) {
+ fail("Error : " + e);
+ }
+ LOG.info("result: {}", rpcResult);
+ assertEquals("200", rpcResult.getResult().getAsdcApiResponseCode());
+ }
+
+ //Input parameter validation
+ @Test
+ public void testVfLicenseModelUpdateInputValidation() {
+
+ VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder();
+
+ inputBuilder.setArtifactName("abc");
+ inputBuilder.setArtifactVersion("1");
+
+ java.util.concurrent.Future<RpcResult<VfLicenseModelUpdateOutput>> future = asdcApiProvider
+ .vfLicenseModelUpdate(null);
+ assertNull(future);
+ }
+
+ @Test
+ public void testVfLicenseModelUpdateValidation1() {
+
+ VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder();
+
+ inputBuilder.setArtifactName("license1");
+ inputBuilder.setArtifactVersion("version1");
+
+ VfLicenseModelBuilder vfLicenseModelBuilder = new VfLicenseModelBuilder();
+ vfLicenseModelBuilder.setVfId("123");
+ vfLicenseModelBuilder.setVendorName("acme");
+ inputBuilder.setVfLicenseModel(vfLicenseModelBuilder.build());
+
+
+ java.util.concurrent.Future<RpcResult<VfLicenseModelUpdateOutput>> future = asdcApiProvider
+ .vfLicenseModelUpdate(inputBuilder.build());
+ RpcResult<VfLicenseModelUpdateOutput> rpcResult = null;
+ try {
+ rpcResult = future.get();
+ } catch (Exception e) {
+ fail("Error : " + e);
+ }
+ }
+
+
+
+
+ @Test
+ public void testAddArtifactVersion() {
+ asdcApiProvider.addArtifactVersion("artifact1",
+ "version1");
+ }
}