class CmsAspspPsuAccountServiceInternal implements CmsAspspPsuAccountService {

    @Override
    @Transactional
    public boolean revokeAllConsents(@Nullable String aspspAccountId, @NotNull PsuIdData psuIdData, @Nullable String instanceId) {
        List<ConsentEntity> consents = consentJpaRepository
                                           .findAll(consentSpecification.byPsuIdDataAndAspspAccountIdAndInstanceId(psuIdData, aspspAccountId, instanceId))
                                           .stream()
                                           .distinct()
                                           .collect(Collectors.toList());

        List<ConsentEntity> filteredConsents = consents.stream()
                                                   .filter(cst -> !cst.getConsentStatus().isFinalisedStatus())
                                                   .collect(Collectors.toList());

        if (CollectionUtils.isEmpty(filteredConsents)) {
            return false;
        }

        filteredConsents.forEach(cst -> {
            cst.setLastActionDate(LocalDate.now());
            cst.setConsentStatus(ConsentStatus.REVOKED_BY_PSU);
        });

        return true;
    }

}