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());
}
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);
}
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();
}
Aggregations