use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class MonitoringService method handleActualPowerQualityResponse.
public void handleActualPowerQualityResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final ActualPowerQualityResponseDto actualPowerQualityResponseDto) {
LOGGER.info("handleGetActualPowerQualityResponse for MessageType: {}", messageMetadata.getMessageType());
ResponseMessageResultType result = deviceResult;
if (exception != null) {
LOGGER.error(DEVICE_RESPONSE_NOT_OK_LOG_MSG, exception);
result = ResponseMessageResultType.NOT_OK;
}
final ActualPowerQualityResponse actualPowerQualityResponse = this.monitoringMapper.map(actualPowerQualityResponseDto, ActualPowerQualityResponse.class);
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(actualPowerQualityResponse).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class MonitoringService method handlePeriodicMeterReadsresponse.
public void handlePeriodicMeterReadsresponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final PeriodicMeterReadGasResponseDto periodMeterReadsValueDTO) {
LOGGER.info("handlePeriodicMeterReadsresponse for MessageType: {}", messageMetadata.getMessageType());
ResponseMessageResultType result = deviceResult;
if (exception != null) {
LOGGER.error(DEVICE_RESPONSE_NOT_OK_LOG_MSG, exception);
result = ResponseMessageResultType.NOT_OK;
}
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(this.monitoringMapper.map(periodMeterReadsValueDTO, PeriodicMeterReadsContainerGas.class)).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class MonitoringService method handleActualMeterReadsResponse.
public void handleActualMeterReadsResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final MeterReadsGasResponseDto actualMeterReadsGas) {
LOGGER.info("handleActualMeterReadsResponse for MessageType: {}", messageMetadata.getMessageType());
ResponseMessageResultType result = deviceResult;
if (exception != null) {
LOGGER.error(DEVICE_RESPONSE_NOT_OK_LOG_MSG, exception);
result = ResponseMessageResultType.NOT_OK;
}
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(this.monitoringMapper.map(actualMeterReadsGas, MeterReadsGas.class)).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class GetFirmwareFileResponseMessageProcessorTest method processMessageShouldSendOkResponseMessageContainingFirmwareVersions.
@Test
void processMessageShouldSendOkResponseMessageContainingFirmwareVersions() throws OsgpException, JMSException {
// arrange
final FirmwareFileDto firmwareFileDto = this.setupFirmwareFileDto();
final ResponseMessage responseMessage = this.setupResponseMessage(firmwareFileDto);
final ObjectMessage message = new ObjectMessageBuilder().withMessageType(MessageType.GET_FIRMWARE_FILE.name()).withObject(responseMessage).build();
final UpdateFirmwareResponseDto updateFirmwareResponseDto = new UpdateFirmwareResponseDto(firmwareFileDto.getFirmwareIdentification());
final ArgumentCaptor<ResponseMessage> responseMessageArgumentCaptor = ArgumentCaptor.forClass(ResponseMessage.class);
final MessageMetadata messageMetadata = new MessageMetadata.Builder(MessageMetadata.fromMessage(message)).withMessageType(MessageType.UPDATE_FIRMWARE.name()).build();
when(this.domainHelperService.findDlmsDevice(any(MessageMetadata.class))).thenReturn(this.dlmsDevice);
when(this.dlmsConnectionManagerMock.getDlmsMessageListener()).thenReturn(this.dlmsMessageListenerMock);
when(this.firmwareService.updateFirmware(same(this.dlmsConnectionManagerMock), same(this.dlmsDevice), same(firmwareFileDto), any(MessageMetadata.class))).thenReturn(updateFirmwareResponseDto);
// act
this.getFirmwareFileResponseMessageProcessor.processMessageTasks(message.getObject(), messageMetadata, this.dlmsConnectionManagerMock);
// assert
verify(this.responseMessageSender, times(1)).send(responseMessageArgumentCaptor.capture());
assertThat(responseMessageArgumentCaptor.getValue().getDataObject()).isSameAs(updateFirmwareResponseDto);
assertThat(responseMessageArgumentCaptor.getValue().getResult()).isSameAs(ResponseMessageResultType.OK);
}
use of org.opensmartgridplatform.shared.infra.jms.ResponseMessage in project open-smart-grid-platform by OSGP.
the class GetFirmwareFileResponseMessageProcessorTest method processMessageShouldCallConnectionHelperCreateAndHandleConnection.
@Test
void processMessageShouldCallConnectionHelperCreateAndHandleConnection() throws JMSException, OsgpException {
final FirmwareFileDto firmwareFileDto = this.setupFirmwareFileDto();
final ResponseMessage responseMessage = this.setupResponseMessage(firmwareFileDto);
final ObjectMessage message = new ObjectMessageBuilder().withMessageType(MessageType.GET_FIRMWARE_FILE.name()).withObject(responseMessage).build();
when(this.domainHelperService.findDlmsDevice(any(MessageMetadata.class))).thenReturn(this.dlmsDevice);
this.getFirmwareFileResponseMessageProcessor.processMessage(message);
verify(this.connectionHelper).createAndHandleConnectionForDevice(any(MessageMetadata.class), eq(this.dlmsDevice), isNull(), isNull(), any());
}
Aggregations