use of org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericSendNotificationRequest in project open-smart-grid-platform by OSGP.
the class NotificationServiceWsTest method testMappingFromGenericSendNotificationRequest.
@Test
public void testMappingFromGenericSendNotificationRequest() {
final GenericSendNotificationRequest genericRequest = new GenericSendNotificationRequest(this.createGenericNotification());
final SendNotificationRequest sendNotificationRequest = this.mapperFactory.getMapperFacade().map(genericRequest, SendNotificationRequest.class);
final Notification notification = sendNotificationRequest.getNotification();
assertThat(notification.getMessage()).isEqualTo(MESSAGE);
assertThat(notification.getResult()).isEqualTo(RESULT);
assertThat(notification.getDeviceIdentification()).isEqualTo(DEVICEIDENTIFICATION);
assertThat(notification.getCorrelationUid()).isEqualTo(CORRELATION_UID);
assertThat(notification.getNotificationType()).isEqualTo(NOTIFICATION_TYPE);
}
use of org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericSendNotificationRequest in project open-smart-grid-platform by OSGP.
the class NotificationServiceWsTest method testMappingToGenericSendNotificationRequest.
@Test
public void testMappingToGenericSendNotificationRequest() {
final SendNotificationRequest sendNotificationRequest = new SendNotificationRequest();
sendNotificationRequest.setNotification(this.createNotification());
final GenericSendNotificationRequest genericRequest = this.mapperFactory.getMapperFacade().map(sendNotificationRequest, GenericSendNotificationRequest.class);
final GenericNotification genericNotification = genericRequest.getNotification();
assertThat(genericNotification.getMessage()).isEqualTo(MESSAGE);
assertThat(genericNotification.getResult()).isEqualTo(RESULT);
assertThat(genericNotification.getDeviceIdentification()).isEqualTo(DEVICEIDENTIFICATION);
assertThat(genericNotification.getCorrelationUid()).isEqualTo(CORRELATION_UID);
assertThat(genericNotification.getNotificationType()).isEqualTo(NOTIFICATION_TYPE.name());
}
use of org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericSendNotificationRequest in project open-smart-grid-platform by OSGP.
the class DefaultNotificationService method sendNotification.
@Override
public void sendNotification(final ApplicationDataLookupKey endpointLookupKey, final GenericNotification notification) {
Objects.requireNonNull(endpointLookupKey, "endpointLookupKey must not be null");
Objects.requireNonNull(notification, "notification must not be null");
final WebServiceTemplate template = this.templateFactory.getTemplate(endpointLookupKey);
if (template == null) {
LOGGER.warn(NO_TEMPLATE_AVAILABLE, endpointLookupKey.getApplicationName(), endpointLookupKey.getOrganisationIdentification(), notification.getResult(), notification.getDeviceIdentification(), notification.getCorrelationUid());
return;
}
LOGGER.info("sendNotification called with correlationUid: {}, type: {}, to application: {} for organisation: {}", notification.getCorrelationUid(), notification.getNotificationType(), endpointLookupKey.getApplicationName(), endpointLookupKey.getOrganisationIdentification());
final T notificationRequest = this.mapper.map(new GenericSendNotificationRequest(notification), this.sendNotificationRequestType);
final String uri = this.getCustomTargetUri(endpointLookupKey, notification);
if (uri == null) {
template.marshalSendAndReceive(notificationRequest);
} else {
template.marshalSendAndReceive(uri, notificationRequest);
}
}
Aggregations