Skip to content

Commit

Permalink
delete document api imp
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitolo-Andrea committed Jan 14, 2025
1 parent 53f9771 commit 559b3e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ public Mono<CitizenConsentDTO> deleteCitizenConsent(String fiscalCode) {
return citizenRepository.findByFiscalCode(fiscalCode)
.switchIfEmpty(Mono.error(exceptionMap.throwException
(ExceptionName.CITIZEN_NOT_ONBOARDED, "Citizen consent not founded during delete process ")))
.map(citizenConsent -> {
citizenRepository.deleteById(citizenConsent.getId());
return mapperToDTO.map(citizenConsent);
});
.flatMap(citizenConsent ->
citizenRepository.deleteById(citizenConsent.getId())
.then(Mono.just(mapperToDTO.map(citizenConsent)))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,13 @@ void getCitizenEnabled_Empty() {
@Test
void deleteCitizenConsent_OK() {
CitizenConsent citizenConsent = CitizenConsent.builder()
.id(FISCAL_CODE)
.fiscalCode(FISCAL_CODE)
.consents(new HashMap<>())
.build();

when(citizenRepository.findByFiscalCode(FISCAL_CODE)).thenReturn(Mono.just(citizenConsent));

when(citizenRepository.deleteById(FISCAL_CODE)).thenReturn(Mono.empty());
StepVerifier.create(citizenService.deleteCitizenConsent(FISCAL_CODE))
.assertNext(response -> {
assertNotNull(response);
Expand Down

0 comments on commit 559b3e0

Please sign in to comment.