Search in sources :

Example 1 with SystemEvent

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SystemEvent in project open-smart-grid-platform by OSGP.

the class NotificationService method handleSystemEvent.

public void handleSystemEvent(final MessageMetadata messageMetadata, final SystemEventDto systemEventDto) {
    LOGGER.info("handleSystemEvent for MessageType: {}", messageMetadata.getMessageType());
    final SystemEvent systemEvent = this.mapperFactory.getMapperFacade().map(systemEventDto, SystemEvent.class);
    /*
     * Send the systemEvent as a response message to the web service, so
     * it can be handled similar to response messages based on earlier web service
     * requests.
     */
    final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(ResponseMessageResultType.OK).withDataObject(systemEvent).build();
    this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
Also used : SystemEvent(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SystemEvent) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage)

Example 2 with SystemEvent

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SystemEvent in project open-smart-grid-platform by OSGP.

the class SystemEventMappingTest method testWithNonEmptyValue.

// is not empty
@Test
void testWithNonEmptyValue() {
    // build test data
    final String deviceId = "deviceId";
    final SystemEventTypeDto systemEventType = SystemEventTypeDto.INVOCATION_COUNTER_THRESHOLD_REACHED;
    final Date timestamp = new Date();
    final String reason = "reason123";
    final SystemEventDto systemEventDto = new SystemEventDto(deviceId, systemEventType, timestamp, reason);
    // actual mapping
    final SystemEvent systemEvent = this.mapperFactory.getMapperFacade().map(systemEventDto, SystemEvent.class);
    // test mapping
    assertThat(systemEvent).isNotNull();
    assertThat(systemEvent.getDeviceIdentification()).isEqualTo(deviceId);
    assertThat(systemEvent.getSystemEventType().name()).isEqualTo(systemEventType.name());
    assertThat(systemEvent.getTimestamp()).isEqualTo(timestamp);
    assertThat(systemEvent.getReason()).isEqualTo(reason);
}
Also used : SystemEvent(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SystemEvent) SystemEventTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventTypeDto) SystemEventDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventDto) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 3 with SystemEvent

use of org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SystemEvent in project open-smart-grid-platform by OSGP.

the class SystemEventMappingTest method testWithNullVariables.

// Test if mapping a SystemEvent object succeeds with null
// variables, although it
@Test
void testWithNullVariables() {
    // build test data
    final String deviceId = null;
    final SystemEventTypeDto systemEventType = null;
    final Date timestamp = null;
    final String reason = null;
    final SystemEventDto systemEventDto = new SystemEventDto(deviceId, systemEventType, timestamp, reason);
    // actual mapping
    final SystemEvent systemEvent = this.mapperFactory.getMapperFacade().map(systemEventDto, SystemEvent.class);
    // test mapping
    assertThat(systemEvent).isNotNull();
    assertThat(systemEvent.getDeviceIdentification()).isNull();
    assertThat(systemEvent.getSystemEventType()).isNull();
    assertThat(systemEvent.getTimestamp()).isNull();
    assertThat(systemEvent.getReason()).isNull();
}
Also used : SystemEvent(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SystemEvent) SystemEventTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventTypeDto) SystemEventDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventDto) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

SystemEvent (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SystemEvent)3 Date (java.util.Date)2 Test (org.junit.jupiter.api.Test)2 SystemEventDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventDto)2 SystemEventTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventTypeDto)2 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1