Search in sources :

Example 16 with ObjectMessageBuilder

use of org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder in project open-smart-grid-platform by OSGP.

the class UpdateFirmwareRequestMessageProcessorTest method processMessageTaskShouldUpdateFirmwareWhenFirmwareFileAvailable.

@Test
void processMessageTaskShouldUpdateFirmwareWhenFirmwareFileAvailable() throws JMSException, OsgpException {
    // Arrange
    final String firmwareIdentification = "available";
    final String deviceIdentification = "availableToo";
    final UpdateFirmwareRequestDto updateFirmwareRequestDto = new UpdateFirmwareRequestDto(firmwareIdentification, deviceIdentification);
    final ObjectMessage message = new ObjectMessageBuilder().withObject(updateFirmwareRequestDto).withCorrelationUid("123456").build();
    final MessageMetadata messageMetadata = MessageMetadata.fromMessage(message);
    when(this.firmwareService.isFirmwareFileAvailable(firmwareIdentification)).thenReturn(true);
    // Act
    this.processor.processMessageTasks(message.getObject(), messageMetadata, this.dlmsConnectionManagerMock, this.device);
    // Assert
    verify(this.configurationService, times(1)).updateFirmware(nullable(DlmsConnectionManager.class), same(this.device), same(updateFirmwareRequestDto), any(MessageMetadata.class));
}
Also used : UpdateFirmwareRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.UpdateFirmwareRequestDto) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) ObjectMessage(javax.jms.ObjectMessage) DlmsConnectionManager(org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) Test(org.junit.jupiter.api.Test)

Example 17 with ObjectMessageBuilder

use of org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder in project open-smart-grid-platform by OSGP.

the class PushNotificationSmsMessageProcessorTest method init.

@BeforeEach
public void init() throws JMSException {
    final String correlationUid = "corr-uid-1";
    final String organisationIdentification = "test-org";
    final RequestMessage requestMessage = new RequestMessage(correlationUid, organisationIdentification, DEVICE_IDENTIFICATION, IP_ADDRESS, null, null, this.pushNotificationSms);
    this.message = new ObjectMessageBuilder().withCorrelationUid(correlationUid).withMessageType(MessageType.PUSH_NOTIFICATION_SMS.name()).withDeviceIdentification(DEVICE_IDENTIFICATION).withObject(requestMessage).build();
}
Also used : RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) ObjectMessageBuilder(org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ObjectMessageBuilder (org.opensmartgridplatform.shared.infra.jms.ObjectMessageBuilder)17 ObjectMessage (javax.jms.ObjectMessage)15 Test (org.junit.jupiter.api.Test)12 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)9 UpdateFirmwareRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.UpdateFirmwareRequestDto)6 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)6 FirmwareFileDto (org.opensmartgridplatform.dto.valueobjects.FirmwareFileDto)4 ProtocolResponseMessage (org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)4 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)4 When (io.cucumber.java.en.When)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 Date (java.util.Date)2 DlmsDeviceBuilder (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder)2 DlmsConnectionManager (org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager)2 DomainInfo (org.opensmartgridplatform.domain.core.entities.DomainInfo)2 ConnectRequestDto (org.opensmartgridplatform.dto.da.ConnectRequestDto)2 GetHealthStatusRequestDto (org.opensmartgridplatform.dto.da.GetHealthStatusRequestDto)2 Collections (java.util.Collections)1 JMSException (javax.jms.JMSException)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1