use of org.opensmartgridplatform.dto.valueobjects.smartmetering.UpdateFirmwareRequestDto in project open-smart-grid-platform by OSGP.
the class UpdateFirmwareRequestMessageProcessorTest method processMessageTaskShouldNotSendFirmwareFileRequestWhenFirmwareFileAvailable.
@Test
void processMessageTaskShouldNotSendFirmwareFileRequestWhenFirmwareFileAvailable() throws JMSException, OsgpException {
// Arrange
final String firmwareIdentification = "unavailable";
final String deviceIdentification = "unavailableEither";
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.osgpRequestMessageSender, never()).send(any(RequestMessage.class), any(String.class), any(MessageMetadata.class));
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.UpdateFirmwareRequestDto 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));
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.UpdateFirmwareRequestDto in project open-smart-grid-platform by OSGP.
the class UpdateFirmwareCommandExecutorIntegrationTest method testExecuteMbusFirmware.
@Test
void testExecuteMbusFirmware() throws Exception {
final DlmsDevice device = new DlmsDevice();
device.setMbusIdentificationNumber("00000001");
final String firmwareIdentification = RandomStringUtils.randomAlphabetic(10);
final String deviceIdentification = RandomStringUtils.randomAlphabetic(10);
device.setDeviceIdentification(deviceIdentification);
final byte[] firmwareFile = org.bouncycastle.util.encoders.Hex.decode("534d523500230011004000310000001000020801e91effffffff500303000000000000831c9d5aa5b4f" + "fbfd057035a8a7896a4abe7afa36687fbc48944bcee0343eed3a75aab882ec1cf57820adfd4394e262d" + "5fa821c678e71c05c47e1c69c4bfffe1fd");
when(this.dlmsDeviceRepository.findByDeviceIdentification(deviceIdentification)).thenReturn(device);
when(this.firmwareFileCachingRepository.retrieve(firmwareIdentification)).thenReturn(firmwareFile);
when(this.macGenerationService.calculateMac(any(), any(), any())).thenReturn(new byte[16]);
final UpdateFirmwareRequestDto updateFirmwareRequestDto = new UpdateFirmwareRequestDto(firmwareIdentification, deviceIdentification);
this.commandExecutor.execute(this.connectionManagerStub, device, updateFirmwareRequestDto, this.messageMetadata);
verify(this.dlmsDeviceRepository, times(1)).findByDeviceIdentification(deviceIdentification);
verify(this.macGenerationService, times(1)).calculateMac(any(), any(), any());
verify(this.firmwareFileCachingRepository, times(1)).retrieve(firmwareIdentification);
verify(this.firmwareImageIdentifierCachingRepository, never()).retrieve(firmwareIdentification);
this.assertImageTransferRelatedInteractionWithConnection();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.UpdateFirmwareRequestDto in project open-smart-grid-platform by OSGP.
the class UpdateFirmwareCommandExecutorIntegrationTest method testExecute.
@Test
void testExecute() throws Exception {
final DlmsDevice device = new DlmsDevice();
final String firmwareIdentification = RandomStringUtils.randomAlphabetic(10);
final String deviceIdentification = RandomStringUtils.randomAlphabetic(10);
final byte[] firmwareFile = RandomStringUtils.randomAlphabetic(100).getBytes(StandardCharsets.UTF_8);
final byte[] firmwareImageIdentifier = Hex.decode("496d6167654964656e746966696572");
when(this.firmwareFileCachingRepository.retrieve(firmwareIdentification)).thenReturn(firmwareFile);
when(this.firmwareImageIdentifierCachingRepository.retrieve(firmwareIdentification)).thenReturn(firmwareImageIdentifier);
final UpdateFirmwareRequestDto updateFirmwareRequestDto = new UpdateFirmwareRequestDto(firmwareIdentification, deviceIdentification);
this.commandExecutor.execute(this.connectionManagerStub, device, updateFirmwareRequestDto, this.messageMetadata);
verify(this.dlmsDeviceRepository, never()).findByDeviceIdentification(deviceIdentification);
verify(this.macGenerationService, never()).calculateMac(any(), any(), any());
verify(this.firmwareFileCachingRepository, times(1)).retrieve(firmwareIdentification);
verify(this.firmwareImageIdentifierCachingRepository, times(1)).retrieve(firmwareIdentification);
this.assertImageTransferRelatedInteractionWithConnection();
}
Aggregations