Fix backward compatibility issues
[vfc/nfvo/driver/vnfm/svnfm.git] / nokiav2 / driver / src / test / java / org / onap / vfc / nfvo / driver / vnfm / svnfm / nokia / onap / vfc / TestVfcNotificationSender.java
index d28e224..ea82882 100644 (file)
@@ -27,22 +27,20 @@ import com.nokia.cbam.lcm.v32.model.ChangeType;
 import com.nokia.cbam.lcm.v32.model.*;
 import com.nokia.cbam.lcm.v32.model.OperationType;
 import com.nokia.cbam.lcm.v32.model.ScaleDirection;
+import java.util.ArrayList;
+import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedConnectionPoints;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedCp;
-import org.onap.vnfmdriver.ApiException;
 import org.onap.vnfmdriver.model.*;
 import org.threeten.bp.OffsetDateTime;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import static java.util.Optional.empty;
 import static java.util.Optional.of;
+
 import static junit.framework.TestCase.*;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
@@ -66,7 +64,7 @@ public class TestVfcNotificationSender extends TestBase {
     public void init() throws Exception {
         vfcNotificationSender = new VfcNotificationSender(driverProperties, vfcRestApiProvider);
         setField(VfcNotificationSender.class, "logger", logger);
-        Mockito.doNothing().when(nsLcmApi).vNFLCMNotification(eq(VNFM_ID), eq(VNF_ID), sentLcnToVfc.capture());
+        when(nsLcmApi.vNFLCMNotification(eq(VNFM_ID), eq(VNF_ID), sentLcnToVfc.capture())).thenReturn(null);
         instantiationOperation.setId("instantiationOperationExecutionId");
         instantiationOperation.setStartTime(OffsetDateTime.now());
         instantiationOperation.setOperationType(OperationType.INSTANTIATE);
@@ -79,7 +77,7 @@ public class TestVfcNotificationSender extends TestBase {
         healOperation.setId("healOperaitonExecutionId");
         healOperation.setOperationType(OperationType.HEAL);
         healOperation.setStartTime(OffsetDateTime.now().plusDays(1));
-        when(vnfApi.vnfsVnfInstanceIdOperationExecutionsGet(VNF_ID, NOKIA_LCM_API_VERSION)).thenReturn(operationExecutions);
+        when(vnfApi.vnfsVnfInstanceIdOperationExecutionsGet(VNF_ID, NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(operationExecutions));
         prepOperation(instantiationOperation);
         prepOperation(scaleOperation);
         prepOperation(healOperation);
@@ -87,7 +85,7 @@ public class TestVfcNotificationSender extends TestBase {
         recievedLcn.setVnfInstanceId(VNF_ID);
     }
 
-    private void prepOperation(OperationExecution operationExecution) throws com.nokia.cbam.lcm.v32.ApiException {
+    private void prepOperation(OperationExecution operationExecution) {
         addEmptyModifiedConnectionPoints(operationExecution);
         JsonElement root = new JsonParser().parse("{ \"additionalParams\" : { \"jobId\" : \"" + JOB_ID + "\"}}");
         operationExecution.setOperationParams(root);
@@ -95,7 +93,7 @@ public class TestVfcNotificationSender extends TestBase {
             case TERMINATE:
                 root.getAsJsonObject().addProperty("terminationType", "GRACEFULL");
         }
-        when(operationExecutionApi.operationExecutionsOperationExecutionIdGet(operationExecution.getId(), NOKIA_LCM_API_VERSION)).thenReturn(operationExecution);
+        when(operationExecutionApi.operationExecutionsOperationExecutionIdGet(operationExecution.getId(), NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(operationExecution));
         operationExecutions.add(operationExecution);
     }
 
@@ -842,7 +840,7 @@ public class TestVfcNotificationSender extends TestBase {
      */
     @Test
     public void testUnableToSendNotificationToVfc() throws Exception {
-        ApiException expectedException = new ApiException();
+        RuntimeException expectedException = new RuntimeException();
         doThrow(expectedException).when(nsLcmApi).vNFLCMNotification(any(), any(), any());
         recievedLcn.setStatus(OperationStatus.STARTED);
         recievedLcn.setOperation(OperationType.INSTANTIATE);