Skip to content

Commit

Permalink
Fix Upsert
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitolo-Andrea committed Nov 13, 2024
1 parent 70b9158 commit 5aac812
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/it/gov/pagopa/tpp/service/TppServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.gov.pagopa.tpp.service;

import it.gov.pagopa.tpp.constants.TppConstants.ExceptionMessage;
import it.gov.pagopa.tpp.constants.TppConstants.ExceptionName;
import it.gov.pagopa.tpp.dto.TppDTO;
import it.gov.pagopa.tpp.dto.mapper.TppObjectToDTOMapper;
Expand Down Expand Up @@ -66,7 +67,7 @@ public Mono<TppDTO> upsert(TppDTO tppDTO) {
.doOnError(error -> log.error("[TPP-SERVICE][SAVE] Error saving TPP with tppId {}: {}", tppToUpdate.getTppId(), error.getMessage()));
})
.switchIfEmpty(Mono.error(exceptionMap.throwException(ExceptionName.TPP_NOT_ONBOARDED,
"Tpp not found during update process")));
ExceptionMessage.TPP_NOT_ONBOARDED)));
}
Mono<Tpp> tpp = tppRepository.findByEntityId(tppDTO.getEntityId())
.switchIfEmpty(
Expand All @@ -79,7 +80,7 @@ public Mono<TppDTO> upsert(TppDTO tppDTO) {
.doOnError(error -> log.error("[TPP-SERVICE][SAVE] Error saving TPP with tppId {}: {}", tppToSave.getTppId(), error.getMessage()));
})
)
.flatMap(existingTpp -> Mono.error(exceptionMap.throwException(ExceptionName.TPP_ALREADY_ONBOARDED, "Tpp not found during update process")));
.flatMap(existingTpp -> Mono.error(exceptionMap.throwException(ExceptionName.TPP_ALREADY_ONBOARDED, ExceptionMessage.TPP_ALREADY_ONBOARDED)));
return tpp.map(mapperToDTO::map);
}

Expand Down

0 comments on commit 5aac812

Please sign in to comment.