use of org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto in project open-smart-grid-platform by OSGP.
the class OsgpCoreRequestSteps method whenIReceiveRequestForIec60870Device.
@When("I receive a request for the IEC60870 device")
public void whenIReceiveRequestForIec60870Device() throws JMSException {
final ObjectMessage message = new ObjectMessageBuilder().withDeviceIdentification(DEFAULT_DEVICE_IDENTIFICATION).withMessageType(DEFAULT_MESSAGE_TYPE).withObject(new GetHealthStatusRequestDto()).build();
this.messageListener.onMessage(message);
}
use of org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageListenerTest method shouldProcessMessageWhenMessageTypeIsSupported.
@Test
void shouldProcessMessageWhenMessageTypeIsSupported() throws JMSException {
// Arrange
final String correlationUid = DEFAULT_CORRELATION_UID;
final ObjectMessage message = new ObjectMessageBuilder().withCorrelationUid(correlationUid).withDeviceIdentification(DEFAULT_DEVICE_IDENTIFICATION).withMessageType(DEFAULT_MESSAGE_TYPE).withObject(new GetHealthStatusRequestDto()).build();
final MessageProcessor messageProcessor = mock(GetHealthStatusRequestMessageProcessor.class);
when(this.iec60870RequestMessageProcessorMap.getMessageProcessor(message)).thenReturn(messageProcessor);
// Act
this.deviceRequestMessageListener.onMessage(message);
// Assert
verify(this.pendingRequestsQueue).enqueue(DEFAULT_DEVICE_IDENTIFICATION, correlationUid);
verify(messageProcessor).processMessage(message);
}
use of org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto in project open-smart-grid-platform by OSGP.
the class DeviceRequestMessageListenerTest method shouldSendErrorMessageWhenMessageTypeIsNotSupported.
@Test
void shouldSendErrorMessageWhenMessageTypeIsNotSupported() throws JMSException {
// Arrange
final String correlationUid = DEFAULT_CORRELATION_UID;
final ObjectMessage message = new ObjectMessageBuilder().withCorrelationUid(correlationUid).withDeviceIdentification(DEFAULT_DEVICE_IDENTIFICATION).withMessageType(DEFAULT_MESSAGE_TYPE).withObject(new GetHealthStatusRequestDto()).build();
when(this.iec60870RequestMessageProcessorMap.getMessageProcessor(message)).thenThrow(JMSException.class);
// Act
this.deviceRequestMessageListener.onMessage(message);
// Assert
verify(this.pendingRequestsQueue).enqueue(DEFAULT_DEVICE_IDENTIFICATION, correlationUid);
verify(this.pendingRequestsQueue).remove(DEFAULT_DEVICE_IDENTIFICATION, correlationUid);
verify(this.deviceResponseMessageSender).send(argThat(new ErrorResponseMessageMatcher()));
}
use of org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto in project open-smart-grid-platform by OSGP.
the class CommunicationRecoveryService method createMessage.
private RequestMessage createMessage(final RtuDevice rtu) {
LOGGER.debug("Creating message for device {}.", rtu.getDeviceIdentification());
final String correlationUid = this.createCorrelationUid(rtu);
final String organisationIdentification = rtu.getOwner().getOrganisationIdentification();
final String deviceIdentification = rtu.getDeviceIdentification();
final GetHealthStatusRequestDto request = this.createHalthStatusRequest(rtu);
return new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, request);
}
use of org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto in project open-smart-grid-platform by OSGP.
the class DeviceManagementService method getHealthStatus.
public void getHealthStatus(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final String messageType, final GetHealthStatusRequest getHealthStatusRequest) throws FunctionalException {
LOGGER.info("Get Health Status for device [{}] with correlation id [{}]", deviceIdentification, correlationUid);
this.findOrganisation(organisationIdentification);
final Device device = this.findActiveDevice(deviceIdentification);
final GetHealthStatusRequestDto dto = this.mapper.map(getHealthStatusRequest, GetHealthStatusRequestDto.class);
this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, dto), messageType, device.getIpAddress());
}
Aggregations