Search in sources :

Example 1 with GenericSendNotificationRequest

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);
}
Also used : SendNotificationRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.notification.SendNotificationRequest) GenericSendNotificationRequest(org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericSendNotificationRequest) Notification(org.opensmartgridplatform.adapter.ws.schema.smartmetering.notification.Notification) GenericNotification(org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericNotification) GenericSendNotificationRequest(org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericSendNotificationRequest) Test(org.junit.jupiter.api.Test)

Example 2 with GenericSendNotificationRequest

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());
}
Also used : GenericNotification(org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericNotification) SendNotificationRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.notification.SendNotificationRequest) GenericSendNotificationRequest(org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericSendNotificationRequest) GenericSendNotificationRequest(org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericSendNotificationRequest) Test(org.junit.jupiter.api.Test)

Example 3 with GenericSendNotificationRequest

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);
    }
}
Also used : WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate) GenericSendNotificationRequest(org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericSendNotificationRequest)

Aggregations

GenericSendNotificationRequest (org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericSendNotificationRequest)3 Test (org.junit.jupiter.api.Test)2 GenericNotification (org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericNotification)2 SendNotificationRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.notification.SendNotificationRequest)2 Notification (org.opensmartgridplatform.adapter.ws.schema.smartmetering.notification.Notification)1 WebServiceTemplate (org.springframework.ws.client.core.WebServiceTemplate)1