@Test
void checkSsldPendingFirmwareUpdateReturnsTrueAndDeletesPendingUpdateWithMatchingCorrelationUid() {

    final String organisationIdentification = "test-org";
    final String deviceIdentification = "device-identification";
    final String correlationUid = "correlation-uid-matching-pending-update";
    final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
    final List<FirmwareVersion> firmwareVersions = Collections
            .singletonList(new FirmwareVersion(FirmwareModuleType.FUNCTIONAL, VERSION_2));
    final SsldPendingFirmwareUpdate matchingPendingFirmwareUpdate = this.anSsldPendingFirmwareUpdate(437L,
            new Date(), deviceIdentification, correlationUid);
    when(this.ssldPendingFirmwareUpdateRepository.findByDeviceIdentification(deviceIdentification))
            .thenReturn(Arrays.asList(
                    this.anSsldPendingFirmwareUpdate(457198L, new Date(), deviceIdentification,
                            "some-other-correlation-uid"),
                    matchingPendingFirmwareUpdate, this.anSsldPendingFirmwareUpdate(94085089L, new Date(),
                            deviceIdentification, "yet-another-correlation-uid")));
    final boolean hasPendingFirmwareUpdate = this.firmwareManagementService.checkSsldPendingFirmwareUpdate(ids,
            firmwareVersions);
    assertThat(hasPendingFirmwareUpdate).isTrue();
    verify(this.ssldPendingFirmwareUpdateRepository).delete(matchingPendingFirmwareUpdate);
}