Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [SRTP-230] extract subject from access token #62

Merged
merged 12 commits into from
Jan 31, 2025
Prev Previous commit
Next Next commit
update name rtpspid and spcreditor and move some code
lucaconsalvi committed Jan 31, 2025
commit f6bb7f58a95cf3c6560f2de335bf14e15e42e047
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ public class ActivationDtoMapper {

public ActivationDto toActivationDto(Payer payer) {
return new ActivationDto().id(payer.activationID().getId())
.payer(new PayerDto().fiscalCode(payer.fiscalCode()).rtpSpId(payer.rtpSpId()))
.payer(new PayerDto().fiscalCode(payer.fiscalCode()).rtpSpId(payer.rtpServiceProviderId()))
.effectiveActivationDate(LocalDateTime.ofInstant(payer.effectiveActivationDate(), ZoneOffset.UTC));
}
}
Original file line number Diff line number Diff line change
@@ -19,22 +19,22 @@ public Rtp toRtp(CreateRtpDto createRtpDto) {
.savingDateTime(LocalDateTime.now())
.payerName(createRtpDto.getPayer().getName())
.payerId(createRtpDto.getPayer().getPayerId()).payeeName(createRtpDto.getPayee().getName())
.payeeId(createRtpDto.getPayee().getPayeeId()).rtpSpId("rtpSpId").iban("iban")
.payeeId(createRtpDto.getPayee().getPayeeId()).rtpServiceProviderId("rtpServiceProviderId").iban("iban")
.subject(createRtpDto.getPaymentNotice().getSubject())
.payTrxRef(createRtpDto.getPayee().getPayTrxRef()).flgConf("flgConf").build();
}

public Rtp toRtpWithSpCr(CreateRtpDto createRtpDto, String subject) {
public Rtp toRtpWithServiceProviderCreditor(CreateRtpDto createRtpDto, String tokenSub) {
return Rtp.builder().noticeNumber(createRtpDto.getPaymentNotice().getNoticeNumber())
.amount(createRtpDto.getPaymentNotice().getAmount()).resourceID(ResourceID.createNew())
.description(createRtpDto.getPaymentNotice().getDescription())
.expiryDate(createRtpDto.getPaymentNotice().getExpiryDate())
.savingDateTime(LocalDateTime.now())
.payerName(createRtpDto.getPayer().getName())
.payerId(createRtpDto.getPayer().getPayerId()).payeeName(createRtpDto.getPayee().getName())
.payeeId(createRtpDto.getPayee().getPayeeId()).rtpSpId("rtpSpId").iban("iban")
.payeeId(createRtpDto.getPayee().getPayeeId()).rtpServiceProviderId("rtpServiceProviderId").iban("iban")
.subject(createRtpDto.getPaymentNotice().getSubject())
.spCreditor(subject)
.serviceProviderCreditor(tokenSub)
.payTrxRef(createRtpDto.getPayee().getPayTrxRef()).flgConf("flgConf").build();
}

Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
import it.gov.pagopa.rtp.activator.domain.errors.PayerNotActivatedException;
import it.gov.pagopa.rtp.activator.model.generated.send.CreateRtpDto;
import it.gov.pagopa.rtp.activator.service.rtp.SendRTPService;
import it.gov.pagopa.rtp.activator.utils.ExtractTokenInfo;
import it.gov.pagopa.rtp.activator.utils.TokenInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -34,9 +34,8 @@ public Mono<ResponseEntity<Void>> createRtp(Mono<CreateRtpDto> createRtpDto,
String version, ServerWebExchange exchange) {
log.info("Received request to create RTP");
return createRtpDto
.flatMap(rtpDto -> ExtractTokenInfo.getTokenSubject()
.switchIfEmpty(Mono.error(new IllegalStateException("Subject not found")))
.map(sub -> rtpDtoMapper.toRtpWithSpCr(rtpDto, sub)))
.flatMap(rtpDto -> TokenInfo.getTokenSubject()
.map(sub -> rtpDtoMapper.toRtpWithServiceProviderCreditor(rtpDto, sub)))
.flatMap(sendRTPService::send)
.thenReturn(new ResponseEntity<Void>(HttpStatus.CREATED))
.onErrorReturn(PayerNotActivatedException.class, ResponseEntity.unprocessableEntity().build())
Original file line number Diff line number Diff line change
@@ -2,5 +2,5 @@

import java.time.Instant;

public record Payer(ActivationID activationID, String rtpSpId, String fiscalCode, Instant effectiveActivationDate) {
public record Payer(ActivationID activationID, String rtpServiceProviderId, String fiscalCode, Instant effectiveActivationDate) {
}
12 changes: 6 additions & 6 deletions src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/Rtp.java
Original file line number Diff line number Diff line change
@@ -8,12 +8,12 @@
@Builder
public record Rtp(String noticeNumber, BigDecimal amount, String description, LocalDate expiryDate,
String payerId, String payerName, String payeeName, String payeeId, ResourceID resourceID,
String subject, LocalDateTime savingDateTime, String rtpSpId, String iban,
String payTrxRef, String flgConf, RtpStatus status, String spCreditor) {
String subject, LocalDateTime savingDateTime, String rtpServiceProviderId, String iban,
String payTrxRef, String flgConf, RtpStatus status, String serviceProviderCreditor) {

public Rtp toRtpWithActivationInfo(String rtpSpId) {
return Rtp.builder()
.rtpSpId(rtpSpId)
.rtpServiceProviderId(rtpSpId)
.iban(this.iban())
.payTrxRef(this.payTrxRef())
.flgConf(this.flgConf())
@@ -27,15 +27,15 @@ public Rtp toRtpWithActivationInfo(String rtpSpId) {
.expiryDate(this.expiryDate())
.resourceID(this.resourceID())
.subject(this.subject())
.spCreditor(this.spCreditor())
.serviceProviderCreditor(this.serviceProviderCreditor())
.savingDateTime(this.savingDateTime())
.status(RtpStatus.CREATED)
.build();
}

public Rtp toRtpSent(Rtp rtp) {
return Rtp.builder()
.rtpSpId(rtp.rtpSpId())
.rtpServiceProviderId(rtp.rtpServiceProviderId())
.iban(rtp.iban())
.payTrxRef(rtp.payTrxRef())
.flgConf(rtp.flgConf())
@@ -49,7 +49,7 @@ public Rtp toRtpSent(Rtp rtp) {
.expiryDate(rtp.expiryDate())
.resourceID(rtp.resourceID())
.subject(this.subject())
.spCreditor(this.spCreditor())
.serviceProviderCreditor(this.serviceProviderCreditor())
.savingDateTime(rtp.savingDateTime())
.status(RtpStatus.SENT)
.build();
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
public class ActivationEntity {
@Id
private String id;
private String rtpSpId;
private String rtpServiceProviderId;
private Instant effectiveActivationDate;

private String fiscalCode;
Original file line number Diff line number Diff line change
@@ -14,14 +14,14 @@ public Payer toDomain(ActivationEntity activationEntity) {
ActivationID activationID = new ActivationID(
UUID.fromString(activationEntity.getId()));
return new Payer(activationID,
activationEntity.getRtpSpId(), activationEntity.getFiscalCode(),
activationEntity.getRtpServiceProviderId(), activationEntity.getFiscalCode(),
activationEntity.getEffectiveActivationDate());
}

public ActivationEntity toDbEntity(Payer payer) {
return ActivationEntity.builder().id(payer.activationID().getId().toString())
.fiscalCode(payer.fiscalCode())
.rtpSpId(payer.rtpSpId())
.rtpServiceProviderId(payer.rtpServiceProviderId())
.effectiveActivationDate(payer.effectiveActivationDate())
.build();
}
Original file line number Diff line number Diff line change
@@ -29,11 +29,11 @@ public class RtpEntity {
private String payeeId;
private String subject;
private Instant savingDateTime;
private String rtpSpId;
private String rtpServiceProviderId;
private String iban;
private String payTrxRef;
private String flgConf;
private String status;
private String spCreditor;
private String serviceProviderCreditor;

}
Original file line number Diff line number Diff line change
@@ -23,13 +23,13 @@ public Rtp toDomain(RtpEntity rtpEntity) {
.payeeId(rtpEntity.getPayeeId())
.resourceID(new ResourceID(rtpEntity.getResourceID()))
.savingDateTime(LocalDateTime.ofInstant(rtpEntity.getSavingDateTime(), ZoneOffset.UTC))
.rtpSpId(rtpEntity.getRtpSpId())
.rtpServiceProviderId(rtpEntity.getRtpServiceProviderId())
.iban(rtpEntity.getIban())
.payTrxRef(rtpEntity.getPayTrxRef())
.flgConf(rtpEntity.getFlgConf())
.subject(rtpEntity.getSubject())
.status(RtpStatus.valueOf(rtpEntity.getStatus()))
.spCreditor(rtpEntity.getSpCreditor())
.serviceProviderCreditor(rtpEntity.getServiceProviderCreditor())
.build();
}

@@ -45,13 +45,13 @@ public RtpEntity toDbEntity(Rtp rtp) {
.payeeId(rtp.payeeId())
.resourceID(rtp.resourceID().getId())
.savingDateTime(rtp.savingDateTime().toInstant(ZoneOffset.UTC))
.rtpSpId(rtp.rtpSpId())
.rtpServiceProviderId(rtp.rtpServiceProviderId())
.iban(rtp.iban())
.payTrxRef(rtp.payTrxRef())
.flgConf(rtp.flgConf())
.subject(rtp.subject())
.status(rtp.status().name())
.spCreditor(rtp.spCreditor())
.serviceProviderCreditor(rtp.serviceProviderCreditor())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -22,10 +22,10 @@ public ActivationPayerServiceImpl(ActivationDBRepository activationDBRepository)
}

@Override
public Mono<Payer> activatePayer(String rtpSpId, String fiscalCode) {
public Mono<Payer> activatePayer(String rtpServiceProviderId, String fiscalCode) {

ActivationID activationID = ActivationID.createNew();
Payer payer = new Payer(activationID, rtpSpId, fiscalCode, Instant.now());
Payer payer = new Payer(activationID, rtpServiceProviderId, fiscalCode, Instant.now());

return activationDBRepository.findByFiscalCode(fiscalCode)
.flatMap(existingEntity -> Mono.<Payer>error(new PayerAlreadyExists()))
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ public Mono<Rtp> send(Rtp rtp) {
.onErrorMap(Throwable::getCause)
.map(response -> rtpToSend)
.defaultIfEmpty(rtpToSend)
.doOnSuccess(rtpSent -> log.info("RTP sent to {} with id: {}", rtpSent.rtpSpId(),
.doOnSuccess(rtpSent -> log.info("RTP sent to {} with id: {}", rtpSent.rtpServiceProviderId(),
rtpSent.resourceID().getId()))
)
.map(rtp::toRtpSent)
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ public SepaRequestToPayRequestResourceDto toEpcRequestToPay(Rtp rtp) {
.id(party38ChoiceEPC25922V30DS02Dto);

var dbtFinancialInstitutionIdentification18EPC25922V30DS02Dto = new FinancialInstitutionIdentification18EPC25922V30DS02Dto();
dbtFinancialInstitutionIdentification18EPC25922V30DS02Dto.setBICFI(rtp.rtpSpId());
dbtFinancialInstitutionIdentification18EPC25922V30DS02Dto.setBICFI(rtp.rtpServiceProviderId());

var dbtBranchAndFinancialInstitutionIdentification6EPC25922V30DS02Dto = new BranchAndFinancialInstitutionIdentification6EPC25922V30DS02Dto()
.finInstnId(dbtFinancialInstitutionIdentification18EPC25922V30DS02Dto);
Original file line number Diff line number Diff line change
@@ -5,15 +5,16 @@

import reactor.core.publisher.Mono;

public final class ExtractTokenInfo {
public final class TokenInfo {

private ExtractTokenInfo() {
private TokenInfo() {
}

public static Mono<String> getTokenSubject() {
return ReactiveSecurityContextHolder.getContext().map(ctx -> ctx.getAuthentication())
.map(auth -> auth.getPrincipal())
.cast(Jwt.class)
.flatMap(jwt -> Mono.just(jwt.getSubject()));
.map(jwt -> jwt.getSubject())
.switchIfEmpty(Mono.error(new IllegalStateException("Subject not found")));
}
}
Original file line number Diff line number Diff line change
@@ -137,7 +137,7 @@ void testFindActivationByPayerIdSuccess() {

Payer payer = new Payer(activationID, "testRtpSpId", "RSSMRA85T10A562S", Instant.now());

PayerDto payerDto = new PayerDto().fiscalCode(payer.fiscalCode()).rtpSpId(payer.rtpSpId());
PayerDto payerDto = new PayerDto().fiscalCode(payer.fiscalCode()).rtpSpId(payer.rtpServiceProviderId());

ActivationDto activationDto = new ActivationDto();
activationDto.setId(activationID.getId());
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ void testToRtp() {
assertThat(rtp.payerId()).isEqualTo(createRtpDto.getPayer().getPayerId());
assertThat(rtp.payeeName()).isEqualTo(createRtpDto.getPayee().getName());
assertThat(rtp.payeeId()).isEqualTo(createRtpDto.getPayee().getPayeeId());
assertThat(rtp.rtpSpId()).isEqualTo("rtpSpId");
assertThat(rtp.rtpServiceProviderId()).isEqualTo("rtpServiceProviderId");
assertThat(rtp.iban()).isEqualTo("iban");
assertThat(rtp.payTrxRef()).isEqualTo(createRtpDto.getPayee().getPayTrxRef());
assertThat(rtp.flgConf()).isEqualTo("flgConf");
@@ -82,7 +82,7 @@ void testTtoRtpWithSpCroRtp() {
payeeDto.setPayTrxRef("ABC/124");
createRtpDto.setPayee(payeeDto);

Rtp rtp = rtpDtoMapper.toRtpWithSpCr(createRtpDto,subject);
Rtp rtp = rtpDtoMapper.toRtpWithServiceProviderCreditor(createRtpDto,subject);
assertThat(rtp).isNotNull();
assertThat(rtp.resourceID()).isNotNull();
assertThat(rtp.savingDateTime()).isNotNull();
@@ -95,10 +95,10 @@ void testTtoRtpWithSpCroRtp() {
assertThat(rtp.payerId()).isEqualTo(createRtpDto.getPayer().getPayerId());
assertThat(rtp.payeeName()).isEqualTo(createRtpDto.getPayee().getName());
assertThat(rtp.payeeId()).isEqualTo(createRtpDto.getPayee().getPayeeId());
assertThat(rtp.rtpSpId()).isEqualTo("rtpSpId");
assertThat(rtp.rtpServiceProviderId()).isEqualTo("rtpServiceProviderId");
assertThat(rtp.iban()).isEqualTo("iban");
assertThat(rtp.payTrxRef()).isEqualTo(createRtpDto.getPayee().getPayTrxRef());
assertThat(rtp.flgConf()).isEqualTo("flgConf");
assertThat(rtp.spCreditor()).isEqualTo(subject);
assertThat(rtp.serviceProviderCreditor()).isEqualTo(subject);
}
}
Original file line number Diff line number Diff line change
@@ -70,22 +70,22 @@ void setup() {
String payerId = "payerId";
String payeeName = "Payee Name";
String payeeId = "payeeId";
String rtpSpId = "rtpSpId";
String rtpSpId = "rtpServiceProviderId";
String iban = "IT60X0542811101000000123456";
String flgConf = "flgConf";
String payerName = "John Doe";
String payTrxRef = "ABC/124";
String subject = "subject";
String spCreditor = "Pagopa";
String serviceProviderCreditor = "Pagopa";

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)
.savingDateTime(LocalDateTime.now()).rtpServiceProviderId(rtpSpId)
.payerName(payerName)
.subject(subject)
.spCreditor(spCreditor)
.serviceProviderCreditor(serviceProviderCreditor)
.iban(iban).payTrxRef(payTrxRef)
.flgConf(flgConf).build();

@@ -100,7 +100,7 @@ void setup() {
@RtpSenderWriter()
void testSendRtpSuccessful() {

when(rtpDtoMapper.toRtpWithSpCr(any(CreateRtpDto.class), eq("PagoPA"))).thenReturn(expectedRtp);
when(rtpDtoMapper.toRtpWithServiceProviderCreditor(any(CreateRtpDto.class), eq("PagoPA"))).thenReturn(expectedRtp);
when(sendRTPService.send(expectedRtp)).thenReturn(Mono.empty());

webTestClient
@@ -118,7 +118,7 @@ void testSendRtpSuccessful() {
@RtpSenderWriter
void testSendRtpWithWrongBody() {

when(rtpDtoMapper.toRtpWithSpCr(any(CreateRtpDto.class), anyString())).thenReturn(expectedRtp);
when(rtpDtoMapper.toRtpWithServiceProviderCreditor(any(CreateRtpDto.class), anyString())).thenReturn(expectedRtp);
when(sendRTPService.send(any()))
.thenReturn(Mono.empty());

@@ -134,7 +134,7 @@ void testSendRtpWithWrongBody() {
@RtpSenderWriter
void testSendRtpWithWrongAmount() {

when(rtpDtoMapper.toRtpWithSpCr(any(CreateRtpDto.class), anyString())).thenReturn(expectedRtp);
when(rtpDtoMapper.toRtpWithServiceProviderCreditor(any(CreateRtpDto.class), anyString())).thenReturn(expectedRtp);
when(sendRTPService.send(any()))
.thenReturn(Mono.empty());

@@ -164,7 +164,7 @@ void userWithoutEnoughPermissionShouldNotSendRtp() {
@RtpSenderWriter
void givenUserNotActivatedWhenSendRTPThenReturnUnprocessableEntity() {

when(rtpDtoMapper.toRtpWithSpCr(any(CreateRtpDto.class), anyString())).thenReturn(expectedRtp);
when(rtpDtoMapper.toRtpWithServiceProviderCreditor(any(CreateRtpDto.class), anyString())).thenReturn(expectedRtp);
when(sendRTPService.send(any()))
.thenReturn(Mono.error(new PayerNotActivatedException()));

@@ -176,14 +176,14 @@ void givenUserNotActivatedWhenSendRTPThenReturnUnprocessableEntity() {
.isEqualTo(HttpStatus.UNPROCESSABLE_ENTITY);

verify(sendRTPService, times(1)).send(any());
verify(rtpDtoMapper, times(1)).toRtpWithSpCr(any(),(any()));
verify(rtpDtoMapper, times(1)).toRtpWithServiceProviderCreditor(any(),(any()));
}

@Test
@RtpSenderWriter
void givenMessageBadFormedWhenSendRTPThenReturnBadRequest() {

when(rtpDtoMapper.toRtpWithSpCr(any(CreateRtpDto.class), anyString())).thenReturn(expectedRtp);
when(rtpDtoMapper.toRtpWithServiceProviderCreditor(any(CreateRtpDto.class), anyString())).thenReturn(expectedRtp);
when(sendRTPService.send(any()))
.thenReturn(Mono.error(generateMessageBadFormed()));

@@ -195,7 +195,7 @@ void givenMessageBadFormedWhenSendRTPThenReturnBadRequest() {
.isEqualTo(HttpStatus.BAD_REQUEST);

verify(sendRTPService, times(1)).send(any());
verify(rtpDtoMapper, times(1)).toRtpWithSpCr(any(),(any()));
verify(rtpDtoMapper, times(1)).toRtpWithServiceProviderCreditor(any(),(any()));
}

@Test
@@ -210,7 +210,7 @@ void givenBadFiscalCodeWhenSendRTPThenReturnBadRequest() {
.isEqualTo(HttpStatus.BAD_REQUEST);

verify(sendRTPService, times(0)).send(any());
verify(rtpDtoMapper, times(0)).toRtpWithSpCr(any(),(any()));
verify(rtpDtoMapper, times(0)).toRtpWithServiceProviderCreditor(any(),(any()));
}

@Test
@@ -251,7 +251,7 @@ void givenBadExpiryDate_whenSendRTP_thenReturnBadRequest() {
.jsonPath("$.details").exists();

verify(sendRTPService, times(0)).send(any());
verify(rtpDtoMapper, times(0)).toRtpWithSpCr(any(),(any()));
verify(rtpDtoMapper, times(0)).toRtpWithServiceProviderCreditor(any(),(any()));

}

Original file line number Diff line number Diff line change
@@ -18,15 +18,15 @@ class ActivationMapperTest {
void testToDomain() {
ActivationEntity activationEntity = new ActivationEntity();
activationEntity.setId(UUID.randomUUID().toString());
activationEntity.setRtpSpId("RTP_SP_ID");
activationEntity.setRtpServiceProviderId("RTP_SP_ID");
activationEntity.setFiscalCode("FISCAL_CODE");
activationEntity.setEffectiveActivationDate(Instant.ofEpochSecond(1732517304));

Payer payer = mapper.toDomain(activationEntity);

assertNotNull(payer);
assertEquals(activationEntity.getId(), payer.activationID().getId().toString());
assertEquals(activationEntity.getRtpSpId(), payer.rtpSpId());
assertEquals(activationEntity.getRtpServiceProviderId(), payer.rtpServiceProviderId());
assertEquals(activationEntity.getFiscalCode(), payer.fiscalCode());
assertEquals(activationEntity.getEffectiveActivationDate(), payer.effectiveActivationDate());
}
@@ -40,7 +40,7 @@ void testToDbEntity() {

assertNotNull(activationEntity);
assertEquals(payer.activationID().getId().toString(), activationEntity.getId());
assertEquals(payer.rtpSpId(), activationEntity.getRtpSpId());
assertEquals(payer.rtpServiceProviderId(), activationEntity.getRtpServiceProviderId());
assertEquals(payer.fiscalCode(), activationEntity.getFiscalCode());
assertEquals(payer.effectiveActivationDate(), activationEntity.getEffectiveActivationDate());
}
Original file line number Diff line number Diff line change
@@ -49,12 +49,12 @@ void testSaveRtp() {
.subject("subject")
.resourceID(new ResourceID(UUID.randomUUID()))
.savingDateTime(LocalDateTime.now())
.rtpSpId("rtpSpId")
.rtpServiceProviderId("rtpServiceProviderId")
.iban("iban123")
.payTrxRef("ABC/124")
.flgConf("Y")
.status(RtpStatus.CREATED)
.spCreditor("PagoPA")
.serviceProviderCreditor("PagoPA")
.build();

RtpEntity rtpEntity = RtpEntity.builder()
@@ -67,12 +67,12 @@ void testSaveRtp() {
.payeeId(rtp.payeeId())
.resourceID(rtp.resourceID().getId())
.savingDateTime(rtp.savingDateTime().toInstant(ZoneOffset.UTC))
.rtpSpId(rtp.rtpSpId())
.rtpServiceProviderId(rtp.rtpServiceProviderId())
.iban(rtp.iban())
.payTrxRef(rtp.payTrxRef())
.flgConf(rtp.flgConf())
.status("CREATED")
.spCreditor("PagoPA")
.serviceProviderCreditor("PagoPA")
.build();

when(rtpDB.save(any())).thenReturn(Mono.just(rtpEntity));
@@ -91,12 +91,12 @@ void testSaveRtp() {
assertEquals(rtp.payeeId(), savedRtp.payeeId());
assertEquals(rtp.resourceID().getId(), savedRtp.resourceID().getId());
assertEquals(rtp.savingDateTime(), savedRtp.savingDateTime());
assertEquals(rtp.rtpSpId(), savedRtp.rtpSpId());
assertEquals(rtp.rtpServiceProviderId(), savedRtp.rtpServiceProviderId());
assertEquals(rtp.iban(), savedRtp.iban());
assertEquals(rtp.payTrxRef(), savedRtp.payTrxRef());
assertEquals(rtp.flgConf(), savedRtp.flgConf());
assertEquals(rtp.status(), savedRtp.status());
assertEquals(rtp.spCreditor(), rtpEntity.getSpCreditor());
assertEquals(rtp.serviceProviderCreditor(), rtpEntity.getServiceProviderCreditor());
})
.verifyComplete();
}
Original file line number Diff line number Diff line change
@@ -39,12 +39,12 @@ void toDomain() {
.subject("subject")
.resourceID(uuid)
.savingDateTime(Instant.now())
.rtpSpId("rtpSpId")
.rtpServiceProviderId("rtpServiceProviderId")
.iban("iban123")
.payTrxRef("ABC/124")
.flgConf("Y")
.status(RtpStatus.CREATED.name())
.spCreditor("PagoPA")
.serviceProviderCreditor("PagoPA")
.build();

Rtp rtp = rtpMapper.toDomain(rtpEntity);
@@ -60,12 +60,12 @@ void toDomain() {
assertEquals(rtpEntity.getPayeeId(), rtp.payeeId());
assertEquals(rtpEntity.getResourceID(), rtp.resourceID().getId());
assertEquals(LocalDateTime.ofInstant(rtpEntity.getSavingDateTime(), ZoneOffset.UTC), rtp.savingDateTime());
assertEquals(rtpEntity.getRtpSpId(), rtp.rtpSpId());
assertEquals(rtpEntity.getRtpServiceProviderId(), rtp.rtpServiceProviderId());
assertEquals(rtpEntity.getIban(), rtp.iban());
assertEquals(rtpEntity.getPayTrxRef(), rtp.payTrxRef());
assertEquals(rtpEntity.getFlgConf(), rtp.flgConf());
assertEquals(rtpEntity.getStatus(), rtp.status().name());
assertEquals(rtpEntity.getSpCreditor(), rtp.spCreditor());
assertEquals(rtpEntity.getServiceProviderCreditor(), rtp.serviceProviderCreditor());
}

@Test
@@ -83,12 +83,12 @@ void toDbEntity() {
.resourceID(new ResourceID(uuid))
.subject("subject")
.savingDateTime(LocalDateTime.now())
.rtpSpId("rtpSpId")
.rtpServiceProviderId("rtpServiceProviderId")
.iban("iban123")
.payTrxRef("ABC/124")
.flgConf("Y")
.status(RtpStatus.CREATED)
.spCreditor("PagoPA")
.serviceProviderCreditor("PagoPA")
.build();

RtpEntity rtpEntity = rtpMapper.toDbEntity(rtp);
@@ -104,11 +104,11 @@ void toDbEntity() {
assertEquals(rtp.payeeId(), rtpEntity.getPayeeId());
assertEquals(rtp.resourceID().getId(), rtpEntity.getResourceID());
assertEquals(rtp.savingDateTime().toInstant(ZoneOffset.UTC), rtpEntity.getSavingDateTime());
assertEquals(rtp.rtpSpId(), rtpEntity.getRtpSpId());
assertEquals(rtp.rtpServiceProviderId(), rtpEntity.getRtpServiceProviderId());
assertEquals(rtp.iban(), rtpEntity.getIban());
assertEquals(rtp.payTrxRef(), rtpEntity.getPayTrxRef());
assertEquals(rtp.flgConf(), rtpEntity.getFlgConf());
assertEquals(rtp.status().name(), rtpEntity.getStatus());
assertEquals(rtp.spCreditor(), rtpEntity.getSpCreditor());
assertEquals(rtp.serviceProviderCreditor(), rtpEntity.getServiceProviderCreditor());
}
}
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ void testActivatePayerSuccessful() {

StepVerifier.create(activationPayerService.activatePayer(rtpSpId, fiscalCode)).expectNextMatches(pay -> {
// Verify payer details
assert pay.rtpSpId().equals(rtpSpId);
assert pay.rtpServiceProviderId().equals(rtpSpId);
assert pay.fiscalCode().equals(fiscalCode);
assert pay.activationID() != null;
assert pay.effectiveActivationDate() != null;
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ void setUp() {
.expiryDate(expiryDate)
.payerId(payerId).payeeName(payeeName).payeeId(payeeId)
.resourceID(ResourceID.createNew())
.savingDateTime(LocalDateTime.now()).rtpSpId(rtpSpId)
.savingDateTime(LocalDateTime.now()).rtpServiceProviderId(rtpSpId)
.iban(iban).payTrxRef(payTrxRef)
.flgConf(flgConf)
.payerName(payerName)
@@ -103,7 +103,7 @@ void testSend() {
.payerId(payerId).payeeName(payeeName).payeeId(payeeId)
.payerName(payerName)
.resourceID(ResourceID.createNew())
.savingDateTime(LocalDateTime.now()).rtpSpId(activationRtpSpId)
.savingDateTime(LocalDateTime.now()).rtpServiceProviderId(activationRtpSpId)
.iban(iban).payTrxRef(payTrxRef)
.status(RtpStatus.CREATED)
.flgConf(flgConf)
@@ -131,7 +131,7 @@ void testSend() {
&& rtp.payerName().equals(expectedRtp.payerName())
&& rtp.payeeName().equals(expectedRtp.payeeName())
&& rtp.payeeId().equals(expectedRtp.payeeId())
&& rtp.rtpSpId().equals(expectedRtp.rtpSpId())
&& rtp.rtpServiceProviderId().equals(expectedRtp.rtpServiceProviderId())
&& rtp.iban().equals(expectedRtp.iban())
&& rtp.payTrxRef().equals(expectedRtp.payTrxRef())
&& rtp.flgConf().equals(expectedRtp.flgConf())
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ void testToEpcRequestToPay() {
String subject = "subject";

Rtp nRtp = Rtp.builder().resourceID(resourceId).payerId(payerId).payerName(payerName).payeeId(payeeId)
.payeeName(payeeName).rtpSpId(rtpSpId).iban(iban).amount(amount)
.payeeName(payeeName).rtpServiceProviderId(rtpSpId).iban(iban).amount(amount)
.savingDateTime(savingDateTime).expiryDate(expiryDate).description(description).subject(subject)
.noticeNumber(noticeNumber).payTrxRef(payTrxRef).flgConf(flgConf).build();