-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [SRTP-124] Add sepa mapping (#32)
Co-authored-by: Andrea Morabito <andrea.morabito@pagopa.it>
- v1.20.0
- v1.19.1
- v1.19.0
- v1.18.0
- v1.17.0
- v1.16.0
- v1.15.0
- v1.14.2
- v1.14.1
- v1.14.0
- v1.13.3
- v1.13.2
- v1.13.1
- v1.13.0
- v1.12.1
- v1.12.0
- v1.11.4
- v1.11.3
- v1.11.2
- v1.11.1
- v1.11.0
- v1.10.4
- v1.10.3
- v1.10.2
- v1.10.1
- v1.10.0
- v1.9.5
- v1.9.4
- v1.9.3
- v1.9.2
- v1.9.1
- v1.9.0
- v1.8.0
- v1.7.1
- v1.7.0
- v1.6.5
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
1 parent
a2af931
commit 35df6db
Showing
29 changed files
with
670 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ov/pagopa/rtp/activator/domain/Payer.java → ...opa/rtp/activator/domain/payer/Payer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../pagopa/rtp/activator/domain/PayerID.java → ...a/rtp/activator/domain/payer/PayerID.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rtp/activator/domain/PayerRepository.java → ...tivator/domain/payer/PayerRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/ResourceID.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package it.gov.pagopa.rtp.activator.domain.rtp; | ||
|
||
import java.util.UUID; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class ResourceID { | ||
|
||
private final UUID id; | ||
|
||
public ResourceID(UUID uuid) { | ||
this.id = uuid; | ||
} | ||
|
||
public static ResourceID createNew() { | ||
UUID uuid = UUID.randomUUID(); | ||
return new ResourceID(uuid); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/Rtp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package it.gov.pagopa.rtp.activator.domain.rtp; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
|
||
public record Rtp(String noticeNumber, Integer amount, String description, LocalDate expiryDate, String payerId, | ||
String payeeName, String payeeId, | ||
ResourceID resourceID, LocalDateTime savingDateTime, | ||
String rtpSpId, String endToEndId, String iban, String payTrxRef, String flgConf) { | ||
} |
2 changes: 1 addition & 1 deletion
2
...tp/activator/repository/ActivationDB.java → ...r/repository/activation/ActivationDB.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package it.gov.pagopa.rtp.activator.repository; | ||
package it.gov.pagopa.rtp.activator.repository.activation; | ||
|
||
|
||
|
||
|
6 changes: 3 additions & 3 deletions
6
...or/repository/ActivationDBRepository.java → ...ry/activation/ActivationDBRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ctivator/repository/ActivationEntity.java → ...pository/activation/ActivationEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ctivator/repository/ActivationMapper.java → ...pository/activation/ActivationMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/main/java/it/gov/pagopa/rtp/activator/service/SendRTPService.java
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...vator/service/ActivationPayerService.java → ...ce/activation/ActivationPayerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...r/service/ActivationPayerServiceImpl.java → ...ctivation/ActivationPayerServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package it.gov.pagopa.rtp.activator.service.rtp; | ||
|
||
import java.time.LocalDate; | ||
import it.gov.pagopa.rtp.activator.domain.rtp.Rtp; | ||
import reactor.core.publisher.Mono; | ||
|
||
public interface SendRTPService { | ||
Mono<Rtp> send(String noticeNumber, Integer amount, String description, LocalDate expiryDate, String payerId, | ||
String payeeName, String payeeId, String rtpSpId, String endToEndId, String iban, String payTrxRef, | ||
String flgConf); | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package it.gov.pagopa.rtp.activator.service.rtp; | ||
|
||
import it.gov.pagopa.rtp.activator.domain.rtp.ResourceID; | ||
import it.gov.pagopa.rtp.activator.domain.rtp.Rtp; | ||
import lombok.extern.slf4j.Slf4j; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
|
||
@Service | ||
@Slf4j | ||
public class SendRTPServiceImpl implements SendRTPService { | ||
|
||
private SepaRequestToPayMapper sepaRequestToPayMapper; | ||
|
||
public SendRTPServiceImpl(SepaRequestToPayMapper sepaRequestToPayMapper) { | ||
this.sepaRequestToPayMapper = sepaRequestToPayMapper; | ||
} | ||
|
||
@Override | ||
public Mono<Rtp> send(String noticeNumber, Integer 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); | ||
// save | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
objectMapper.enable(SerializationFeature.INDENT_OUTPUT); | ||
|
||
try { // | ||
String jsonString = objectMapper.writeValueAsString(sepaRequestToPayMapper.toRequestToPay(rtp)); | ||
log.info(jsonString); | ||
} catch (JsonProcessingException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
return Mono.just(rtp); | ||
} | ||
} |
226 changes: 226 additions & 0 deletions
226
src/main/java/it/gov/pagopa/rtp/activator/service/rtp/SepaRequestToPayMapper.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/test/java/it/gov/pagopa/rtp/activator/controller/SendAPIControllerImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package it.gov.pagopa.rtp.activator.controller; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
|
||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.security.test.context.support.WithMockUser; | ||
import org.springframework.test.context.aot.DisabledInAotMode; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
import org.springframework.test.web.reactive.server.WebTestClient; | ||
|
||
import it.gov.pagopa.rtp.activator.configuration.SecurityConfig; | ||
|
||
import it.gov.pagopa.rtp.activator.model.generated.send.CreateRtpDto; | ||
import it.gov.pagopa.rtp.activator.model.generated.send.PayeeDto; | ||
import it.gov.pagopa.rtp.activator.service.rtp.SendRTPService; | ||
import it.gov.pagopa.rtp.activator.utils.Users; | ||
import reactor.core.publisher.Mono; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyInt; | ||
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.Mockito.when; | ||
import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.springSecurity; | ||
|
||
import java.time.LocalDate; | ||
|
||
@ExtendWith(SpringExtension.class) | ||
@WebFluxTest(controllers = { SendAPIControllerImpl.class }) | ||
@Import({ SecurityConfig.class }) | ||
@DisabledInAotMode | ||
class SendAPIControllerImplTest { | ||
|
||
@MockBean | ||
private SendRTPService sendRTPService; | ||
|
||
private WebTestClient webTestClient; | ||
|
||
@Autowired | ||
private ApplicationContext context; | ||
|
||
@BeforeEach | ||
void setup() { | ||
webTestClient = WebTestClient | ||
.bindToApplicationContext(context) | ||
.apply(springSecurity()) | ||
.configureClient() | ||
.build(); | ||
} | ||
|
||
@Test | ||
@Users.RtpSenderWriter | ||
void testSendRtpSuccessful() { | ||
|
||
when(sendRTPService.send(anyString(), anyInt(), anyString(), any(), anyString(), anyString(), anyString(), | ||
anyString(), anyString(),anyString(), anyString(), anyString())) | ||
.thenReturn(Mono.empty()); | ||
|
||
webTestClient.post() | ||
.uri("/rtps") | ||
.bodyValue(generateSendRequest()) | ||
.exchange() | ||
.expectStatus() | ||
.isCreated() | ||
.expectBody() | ||
.isEmpty(); | ||
} | ||
|
||
@Test | ||
@Users.RtpSenderWriter | ||
void testSendRtpWithWrongBody() { | ||
|
||
when(sendRTPService.send(anyString(), anyInt(), anyString(), any(), anyString(), anyString(), anyString(), | ||
anyString(), anyString(),anyString(), anyString(), anyString())) | ||
.thenReturn(Mono.empty()); | ||
|
||
webTestClient.post() | ||
.uri("/rtps") | ||
.bodyValue(generateWrongSendRequest()) | ||
.exchange() | ||
.expectStatus() | ||
.isEqualTo(HttpStatus.BAD_REQUEST); | ||
} | ||
|
||
@Test | ||
@WithMockUser | ||
void userWithoutEnoughPermissionShouldNotSendRtp() { | ||
webTestClient.post() | ||
.uri("/rtps") | ||
.bodyValue(generateSendRequest()) | ||
.exchange() | ||
.expectStatus() | ||
.isEqualTo(HttpStatus.FORBIDDEN); | ||
} | ||
|
||
private CreateRtpDto generateSendRequest() { | ||
return new CreateRtpDto("311111111112222222", 1, "description", LocalDate.now(), "payerId", | ||
new PayeeDto("77777777777", "payeeName")); | ||
} | ||
|
||
private CreateRtpDto generateWrongSendRequest() { | ||
return new CreateRtpDto("noticenumber", 1, "description", LocalDate.now(), "payerId", | ||
new PayeeDto("dsds", "payeeName")); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
...opa/rtp/activator/domain/PayerIDTest.java → ...p/activator/domain/payer/PayerIDTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/test/java/it/gov/pagopa/rtp/activator/domain/rtp/ResourceIDTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package it.gov.pagopa.rtp.activator.domain.rtp; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import java.util.UUID; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class ResourceIDTest { | ||
@Test | ||
void testCreateNew() { | ||
ResourceID resourceID = ResourceID.createNew(); | ||
assertNotNull(resourceID); | ||
assertNotNull(resourceID.getId()); | ||
} | ||
|
||
@Test | ||
void testConstructor() { | ||
UUID uuid = UUID.randomUUID(); | ||
ResourceID resourceID = new ResourceID(uuid); | ||
assertNotNull(resourceID); | ||
assertEquals(uuid, resourceID.getId()); | ||
} | ||
|
||
} |
6 changes: 3 additions & 3 deletions
6
...ator/repository/ActivationMapperTest.java → ...tory/activation/ActivationMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package it.gov.pagopa.rtp.activator.service.rtp; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.net.URI; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import it.gov.pagopa.rtp.activator.domain.rtp.ResourceID; | ||
import it.gov.pagopa.rtp.activator.domain.rtp.Rtp; | ||
import it.gov.pagopa.rtp.activator.model.generated.epc.SepaRequestToPayRequestResourceDto; | ||
import reactor.core.publisher.Mono; | ||
import reactor.test.StepVerifier; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class SendRTPServiceTest { | ||
|
||
@Mock | ||
private SepaRequestToPayMapper sepaRequestToPayMapper; | ||
|
||
@InjectMocks | ||
private SendRTPServiceImpl sendRTPService; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
MockitoAnnotations.openMocks(this); | ||
} | ||
|
||
@Test | ||
void testSend() { | ||
String noticeNumber = "12345"; | ||
Integer amount = 100; | ||
String description = "Payment Description"; | ||
LocalDate expiryDate = LocalDate.now(); | ||
String payerId = "payerId"; | ||
String payeeName = "Payee Name"; | ||
String payeeId = "payeeId"; | ||
String endToEndId = "endToEndId"; | ||
String rtpSpId = "rtpSpId"; | ||
String iban = "IT60X0542811101000000123456"; | ||
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); | ||
|
||
SepaRequestToPayRequestResourceDto mockSepaRequestToPayRequestResource = new SepaRequestToPayRequestResourceDto( | ||
URI.create("http://callback.url")); | ||
|
||
when(sepaRequestToPayMapper.toRequestToPay(any(Rtp.class))).thenReturn(mockSepaRequestToPayRequestResource); | ||
|
||
Mono<Rtp> 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()) | ||
&& rtp.amount().equals(expectedRtp.amount()) | ||
&& rtp.description().equals(expectedRtp.description()) | ||
&& rtp.expiryDate().equals(expectedRtp.expiryDate()) | ||
&& rtp.payerId().equals(expectedRtp.payerId()) | ||
&& rtp.payeeName().equals(expectedRtp.payeeName()) | ||
&& 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.flgConf().equals(expectedRtp.flgConf())) | ||
.verifyComplete(); | ||
verify(sepaRequestToPayMapper, times(1)).toRequestToPay(any(Rtp.class)); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SepaRequestToPayMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package it.gov.pagopa.rtp.activator.service.rtp; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.*; | ||
|
||
import it.gov.pagopa.rtp.activator.domain.rtp.ResourceID; | ||
import it.gov.pagopa.rtp.activator.domain.rtp.Rtp; | ||
import it.gov.pagopa.rtp.activator.model.generated.epc.SepaRequestToPayRequestResourceDto; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
|
||
class SepaRequestToPayMapperTest { | ||
|
||
@Mock | ||
private Rtp rtp; | ||
|
||
@InjectMocks | ||
private SepaRequestToPayMapper sepaRequestToPayMapper; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
MockitoAnnotations.openMocks(this); | ||
} | ||
|
||
@Test | ||
void testToRequestToPay() { | ||
ResourceID resourceId = ResourceID.createNew(); | ||
String payerId = "payerId123"; | ||
String payeeId = "payeeId123"; | ||
String payeeName = "Mario Rossi"; | ||
String rtpSpId = "BIC123456"; | ||
String iban = "IT60X0542811101000000123456"; | ||
String endToEndId = "endToEndId123"; | ||
BigDecimal amount = BigDecimal.valueOf(10); | ||
LocalDateTime savingDateTime = LocalDateTime.now(); | ||
LocalDate expiryDate = LocalDate.now().plusDays(5); | ||
String description = "Pagamento TARI"; | ||
String noticeNumber = "123456"; | ||
String payTrxRef = "payTrxRef123"; | ||
String flgConf = "flgConf123"; | ||
|
||
when(rtp.resourceID()).thenReturn(resourceId); | ||
when(rtp.payerId()).thenReturn(payerId); | ||
when(rtp.payeeId()).thenReturn(payeeId); | ||
when(rtp.payeeName()).thenReturn(payeeName); | ||
when(rtp.rtpSpId()).thenReturn(rtpSpId); | ||
when(rtp.iban()).thenReturn(iban); | ||
when(rtp.endToEndId()).thenReturn(endToEndId); | ||
when(rtp.amount()).thenReturn(amount.intValue()); | ||
when(rtp.savingDateTime()).thenReturn(savingDateTime); | ||
when(rtp.expiryDate()).thenReturn(expiryDate); | ||
when(rtp.description()).thenReturn(description); | ||
when(rtp.noticeNumber()).thenReturn(noticeNumber); | ||
when(rtp.payTrxRef()).thenReturn(payTrxRef); | ||
when(rtp.flgConf()).thenReturn(flgConf); | ||
|
||
SepaRequestToPayRequestResourceDto result = sepaRequestToPayMapper.toRequestToPay(rtp); | ||
|
||
assertNotNull(result); | ||
assertEquals(resourceId.getId().toString(), result.getResourceId()); | ||
assertEquals("http://spsrtp.api.cstar.pagopa.it", result.getCallbackUrl().toString()); | ||
assertEquals(resourceId.getId().toString(), result.getDocument().getCdtrPmtActvtnReq().getGrpHdr().getMsgId()); | ||
assertTrue(result.getDocument().getCdtrPmtActvtnReq().getPmtInf().get(0).getCdtTrfTx().get(0).getRmtInf().getUstrd().contains(description)); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters