Search in sources :

Example 1 with GetHealthStatusRequestDto

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);
}
Also used : GetHealthStatusRequestDto(org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto) ObjectMessage(javax.jms.ObjectMessage) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) When(io.cucumber.java.en.When)

Example 2 with GetHealthStatusRequestDto

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);
}
Also used : GetHealthStatusRequestDto(org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto) ObjectMessage(javax.jms.ObjectMessage) MessageProcessor(org.opensmartgridplatform.shared.infra.jms.MessageProcessor) GetHealthStatusRequestMessageProcessor(org.opensmartgridplatform.adapter.protocol.iec60870.infra.messaging.processors.GetHealthStatusRequestMessageProcessor) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) Test(org.junit.jupiter.api.Test)

Example 3 with GetHealthStatusRequestDto

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()));
}
Also used : GetHealthStatusRequestDto(org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto) ObjectMessage(javax.jms.ObjectMessage) ErrorResponseMessageMatcher(org.opensmartgridplatform.adapter.protocol.iec60870.testutils.matchers.ErrorResponseMessageMatcher) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with GetHealthStatusRequestDto

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);
}
Also used : GetHealthStatusRequestDto(org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage)

Example 5 with GetHealthStatusRequestDto

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());
}
Also used : GetHealthStatusRequestDto(org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto) Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage)

Aggregations

GetHealthStatusRequestDto (org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto)5 ObjectMessage (javax.jms.ObjectMessage)3 ObjectMessageBuilder (org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder)3 Test (org.junit.jupiter.api.Test)2 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)2 When (io.cucumber.java.en.When)1 GetHealthStatusRequestMessageProcessor (org.opensmartgridplatform.adapter.protocol.iec60870.infra.messaging.processors.GetHealthStatusRequestMessageProcessor)1 ErrorResponseMessageMatcher (org.opensmartgridplatform.adapter.protocol.iec60870.testutils.matchers.ErrorResponseMessageMatcher)1 Device (org.opensmartgridplatform.domain.core.entities.Device)1 MessageProcessor (org.opensmartgridplatform.shared.infra.jms.MessageProcessor)1