aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimoney, Dan (dt5972) <dtimoney@att.com>2019-02-26 15:30:23 -0500
committerTimoney, Dan (dt5972) <dtimoney@att.com>2019-02-26 15:30:23 -0500
commit95e5f382ad78e2f61b3289956caa8e36074380c0 (patch)
tree36112d1b708d8d8208f111d50f78fe4bebc1eee3
parentfc7132985898981337055ae4cef3104836fd16d1 (diff)
Remove unused code in vnfapi
vnfapi has code to implement the onDataTreeChanged event, but does not register itself as a listener. This code is not used and is untested, so should be removed. Change-Id: Ide4f2c38c5bb22871cd5f86135f791d5f51ed19b Issue-ID: SDNC-667 Signed-off-by: Timoney, Dan (dt5972) <dtimoney@att.com>
-rw-r--r--vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfApiProvider.java170
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfInstanceTopologyOperationTest.java2
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfapiProviderTestBase.java102
3 files changed, 3 insertions, 271 deletions
diff --git a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfApiProvider.java b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfApiProvider.java
index 46184b0a..15af1f22 100644
--- a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfApiProvider.java
+++ b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfApiProvider.java
@@ -155,7 +155,7 @@ import java.util.concurrent.Future;
* initialization / clean up methods.
*/
-public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataTreeChangeListener {
+public class VnfApiProvider implements AutoCloseable, VNFAPIService {
protected DataBroker dataBroker;
protected NotificationPublishService notificationService;
protected RpcProviderRegistry rpcRegistry;
@@ -277,175 +277,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataTreeCha
log.info("Successfully closed provider for " + APP_NAME);
}
- // On data change not used
- @Override
- public void onDataTreeChanged(Collection changes) {
-
- log.info(" IN ON DATA CHANGE: ");
-
- for (Object changeObj : changes) {
-
- if (changeObj instanceof DataTreeModification) {
-
- DataTreeModification change = (DataTreeModification) changeObj;
-
-
- boolean changed = false;
- WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
- DataObject updatedSubTree = change.getRootNode().getDataAfter();
-
- if (updatedSubTree != null) {
- if (log.isDebugEnabled()) {
- log.debug("updatedSubTree was non-null:" + updatedSubTree);
- }
- if (updatedSubTree instanceof Vnfs) {
- changed = isChanged(changed, (Vnfs) updatedSubTree);
- }
- if (updatedSubTree instanceof PreloadVnfs) {
- changed = isChanged(changed, (PreloadVnfs) updatedSubTree);
- }
- // 1610
- if (updatedSubTree instanceof PreloadVnfInstances) {
- changed = isChanged(changed, (PreloadVnfInstances) updatedSubTree);
- }
- // 1610
- if (updatedSubTree instanceof VnfInstances) {
- changed = isChanged(changed, (VnfInstances) updatedSubTree);
- }
- // 1610
- if (updatedSubTree instanceof PreloadVfModules) {
- changed = isChanged(changed, (PreloadVfModules) updatedSubTree);
- }
- // 1610
- if (updatedSubTree instanceof VfModules) {
- changed = isChanged(changed, (VfModules) updatedSubTree);
- }
- }
-
- // Do the write transaction only if something changed.
- if (changed) {
- CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = writeTransaction.submit();
- Futures.addCallback(checkedFuture, new FutureCallback<Void>() {
-
- @Override
- public void onSuccess(Void arg0) {
- log.debug("Successfully updated Service Status");
- }
-
- @Override
- public void onFailure(Throwable e) {
- log.debug("Failed updating Service Status", e);
- }
- }, executor);
- }
- }
- }
- }
-
- private boolean isChanged(boolean changed, VfModules updatedSubTree) {
- ArrayList<VfModuleList> vfModuleList =
- (ArrayList<VfModuleList>) updatedSubTree.getVfModuleList();
- if (vfModuleList != null) {
- for (VfModuleList entry : vfModuleList) {
- VfModuleServiceData vfModuleServiceData = entry.getVfModuleServiceData();
- ServiceStatus serviceStatus = entry.getServiceStatus();
- if (vfModuleServiceData != null && serviceStatus != null) {
- // VfModuleServiceData change detected, check the AckFinal indicator and request-status to
- // see if we need to proceed.
- return isChanged(changed, serviceStatus);
- }
- }
- }
- return changed;
- }
-
- private boolean isChanged(boolean changed, PreloadVfModules updatedSubTree) {
- ArrayList<VfModulePreloadList> vnfInstanceList =
- (ArrayList<VfModulePreloadList>) updatedSubTree.getVfModulePreloadList();
- if (vnfInstanceList != null) {
- for (VfModulePreloadList entry : vnfInstanceList) {
- VfModulePreloadData vnfInstancePreloadData = entry.getVfModulePreloadData();
- if (vnfInstancePreloadData != null) {
- return true;
- }
- }
- }
- return changed;
- }
-
- private boolean isChanged(boolean changed, VnfInstances updatedSubTree) {
- ArrayList<VnfInstanceList> vnfInstanceList =
- (ArrayList<VnfInstanceList>) updatedSubTree.getVnfInstanceList();
- if (vnfInstanceList != null) {
- for (VnfInstanceList entry : vnfInstanceList) {
- VnfInstanceServiceData vnfInstanceServiceData = entry.getVnfInstanceServiceData();
- ServiceStatus serviceStatus = entry.getServiceStatus();
- if (vnfInstanceServiceData != null && serviceStatus != null) {
- // VnfInstanceServiceData change detected, check the AckFinal indicator and request-status
- // to see if we need to proceed.
- return isChanged(changed, serviceStatus);
- }
- }
- }
- return changed;
- }
-
- private boolean isChanged(boolean changed, PreloadVnfInstances updatedSubTree) {
- ArrayList<VnfInstancePreloadList> vnfInstanceList =
- (ArrayList<VnfInstancePreloadList>) updatedSubTree
- .getVnfInstancePreloadList();
- if (vnfInstanceList != null) {
- for (VnfInstancePreloadList entry : vnfInstanceList) {
- VnfInstancePreloadData vnfInstancePreloadData = entry.getVnfInstancePreloadData();
- if (vnfInstancePreloadData != null) {
- return true;
- }
- }
- }
- return changed;
- }
-
- private boolean isChanged(boolean changed, PreloadVnfs updatedSubTree) {
- ArrayList<VnfPreloadList> vnfList =
- (ArrayList<VnfPreloadList>) updatedSubTree.getVnfPreloadList();
- if (vnfList != null) {
- for (VnfPreloadList entry : vnfList) {
- PreloadData preloadData = entry.getPreloadData();
- if (preloadData != null) {
- return true;
- }
- }
- }
- return changed;
- }
- private boolean isChanged(boolean changed, Vnfs updatedSubTree) {
- ArrayList<VnfList> vnfList = (ArrayList<VnfList>) updatedSubTree.getVnfList();
- if (vnfList != null) {
- for (VnfList entry : vnfList) {
- ServiceData serviceData = entry.getServiceData();
- ServiceStatus serviceStatus = entry.getServiceStatus();
- if (serviceData != null && serviceStatus != null) {
- //
- // ServiceData change detected, check the AckFinal indicator and request-status to see if we need to proceed.
- //
- return isChanged(changed, serviceStatus);
- }
- }
- }
- return changed;
- }
-
- private boolean isChanged(boolean changed, ServiceStatus serviceStatus) {
- if ((!"Y".equals(serviceStatus.getFinalIndicator())) && (RequestStatus.Synccomplete
- .equals(serviceStatus.getRequestStatus()))) {
- if (log.isDebugEnabled()) {
- log.debug("Final Indicator is not Y, calling handleServiceDataUpdated");
- }
- return true;
- }
- return changed;
- }
private static class Iso8601Util {
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfInstanceTopologyOperationTest.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfInstanceTopologyOperationTest.java
index 72c0c9d5..681b8d85 100644
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfInstanceTopologyOperationTest.java
+++ b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfInstanceTopologyOperationTest.java
@@ -309,4 +309,6 @@ public class VnfInstanceTopologyOperationTest extends VnfApiProviderTest {
.setVnfModelId(PRELOAD_TYPE)
.build();
}
+
+
}
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfapiProviderTestBase.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfapiProviderTestBase.java
index 7ce99ec6..92346047 100644
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfapiProviderTestBase.java
+++ b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfapiProviderTestBase.java
@@ -174,108 +174,6 @@ public class VnfapiProviderTestBase {
verify(vnfapiServiceRpcRegistration, times(1)).close();
}
- @Test public void onDataTreeChanged() throws Exception {
- DataTreeModification dtm = mock(DataTreeModification.class);
- DataObjectModification dom = mock(DataObjectModification.class);
-
-
- // instance of Vnfs
- Vnfs vnfs = mock(Vnfs.class);
- doReturn(dom).when(dtm).getRootNode();
- doReturn(vnfs).when(dom).getDataAfter();
- VnfList vnfList = mock(VnfList.class);
- ServiceData serviceData = mock(ServiceData.class);
- doReturn(serviceData).when(vnfList).getServiceData();
- ServiceStatus serviceStatus = mock(ServiceStatus.class);
- doReturn("N").when(serviceStatus).getFinalIndicator();
- doReturn(ServiceStatus.RequestStatus.Synccomplete).when(serviceStatus).getRequestStatus();
- doReturn(serviceStatus).when(vnfList).getServiceStatus();
- ArrayList<VnfList> vnfListList = new ArrayList<>();
- vnfListList.add(vnfList);
- doReturn(vnfListList).when(vnfs).getVnfList();
- doReturn(readWriteTransactionInDataChanged).when(dataBroker).newWriteOnlyTransaction();
- doReturn(checkedFuture).when(readWriteTransactionInDataChanged).submit();
-
- Collection dtmList = new LinkedList<DataTreeModification>();
- dtmList.add(dtm);
-
- vnfapiProvider.onDataTreeChanged(dtmList);
-
- verify(readWriteTransactionInDataChanged, times(1)).submit();
-
- // instance of PreloadVnfs
- PreloadVnfs preloadVnfs = mock(PreloadVnfs.class);
- doReturn(preloadVnfs).when(dom).getDataAfter();
- ArrayList<VnfPreloadList> vnfPreloadLists = new ArrayList<>();
- doReturn(vnfPreloadLists).when(preloadVnfs).getVnfPreloadList();
- PreloadData preloadData = mock(PreloadData.class);
- VnfPreloadList vnfPreloadList = mock(VnfPreloadList.class);
- doReturn(preloadData).when(vnfPreloadList).getPreloadData();
- vnfPreloadLists.add(vnfPreloadList);
-
- vnfapiProvider.onDataTreeChanged(dtmList);
-
- verify(readWriteTransactionInDataChanged, times(2)).submit();
-
- // instance of PreloadVnfInstances
- PreloadVnfInstances preloadVnfInstances = mock(PreloadVnfInstances.class);
- doReturn(preloadVnfInstances).when(dom).getDataAfter();
- ArrayList<VnfInstancePreloadList> vnfInstancePreloadLists = new ArrayList<>();
- doReturn(vnfInstancePreloadLists).when(preloadVnfInstances).getVnfInstancePreloadList();
- VnfInstancePreloadList vnfInstancePreloadList = mock(VnfInstancePreloadList.class);
- VnfInstancePreloadData vnfInstancePreloadData = mock(VnfInstancePreloadData.class);
- doReturn(vnfInstancePreloadData).when(vnfInstancePreloadList).getVnfInstancePreloadData();
- vnfInstancePreloadLists.add(vnfInstancePreloadList);
-
- vnfapiProvider.onDataTreeChanged(dtmList);
-
- verify(readWriteTransactionInDataChanged, times(3)).submit();
-
- // instance of VnfInstances
- VnfInstances vnfInstances = mock(VnfInstances.class);
- doReturn(vnfInstances).when(dom).getDataAfter();
- ArrayList<VnfInstanceList> vnfInstanceLists = new ArrayList<>();
- doReturn(vnfInstanceLists).when(vnfInstances).getVnfInstanceList();
- VnfInstanceList vnfInstanceList = mock(VnfInstanceList.class);
- vnfInstanceLists.add(vnfInstanceList);
- VnfInstanceServiceData vnfInstanceServiceData = mock(VnfInstanceServiceData.class);
- doReturn(vnfInstanceServiceData).when(vnfInstanceList).getVnfInstanceServiceData();
- doReturn(serviceStatus).when(vnfInstanceList).getServiceStatus();
-
- vnfapiProvider.onDataTreeChanged(dtmList);
-
- verify(readWriteTransactionInDataChanged, times(4)).submit();
-
- // instance of PreloadVfModules
- PreloadVfModules preloadVfModules = mock(PreloadVfModules.class);
- doReturn(preloadVfModules).when(dom).getDataAfter();
- ArrayList<VfModulePreloadList> vfModulePreloadLists = new ArrayList<>();
- doReturn(vfModulePreloadLists).when(preloadVfModules).getVfModulePreloadList();
- VfModulePreloadList vfModulePreloadList = mock(VfModulePreloadList.class);
- vfModulePreloadLists.add(vfModulePreloadList);
- VfModulePreloadData vfModulePreloadData = mock(VfModulePreloadData.class);
- doReturn(vfModulePreloadData).when(vfModulePreloadList).getVfModulePreloadData();
-
- vnfapiProvider.onDataTreeChanged(dtmList);
-
- verify(readWriteTransactionInDataChanged, times(5)).submit();
-
- // instance of VfModules
- VfModules vfModules = mock(VfModules.class);
- doReturn(preloadVfModules).when(dom).getDataAfter();
- ArrayList<VfModuleList> vfModuleLists = new ArrayList<>();
- doReturn(vfModuleLists).when(vfModules).getVfModuleList();
- VfModuleList vfModuleList = mock(VfModuleList.class);
- vfModuleLists.add(vfModuleList);
- VfModuleServiceData vfModuleServiceData = mock(VfModuleServiceData.class);
- doReturn(vfModuleServiceData).when(vfModuleList).getVfModuleServiceData();
- doReturn(serviceStatus).when(vfModuleList).getServiceStatus();
-
- vnfapiProvider.onDataTreeChanged(dtmList);
-
- verify(readWriteTransactionInDataChanged, times(6)).submit();
- }
-
/**
* Test Error case:
* <p>