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;
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);
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);
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);
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);
}
*/
@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);