diff --git a/src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/Rtp.java b/src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/Rtp.java index b122f02..4d15b31 100644 --- a/src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/Rtp.java +++ b/src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/Rtp.java @@ -4,6 +4,8 @@ import java.time.LocalDate; import java.time.LocalDateTime; +import lombok.Builder; +@Builder public record Rtp(String noticeNumber, BigDecimal amount, String description, LocalDate expiryDate, String payerId, String payeeName, String payeeId, ResourceID resourceID, LocalDateTime savingDateTime, diff --git a/src/main/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceImpl.java b/src/main/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceImpl.java index 69bfe8d..d9fb994 100644 --- a/src/main/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceImpl.java +++ b/src/main/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceImpl.java @@ -29,7 +29,7 @@ @Service @Slf4j @RegisterReflectionForBinding({ SepaRequestToPayRequestResourceDto.class, - PersonIdentification13EPC25922V30DS02WrapperDto.class,ISODateWrapperDto.class, + PersonIdentification13EPC25922V30DS02WrapperDto.class, ISODateWrapperDto.class, ExternalPersonIdentification1CodeEPC25922V30DS02WrapperDto.class, ExternalServiceLevel1CodeWrapperDto.class, ActiveOrHistoricCurrencyAndAmountEPC25922V30DS02WrapperDto.class, Max35TextWrapperDto.class, OrganisationIdentification29EPC25922V30DS022WrapperDto.class, @@ -44,13 +44,15 @@ public SendRTPServiceImpl(SepaRequestToPayMapper sepaRequestToPayMapper) { } @Override - public Mono send(String noticeNumber, BigDecimal amount, String description, LocalDate expiryDate, String payerId, + public Mono send(String noticeNumber, BigDecimal amount, String description, LocalDate expiryDate, + String payerId, String payeeName, String payeeId, String rtpSpId, String endToEndId, String iban, String payTrxRef, String flgConf) { - Rtp rtp = new Rtp(noticeNumber, amount, description, expiryDate, payerId, payeeName, payeeId, - ResourceID.createNew(), LocalDateTime.now(), rtpSpId, endToEndId, iban, payTrxRef, flgConf); - + Rtp rtp = Rtp.builder().noticeNumber(noticeNumber).amount(amount).description(description).expiryDate(expiryDate) + .payerId(payerId).payeeName(payeeName).payeeId(payeeId).resourceID(ResourceID.createNew()) + .savingDateTime(LocalDateTime.now()).rtpSpId(rtpSpId).endToEndId(endToEndId).iban(iban).payTrxRef(payTrxRef) + .flgConf(flgConf).build(); // save ObjectMapper objectMapper = new ObjectMapper(); objectMapper.enable(SerializationFeature.INDENT_OUTPUT); diff --git a/src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceTest.java b/src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceTest.java index baf34d2..8c9976d 100644 --- a/src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceTest.java +++ b/src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceTest.java @@ -53,15 +53,21 @@ void testSend() { String payTrxRef = "payTrxRef"; String flgConf = "flgConf"; - Rtp expectedRtp = new Rtp(noticeNumber, amount, description, expiryDate, payerId, payeeName, payeeId, - ResourceID.createNew(), LocalDateTime.now(),"rtpSpId", endToEndId, iban, payTrxRef, flgConf); - + Rtp expectedRtp = Rtp.builder().noticeNumber(noticeNumber).amount(amount).description(description) + .expiryDate(expiryDate) + .payerId(payerId).payeeName(payeeName).payeeId(payeeId) + .resourceID(ResourceID.createNew()) + .savingDateTime(LocalDateTime.now()).rtpSpId("rtpSpId").endToEndId(endToEndId) + .iban(iban).payTrxRef(payTrxRef) + .flgConf(flgConf).build(); SepaRequestToPayRequestResourceDto mockSepaRequestToPayRequestResource = new SepaRequestToPayRequestResourceDto( URI.create("http://callback.url")); - when(sepaRequestToPayMapper.toRequestToPay(any(Rtp.class))).thenReturn(mockSepaRequestToPayRequestResource); + when(sepaRequestToPayMapper.toRequestToPay(any(Rtp.class))) + .thenReturn(mockSepaRequestToPayRequestResource); - Mono result = sendRTPService.send(noticeNumber, amount, description, expiryDate, payerId, payeeName, + Mono result = sendRTPService.send(noticeNumber, amount, description, expiryDate, payerId, + payeeName, payeeId, rtpSpId, endToEndId, iban, payTrxRef, flgConf); StepVerifier.create(result) .expectNextMatches(rtp -> rtp.noticeNumber().equals(expectedRtp.noticeNumber()) @@ -73,7 +79,8 @@ void testSend() { && rtp.payeeId().equals(expectedRtp.payeeId()) && rtp.rtpSpId().equals(expectedRtp.rtpSpId()) && rtp.endToEndId().equals(expectedRtp.endToEndId()) - && rtp.iban().equals(expectedRtp.iban()) && rtp.payTrxRef().equals(expectedRtp.payTrxRef()) + && rtp.iban().equals(expectedRtp.iban()) + && rtp.payTrxRef().equals(expectedRtp.payTrxRef()) && rtp.flgConf().equals(expectedRtp.flgConf())) .verifyComplete(); verify(sepaRequestToPayMapper, times(1)).toRequestToPay(any(Rtp.class));