@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());
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);
}
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()));
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());
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)) {
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);
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();
}
/**
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();
}
/**
assertEquals("portProviderId", actualAffectedCp.getPortResource().getResourceid());
assertEquals("myPortName", actualAffectedCp.getPortResource().getResourceName());
assertEquals(VnfCpNotificationType.ADDED, actualAffectedCp.getChangeType());
+ VOID_OBSERVABLE.assertCalled();
}
/**
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();
}
/**
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();
}
/**
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();
}
/**
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();
}
//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();
}
/**
//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());