@Test void testCheckFirmwareHistoryForExistingVersion() { final FirmwareVersion firmwareVersion1 = new FirmwareVersion(FirmwareModuleType.SECURITY, VERSION_2); final FirmwareVersion firmwareVersion2 = new FirmwareVersion(FirmwareModuleType.FUNCTIONAL, VERSION_2); final List<FirmwareVersion> versionsOnDevice = Arrays.asList(firmwareVersion1, firmwareVersion2); final List<FirmwareVersion> versionsNotInHistory = this.firmwareManagementService .checkFirmwareHistoryForVersion("DVC", versionsOnDevice); assertThat(versionsNotInHistory).withFailMessage("List should be empty").isEmpty(); }
public List<FirmwareVersion> checkFirmwareHistoryForVersion(final String deviceId, final List<FirmwareVersion> firmwareVersions) { if (firmwareVersions.isEmpty()) { return firmwareVersions; } final List<FirmwareVersion> firmwareVersionsToCheck = new ArrayList<>(firmwareVersions); final Device device = this.deviceRepository.findByDeviceIdentification(deviceId); final List<DeviceFirmwareFile> deviceFirmwareFiles = this.deviceFirmwareFileRepository .findByDeviceOrderByInstallationDateAsc(device); final List<FirmwareVersion> firmwareVersionsInHistory = deviceFirmwareFiles.stream() .map(d -> d.getFirmwareFile().getModuleVersions().entrySet()) .flatMap(Collection::stream) .map(e -> new FirmwareVersion(FirmwareModuleType.forDescription(e.getKey().getDescription()), e.getValue())) .collect(Collectors.toList()); firmwareVersionsToCheck.removeAll(firmwareVersionsInHistory); return firmwareVersionsToCheck; }
FirmwareManagementService extends AbstractService { public List<FirmwareVersion> checkFirmwareHistoryForVersion(final String deviceId, final List<FirmwareVersion> firmwareVersions) { if (firmwareVersions.isEmpty()) { return firmwareVersions; } final List<FirmwareVersion> firmwareVersionsToCheck = new ArrayList<>(firmwareVersions); final Device device = this.deviceRepository.findByDeviceIdentification(deviceId); final List<DeviceFirmwareFile> deviceFirmwareFiles = this.deviceFirmwareFileRepository .findByDeviceOrderByInstallationDateAsc(device); final List<FirmwareVersion> firmwareVersionsInHistory = deviceFirmwareFiles.stream() .map(d -> d.getFirmwareFile().getModuleVersions().entrySet()) .flatMap(Collection::stream) .map(e -> new FirmwareVersion(FirmwareModuleType.forDescription(e.getKey().getDescription()), e.getValue())) .collect(Collectors.toList()); firmwareVersionsToCheck.removeAll(firmwareVersionsInHistory); return firmwareVersionsToCheck; } }
FirmwareManagementService extends AbstractService { public List<FirmwareVersion> checkFirmwareHistoryForVersion(final String deviceId, final List<FirmwareVersion> firmwareVersions) { if (firmwareVersions.isEmpty()) { return firmwareVersions; } final List<FirmwareVersion> firmwareVersionsToCheck = new ArrayList<>(firmwareVersions); final Device device = this.deviceRepository.findByDeviceIdentification(deviceId); final List<DeviceFirmwareFile> deviceFirmwareFiles = this.deviceFirmwareFileRepository .findByDeviceOrderByInstallationDateAsc(device); final List<FirmwareVersion> firmwareVersionsInHistory = deviceFirmwareFiles.stream() .map(d -> d.getFirmwareFile().getModuleVersions().entrySet()) .flatMap(Collection::stream) .map(e -> new FirmwareVersion(FirmwareModuleType.forDescription(e.getKey().getDescription()), e.getValue())) .collect(Collectors.toList()); firmwareVersionsToCheck.removeAll(firmwareVersionsInHistory); return firmwareVersionsToCheck; } FirmwareManagementService(); }
FirmwareManagementService extends AbstractService { public List<FirmwareVersion> checkFirmwareHistoryForVersion(final String deviceId, final List<FirmwareVersion> firmwareVersions) { if (firmwareVersions.isEmpty()) { return firmwareVersions; } final List<FirmwareVersion> firmwareVersionsToCheck = new ArrayList<>(firmwareVersions); final Device device = this.deviceRepository.findByDeviceIdentification(deviceId); final List<DeviceFirmwareFile> deviceFirmwareFiles = this.deviceFirmwareFileRepository .findByDeviceOrderByInstallationDateAsc(device); final List<FirmwareVersion> firmwareVersionsInHistory = deviceFirmwareFiles.stream() .map(d -> d.getFirmwareFile().getModuleVersions().entrySet()) .flatMap(Collection::stream) .map(e -> new FirmwareVersion(FirmwareModuleType.forDescription(e.getKey().getDescription()), e.getValue())) .collect(Collectors.toList()); firmwareVersionsToCheck.removeAll(firmwareVersionsInHistory); return firmwareVersionsToCheck; } 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 List<FirmwareVersion> checkFirmwareHistoryForVersion(final String deviceId, final List<FirmwareVersion> firmwareVersions) { if (firmwareVersions.isEmpty()) { return firmwareVersions; } final List<FirmwareVersion> firmwareVersionsToCheck = new ArrayList<>(firmwareVersions); final Device device = this.deviceRepository.findByDeviceIdentification(deviceId); final List<DeviceFirmwareFile> deviceFirmwareFiles = this.deviceFirmwareFileRepository .findByDeviceOrderByInstallationDateAsc(device); final List<FirmwareVersion> firmwareVersionsInHistory = deviceFirmwareFiles.stream() .map(d -> d.getFirmwareFile().getModuleVersions().entrySet()) .flatMap(Collection::stream) .map(e -> new FirmwareVersion(FirmwareModuleType.forDescription(e.getKey().getDescription()), e.getValue())) .collect(Collectors.toList()); firmwareVersionsToCheck.removeAll(firmwareVersionsInHistory); return firmwareVersionsToCheck; } 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);  }