@Test
void testHandleGetFirmwareVersionResponseVersionAlreadyInAndLast() {

    // Arrange
    // Mock that VERSION 2 is now installed
    final FirmwareVersionDto firmwareVersionDto1 = new FirmwareVersionDto(
            org.opensmartgridplatform.dto.valueobjects.FirmwareModuleType.SECURITY, VERSION_2);
    final FirmwareVersionDto firmwareVersionDto2 = new FirmwareVersionDto(
            org.opensmartgridplatform.dto.valueobjects.FirmwareModuleType.FUNCTIONAL, VERSION_2);
    final List<FirmwareVersionDto> versionsOnDeviceDtos = Arrays.asList(firmwareVersionDto1, firmwareVersionDto2);
    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 FirmwareFile firmwareFile = new FirmwareFile.Builder().withFilename("filename")
            .withDescription("description")
            .withPushToNewDevices(false)
            .build();
    final FirmwareModule firmwareModule1 = new FirmwareModule(
            FirmwareModuleType.SECURITY.getDescription().toLowerCase());
    firmwareFile.addFirmwareModule(firmwareModule1, VERSION_2);
    final FirmwareModule firmwareModule2 = new FirmwareModule(
            FirmwareModuleType.FUNCTIONAL.getDescription().toLowerCase());
    firmwareFile.addFirmwareModule(firmwareModule2, VERSION_2);
    when(this.domainCoreMapper.mapAsList(versionsOnDeviceDtos, FirmwareVersion.class)).thenReturn(versionsOnDevice);
    when(this.ssldPendingFirmwareUpdateRepository.findByDeviceIdentification("DVC"))
            .thenReturn(Collections.emptyList());
    when(this.firmwareFileRepository.findByDeviceModel(any(DeviceModel.class)))
            .thenReturn(Collections.singletonList(firmwareFile));
    final CorrelationIds ids = new CorrelationIds("ORG", "DVC", "CORR");
    // Act
    this.firmwareManagementService.handleGetFirmwareVersionResponse(versionsOnDeviceDtos, ids, "FW", 0,
            ResponseMessageResultType.OK, null);
    // Validate
    verify(this.deviceFirmwareFileRepository, never()).save(any(DeviceFirmwareFile.class));
}