@Test void testTryToAddFirmwareVersionToHistoryWhenFileIsNotAvailable() { final FirmwareFile firmwareFile = new FirmwareFile.Builder().withFilename("filename") .withDescription("description") .withPushToNewDevices(false) .build(); when(this.firmwareFileRepository.findByDeviceModel(any(DeviceModel.class))) .thenReturn(Collections.singletonList(firmwareFile)); final List<FirmwareVersion> firmwareVersions = Collections.singletonList( new FirmwareVersion(FirmwareModuleType.SECURITY, VERSION_2)); this.firmwareManagementService.tryToAddDeviceFirmwareFile("DVC", firmwareVersions); verify(this.deviceFirmwareFileRepository, never()).save(any(DeviceFirmwareFile.class)); }
public void tryToAddDeviceFirmwareFile(final String deviceIdentification, final List<FirmwareVersion> firmwareVersionsNotCurrent) { if (firmwareVersionsNotCurrent.isEmpty()) { LOGGER.info("No firmware to look for, concerning device {}, so nothing to add.", deviceIdentification); return; } final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification); for (final FirmwareFile file : this.getAvailableFirmwareFilesForDeviceModel(device.getDeviceModel())) { if (firmwareFileContainsAllOfTheseModules(file, firmwareVersionsNotCurrent)) { final DeviceFirmwareFile deviceFirmwareFile = new DeviceFirmwareFile(device, file, new Date(), INSTALLER); this.deviceFirmwareFileRepository.save(deviceFirmwareFile); if (LOGGER.isInfoEnabled()) { LOGGER.info( "Added new record to deviceFirmwareFile for device: {} with following modules (ModulesType/Versions):{} " + ", using file: {}", deviceIdentification, firmwareVersionsNotCurrent.toString(), file.getFilename()); } return; } } LOGGER.warn("Could not find any firmware file for device: {} that contains (all of) the following modules (ModulesType/Versions):{}", deviceIdentification, firmwareVersionsNotCurrent); }
FirmwareManagementService extends AbstractService { public void tryToAddDeviceFirmwareFile(final String deviceIdentification, final List<FirmwareVersion> firmwareVersionsNotCurrent) { if (firmwareVersionsNotCurrent.isEmpty()) { LOGGER.info("No firmware to look for, concerning device {}, so nothing to add.", deviceIdentification); return; } final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification); for (final FirmwareFile file : this.getAvailableFirmwareFilesForDeviceModel(device.getDeviceModel())) { if (firmwareFileContainsAllOfTheseModules(file, firmwareVersionsNotCurrent)) { final DeviceFirmwareFile deviceFirmwareFile = new DeviceFirmwareFile(device, file, new Date(), INSTALLER); this.deviceFirmwareFileRepository.save(deviceFirmwareFile); if (LOGGER.isInfoEnabled()) { LOGGER.info( "Added new record to deviceFirmwareFile for device: {} with following modules (ModulesType/Versions):{} " + ", using file: {}", deviceIdentification, firmwareVersionsNotCurrent.toString(), file.getFilename()); } return; } } LOGGER.warn("Could not find any firmware file for device: {} that contains (all of) the following modules (ModulesType/Versions):{}", deviceIdentification, firmwareVersionsNotCurrent); } }
FirmwareManagementService extends AbstractService { public void tryToAddDeviceFirmwareFile(final String deviceIdentification, final List<FirmwareVersion> firmwareVersionsNotCurrent) { if (firmwareVersionsNotCurrent.isEmpty()) { LOGGER.info("No firmware to look for, concerning device {}, so nothing to add.", deviceIdentification); return; } final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification); for (final FirmwareFile file : this.getAvailableFirmwareFilesForDeviceModel(device.getDeviceModel())) { if (firmwareFileContainsAllOfTheseModules(file, firmwareVersionsNotCurrent)) { final DeviceFirmwareFile deviceFirmwareFile = new DeviceFirmwareFile(device, file, new Date(), INSTALLER); this.deviceFirmwareFileRepository.save(deviceFirmwareFile); if (LOGGER.isInfoEnabled()) { LOGGER.info( "Added new record to deviceFirmwareFile for device: {} with following modules (ModulesType/Versions):{} " + ", using file: {}", deviceIdentification, firmwareVersionsNotCurrent.toString(), file.getFilename()); } return; } } LOGGER.warn("Could not find any firmware file for device: {} that contains (all of) the following modules (ModulesType/Versions):{}", deviceIdentification, firmwareVersionsNotCurrent); } FirmwareManagementService(); }
FirmwareManagementService extends AbstractService { public void tryToAddDeviceFirmwareFile(final String deviceIdentification, final List<FirmwareVersion> firmwareVersionsNotCurrent) { if (firmwareVersionsNotCurrent.isEmpty()) { LOGGER.info("No firmware to look for, concerning device {}, so nothing to add.", deviceIdentification); return; } final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification); for (final FirmwareFile file : this.getAvailableFirmwareFilesForDeviceModel(device.getDeviceModel())) { if (firmwareFileContainsAllOfTheseModules(file, firmwareVersionsNotCurrent)) { final DeviceFirmwareFile deviceFirmwareFile = new DeviceFirmwareFile(device, file, new Date(), INSTALLER); this.deviceFirmwareFileRepository.save(deviceFirmwareFile); if (LOGGER.isInfoEnabled()) { LOGGER.info( "Added new record to deviceFirmwareFile for device: {} with following modules (ModulesType/Versions):{} " + ", using file: {}", deviceIdentification, firmwareVersionsNotCurrent.toString(), file.getFilename()); } return; } } LOGGER.warn("Could not find any firmware file for device: {} that contains (all of) the following modules (ModulesType/Versions):{}", deviceIdentification, firmwareVersionsNotCurrent); } FirmwareManagementService(); void updateFirmware(final CorrelationIds ids,
            final FirmwareUpdateMessageDataContainer firmwareUpdateMessageDataContainer, final Long scheduleTime,
            final String messageType, final int messagePriority); void handleSsldPendingFirmwareUpdate(final String deviceIdentification); void getFirmwareVersion(@Identification final String organisationIdentification,
            @Identification final String deviceIdentification, final String correlationUid, final String messageType,
            final int messagePriority); void getFirmwareVersion(@Identification final String organisationIdentification,
            @Identification final String deviceIdentification, final String correlationUid, final String messageType,
            final int messagePriority, final Long delay); void handleGetFirmwareVersionResponse(final List<FirmwareVersionDto> firmwareVersionsDto,
            final CorrelationIds ids, final String messageType, final int messagePriority,
            final ResponseMessageResultType deviceResult, final OsgpException exception); List<FirmwareVersion> checkFirmwareHistoryForVersion(final String deviceId,
            final List<FirmwareVersion> firmwareVersions); void tryToAddDeviceFirmwareFile(final String deviceIdentification,
            final List<FirmwareVersion> firmwareVersionsNotCurrent); void switchFirmware(final String organisationIdentification, final String deviceIdentification,
            final String correlationUid, final String messageType, final int messagePriority, final String version); }
FirmwareManagementService extends AbstractService { public void tryToAddDeviceFirmwareFile(final String deviceIdentification, final List<FirmwareVersion> firmwareVersionsNotCurrent) { if (firmwareVersionsNotCurrent.isEmpty()) { LOGGER.info("No firmware to look for, concerning device {}, so nothing to add.", deviceIdentification); return; } final Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification); for (final FirmwareFile file : this.getAvailableFirmwareFilesForDeviceModel(device.getDeviceModel())) { if (firmwareFileContainsAllOfTheseModules(file, firmwareVersionsNotCurrent)) { final DeviceFirmwareFile deviceFirmwareFile = new DeviceFirmwareFile(device, file, new Date(), INSTALLER); this.deviceFirmwareFileRepository.save(deviceFirmwareFile); if (LOGGER.isInfoEnabled()) { LOGGER.info( "Added new record to deviceFirmwareFile for device: {} with following modules (ModulesType/Versions):{} " + ", using file: {}", deviceIdentification, firmwareVersionsNotCurrent.toString(), file.getFilename()); } return; } } LOGGER.warn("Could not find any firmware file for device: {} that contains (all of) the following modules (ModulesType/Versions):{}", deviceIdentification, firmwareVersionsNotCurrent); } FirmwareManagementService(); void updateFirmware(final CorrelationIds ids,
            final FirmwareUpdateMessageDataContainer firmwareUpdateMessageDataContainer, final Long scheduleTime,
            final String messageType, final int messagePriority); void handleSsldPendingFirmwareUpdate(final String deviceIdentification); void getFirmwareVersion(@Identification final String organisationIdentification,
            @Identification final String deviceIdentification, final String correlationUid, final String messageType,
            final int messagePriority); void getFirmwareVersion(@Identification final String organisationIdentification,
            @Identification final String deviceIdentification, final String correlationUid, final String messageType,
            final int messagePriority, final Long delay); void handleGetFirmwareVersionResponse(final List<FirmwareVersionDto> firmwareVersionsDto,
            final CorrelationIds ids, final String messageType, final int messagePriority,
            final ResponseMessageResultType deviceResult, final OsgpException exception); List<FirmwareVersion> checkFirmwareHistoryForVersion(final String deviceId,
            final List<FirmwareVersion> firmwareVersions); void tryToAddDeviceFirmwareFile(final String deviceIdentification,
            final List<FirmwareVersion> firmwareVersionsNotCurrent); void switchFirmware(final String organisationIdentification, final String deviceIdentification,
            final String correlationUid, final String messageType, final int messagePriority, final String version);  }