Fix VNFM driver not sending LCN to VF-C 87/46687/1
authorDenes Nemeth <denes.nemeth@nokia.com>
Tue, 8 May 2018 20:33:57 +0000 (22:33 +0200)
committerDenes Nemeth <denes.nemeth@nokia.com>
Tue, 8 May 2018 20:33:57 +0000 (22:33 +0200)
Change-Id: I340881a322aefcb353f6d18989f931e1495cbdec
Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com>
Issue-ID: VFC-728

nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcNotificationSender.java

index b44c153..caecee0 100644 (file)
@@ -54,7 +54,7 @@ public class VfcNotificationSender implements INotificationSender {
 
     @Override
     public void processNotification(VnfLifecycleChangeNotification recievedNotification, OperationExecution operationExecution, Optional<ReportedAffectedConnectionPoints> affectedCps, String vimId, String vnfmId) {
-        VNFLCMNotification notificationToSend = new VNFLCMNotification();
+        VNFLCMNotification notificationToSend = buildNotification();
         notificationToSend.setJobId(extractOnapJobId(operationExecution.getOperationParams()));
         notificationToSend.setOperation(getOperation(operationExecution, recievedNotification.getOperation()));
         notificationToSend.setVnfInstanceId(recievedNotification.getVnfInstanceId());
@@ -69,12 +69,21 @@ public class VfcNotificationSender implements INotificationSender {
         sendNotification(vnfmId, notificationToSend);
     }
 
+    private VNFLCMNotification buildNotification() {
+        VNFLCMNotification notificationToSend = new VNFLCMNotification();
+        notificationToSend.setAffectedVirtualStorage(new ArrayList<>());
+        notificationToSend.setAffectedVnfc(new ArrayList<>());
+        notificationToSend.setAffectedVl(new ArrayList<>());
+        notificationToSend.setAffectedCp(new ArrayList<>());
+        return notificationToSend;
+    }
+
     private void sendNotification(String vnfmId, VNFLCMNotification notification) {
         try {
             if (logger.isInfoEnabled()) {
                 logger.info("Sending LCN: {}", new Gson().toJson(notification));
             }
-            vfcRestApiProvider.getNsLcmApi().vNFLCMNotification(vnfmId, notification.getVnfInstanceId(), notification);
+            vfcRestApiProvider.getNsLcmApi().vNFLCMNotification(vnfmId, notification.getVnfInstanceId(), notification).blockingFirst(null);
         } catch (Exception e) {
             throw buildFatalFailure(logger, "Unable to send LCN to VF-C", e);
         }
@@ -102,7 +111,6 @@ public class VfcNotificationSender implements INotificationSender {
 
     private void addAffectedVnfcs(String vimId, String vnfId, VNFLCMNotification notificationToSend, VnfLifecycleChangeNotification request) {
         if (request.getAffectedVnfcs() != null) {
-            notificationToSend.setAffectedVnfc(new ArrayList<>());
             for (com.nokia.cbam.lcm.v32.model.AffectedVnfc affectedVnfc : request.getAffectedVnfcs()) {
                 org.onap.vnfmdriver.model.AffectedVnfc onapVnfc = new org.onap.vnfmdriver.model.AffectedVnfc();
                 onapVnfc.setChangeType(getChangeType(affectedVnfc.getChangeType()));
@@ -118,7 +126,6 @@ public class VfcNotificationSender implements INotificationSender {
 
     private void addAffectedVirtualLinks(VnfLifecycleChangeNotification request, VNFLCMNotification notification) {
         if (request.getAffectedVirtualLinks() != null) {
-            notification.setAffectedVl(new ArrayList<>());
             for (com.nokia.cbam.lcm.v32.model.AffectedVirtualLink affectedVirtualLink : request.getAffectedVirtualLinks()) {
                 org.onap.vnfmdriver.model.AffectedVirtualLink onapVirtualLink = new org.onap.vnfmdriver.model.AffectedVirtualLink();
                 onapVirtualLink.setVlInstanceId(request.getVnfInstanceId() + SEPARATOR + affectedVirtualLink.getId());
@@ -146,7 +153,6 @@ public class VfcNotificationSender implements INotificationSender {
 
     private void addAffectedCps(String vimId, VNFLCMNotification notificationToSend, Optional<ReportedAffectedConnectionPoints> affectedCps) {
         if (affectedCps.isPresent()) {
-            notificationToSend.setAffectedCp(new ArrayList<>());
             for (ReportedAffectedCp pre : affectedCps.get().getPre()) {
                 Optional<VnfCpNotificationType> changeType = getChangeType(affectedCps.get(), pre);
                 if (of(VnfCpNotificationType.REMOVED).equals(changeType)) {
index 5115aef..1312b9d 100644 (file)
@@ -491,7 +491,7 @@ public class LifecycleManager {
      */
     public void deleteVnf(String vnfmId, String vnfId) {
         logger.info("Deleting VNF with {} identifier", vnfId);
-        cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdDelete(vnfId, NOKIA_LCM_API_VERSION).blockingFirst();
+        cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdDelete(vnfId, NOKIA_LCM_API_VERSION).blockingFirst(null);
         logger.info("The VNF with {} identifier has been deleted", vnfId);
     }
 
index 06cb643..ed6375f 100644 (file)
@@ -62,7 +62,7 @@ public class TestVfcNotificationSender extends TestBase {
     public void init() throws Exception {
         vfcNotificationSender = new VfcNotificationSender(vfcRestApiProvider);
         setField(VfcNotificationSender.class, "logger", logger);
-        when(nsLcmApi.vNFLCMNotification(eq(VNFM_ID), eq(VNF_ID), sentLcnToVfc.capture())).thenReturn(null);
+        when(nsLcmApi.vNFLCMNotification(eq(VNFM_ID), eq(VNF_ID), sentLcnToVfc.capture())).thenReturn(VOID_OBSERVABLE.value());
         instantiationOperation.setId("instantiationOperationExecutionId");
         instantiationOperation.setStartTime(OffsetDateTime.now());
         instantiationOperation.setOperationType(OperationType.INSTANTIATE);
@@ -115,15 +115,16 @@ public class TestVfcNotificationSender extends TestBase {
         vfcNotificationSender.processNotification(recievedLcn, instantiationOperation, empty(), VIM_ID, VNFM_ID);
         //verify
         assertEquals(1, sentLcnToVfc.getAllValues().size());
-        assertNull(sentLcnToVfc.getValue().getAffectedVl());
-        assertNull(sentLcnToVfc.getValue().getAffectedVnfc());
-        assertNull(sentLcnToVfc.getValue().getAffectedCp());
-        assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVl().size());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVnfc().size());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedCp().size());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size());
 
         assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId());
         assertEquals(org.onap.vnfmdriver.model.OperationType.INSTANTIATE, sentLcnToVfc.getValue().getOperation());
         assertEquals(VnfLcmNotificationStatus.START, sentLcnToVfc.getValue().getStatus());
         assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId());
+        VOID_OBSERVABLE.assertCalled();
     }
 
     /**
@@ -223,11 +224,12 @@ public class TestVfcNotificationSender extends TestBase {
         assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName());
         assertEquals(VnfCpNotificationType.ADDED, actualAffectedCp.getChangeType());
 
-        assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size());
         assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId());
         assertEquals(org.onap.vnfmdriver.model.OperationType.INSTANTIATE, sentLcnToVfc.getValue().getOperation());
         assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus());
         assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId());
+        VOID_OBSERVABLE.assertCalled();
     }
 
     /**
@@ -288,6 +290,7 @@ public class TestVfcNotificationSender extends TestBase {
         assertEquals("portProviderId", actualAffectedCp.getPortResource().getResourceid());
         assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName());
         assertEquals(VnfCpNotificationType.ADDED, actualAffectedCp.getChangeType());
+        VOID_OBSERVABLE.assertCalled();
     }
 
     /**
@@ -387,11 +390,12 @@ public class TestVfcNotificationSender extends TestBase {
         assertEquals("portProviderId", actualAffectedCp.getPortResource().getResourceid());
         assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName());
 
-        assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size());
         assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId());
         assertEquals(org.onap.vnfmdriver.model.OperationType.TERMINAL, sentLcnToVfc.getValue().getOperation());
         assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus());
         assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId());
+        VOID_OBSERVABLE.assertCalled();
     }
 
     /**
@@ -508,11 +512,12 @@ public class TestVfcNotificationSender extends TestBase {
         assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName());
         assertEquals(VnfCpNotificationType.CHANGED, actualAffectedCp.getChangeType());
 
-        assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size());
         assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId());
         assertEquals(org.onap.vnfmdriver.model.OperationType.HEAL, sentLcnToVfc.getValue().getOperation());
         assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus());
         assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId());
+        VOID_OBSERVABLE.assertCalled();
     }
 
     /**
@@ -620,11 +625,12 @@ public class TestVfcNotificationSender extends TestBase {
         assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName());
         assertEquals(VnfCpNotificationType.ADDED, actualAffectedCp.getChangeType());
 
-        assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size());
         assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId());
         assertEquals(org.onap.vnfmdriver.model.OperationType.SCALEOUT, sentLcnToVfc.getValue().getOperation());
         assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus());
         assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId());
+        VOID_OBSERVABLE.assertCalled();
     }
 
     /**
@@ -733,11 +739,12 @@ public class TestVfcNotificationSender extends TestBase {
         assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName());
         assertEquals(VnfCpNotificationType.REMOVED, actualAffectedCp.getChangeType());
 
-        assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size());
         assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId());
         assertEquals(org.onap.vnfmdriver.model.OperationType.SCALEIN, sentLcnToVfc.getValue().getOperation());
         assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus());
         assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId());
+        VOID_OBSERVABLE.assertCalled();
     }
 
 
@@ -764,15 +771,16 @@ public class TestVfcNotificationSender extends TestBase {
         //verify
         assertEquals(1, sentLcnToVfc.getAllValues().size());
 
-        assertNull(sentLcnToVfc.getValue().getAffectedVl());
-        assertNull(sentLcnToVfc.getValue().getAffectedVnfc());
-        assertNull(sentLcnToVfc.getValue().getAffectedCp());
-        assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVl().size());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVnfc().size());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedCp().size());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size());
         assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId());
         assertEquals(org.onap.vnfmdriver.model.OperationType.SCALEIN, sentLcnToVfc.getValue().getOperation());
         assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus());
         assertEquals(VNF_ID, sentLcnToVfc.getValue().getVnfInstanceId());
         verify(logger, never()).info(eq("Sending LCN: {}"), anyString());
+        VOID_OBSERVABLE.assertCalled();
     }
 
     /**
@@ -823,10 +831,10 @@ public class TestVfcNotificationSender extends TestBase {
         //verify
         assertEquals(1, sentLcnToVfc.getAllValues().size());
 
-        assertNull(sentLcnToVfc.getValue().getAffectedVl());
-        assertNull(sentLcnToVfc.getValue().getAffectedVnfc());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVl().size());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVnfc().size());
         assertEquals(0, sentLcnToVfc.getValue().getAffectedCp().size());
-        assertNull(sentLcnToVfc.getValue().getAffectedVirtualStorage());
+        assertEquals(0, sentLcnToVfc.getValue().getAffectedVirtualStorage().size());
         assertEquals(JOB_ID, sentLcnToVfc.getValue().getJobId());
         assertEquals(org.onap.vnfmdriver.model.OperationType.HEAL, sentLcnToVfc.getValue().getOperation());
         assertEquals(VnfLcmNotificationStatus.RESULT, sentLcnToVfc.getValue().getStatus());