Search in sources :

Example 1 with ErrorResponseMessageMatcher

use of org.opensmartgridplatform.adapter.protocol.iec60870.testutils.matchers.ErrorResponseMessageMatcher 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)

Aggregations

ObjectMessage (javax.jms.ObjectMessage)1 Test (org.junit.jupiter.api.Test)1 ErrorResponseMessageMatcher (org.opensmartgridplatform.adapter.protocol.iec60870.testutils.matchers.ErrorResponseMessageMatcher)1 GetHealthStatusRequestDto (org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto)1 ObjectMessageBuilder (org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder)1