Skip to content

Commit

Permalink
add the extraction of the subject from jwt token and update the relat…
Browse files Browse the repository at this point in the history
…ive tests
  • Loading branch information
lucaconsalvi committed Jan 31, 2025
1 parent 966afb4 commit f048952
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Rtp toRtpWithSpCr(CreateRtpDto createRtpDto, String subject) {
.payerId(createRtpDto.getPayer().getPayerId()).payeeName(createRtpDto.getPayee().getName())
.payeeId(createRtpDto.getPayee().getPayeeId()).rtpSpId("rtpSpId").iban("iban")
.subject(createRtpDto.getPaymentNotice().getSubject())
.SpCreditor(subject)
.spCreditor(subject)
.payTrxRef(createRtpDto.getPayee().getPayTrxRef()).flgConf("flgConf").build();
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/Rtp.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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 payTrxRef, String flgConf, RtpStatus status, String spCreditor) {

public Rtp toRtpWithActivationInfo(String rtpSpId) {
return Rtp.builder()
Expand All @@ -27,7 +27,7 @@ public Rtp toRtpWithActivationInfo(String rtpSpId) {
.expiryDate(this.expiryDate())
.resourceID(this.resourceID())
.subject(this.subject())
.SpCreditor(this.SpCreditor())
.spCreditor(this.spCreditor())
.savingDateTime(this.savingDateTime())
.status(RtpStatus.CREATED)
.build();
Expand All @@ -49,7 +49,7 @@ public Rtp toRtpSent(Rtp rtp) {
.expiryDate(rtp.expiryDate())
.resourceID(rtp.resourceID())
.subject(this.subject())
.SpCreditor(this.SpCreditor())
.spCreditor(this.spCreditor())
.savingDateTime(rtp.savingDateTime())
.status(RtpStatus.SENT)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ public class RtpEntity {
private String payTrxRef;
private String flgConf;
private String status;
private String spCreditor;

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public Rtp toDomain(RtpEntity rtpEntity) {
.flgConf(rtpEntity.getFlgConf())
.subject(rtpEntity.getSubject())
.status(RtpStatus.valueOf(rtpEntity.getStatus()))
.spCreditor(rtpEntity.getSpCreditor())
.build();
}

Expand All @@ -50,6 +51,7 @@ public RtpEntity toDbEntity(Rtp rtp) {
.flgConf(rtp.flgConf())
.subject(rtp.subject())
.status(rtp.status().name())
.spCreditor(rtp.spCreditor())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ void testTtoRtpWithSpCroRtp() {
assertThat(rtp.iban()).isEqualTo("iban");
assertThat(rtp.payTrxRef()).isEqualTo(createRtpDto.getPayee().getPayTrxRef());
assertThat(rtp.flgConf()).isEqualTo("flgConf");
assertThat(rtp.SpCreditor()).isEqualTo(subject);
assertThat(rtp.spCreditor()).isEqualTo(subject);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void setup() {
.savingDateTime(LocalDateTime.now()).rtpSpId(rtpSpId)
.payerName(payerName)
.subject(subject)
.SpCreditor(SpCreditor)
.spCreditor(SpCreditor)
.iban(iban).payTrxRef(payTrxRef)
.flgConf(flgConf).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void testSaveRtp() {
.payTrxRef("ABC/124")
.flgConf("Y")
.status(RtpStatus.CREATED)
.spCreditor("PagoPA")
.build();

RtpEntity rtpEntity = RtpEntity.builder()
Expand All @@ -71,6 +72,7 @@ void testSaveRtp() {
.payTrxRef(rtp.payTrxRef())
.flgConf(rtp.flgConf())
.status("CREATED")
.spCreditor("PagoPA")
.build();

when(rtpDB.save(any())).thenReturn(Mono.just(rtpEntity));
Expand All @@ -94,6 +96,7 @@ void testSaveRtp() {
assertEquals(rtp.payTrxRef(), savedRtp.payTrxRef());
assertEquals(rtp.flgConf(), savedRtp.flgConf());
assertEquals(rtp.status(), savedRtp.status());
assertEquals(rtp.spCreditor(), rtpEntity.getSpCreditor());
})
.verifyComplete();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void toDomain() {
.payTrxRef("ABC/124")
.flgConf("Y")
.status(RtpStatus.CREATED.name())
.spCreditor("PagoPA")
.build();

Rtp rtp = rtpMapper.toDomain(rtpEntity);
Expand All @@ -64,6 +65,7 @@ void toDomain() {
assertEquals(rtpEntity.getPayTrxRef(), rtp.payTrxRef());
assertEquals(rtpEntity.getFlgConf(), rtp.flgConf());
assertEquals(rtpEntity.getStatus(), rtp.status().name());
assertEquals(rtpEntity.getSpCreditor(), rtp.spCreditor());
}

@Test
Expand All @@ -86,6 +88,7 @@ void toDbEntity() {
.payTrxRef("ABC/124")
.flgConf("Y")
.status(RtpStatus.CREATED)
.spCreditor("PagoPA")
.build();

RtpEntity rtpEntity = rtpMapper.toDbEntity(rtp);
Expand All @@ -106,5 +109,6 @@ void toDbEntity() {
assertEquals(rtp.payTrxRef(), rtpEntity.getPayTrxRef());
assertEquals(rtp.flgConf(), rtpEntity.getFlgConf());
assertEquals(rtp.status().name(), rtpEntity.getStatus());
assertEquals(rtp.spCreditor(), rtpEntity.getSpCreditor());
}
}

0 comments on commit f048952

Please sign in to comment.