Skip to content

Commit

Permalink
fix: resolved various errors on broken JUnit tests (#33)
Browse files Browse the repository at this point in the history
* fix: resolved error on broken JUnit tests
* fix: upgraded some tests
* fix: added test on idempotency lock
* fix: incremented coverage on IdempotencyService
  • Loading branch information
andrea-deri authored Jun 24, 2024
1 parent 7d1cf30 commit 00b20f8
Show file tree
Hide file tree
Showing 10 changed files with 854 additions and 508 deletions.
499 changes: 227 additions & 272 deletions openapi/openapi.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
@RequiredArgsConstructor
public class ServiceBusService {

@Value("${azure.sb.connectionString}")
private String connectionString;

@Value("${azure.sb.paaInviaRT.name}")
private String queueName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.ZonedDateTime;

@Component
Expand All @@ -38,10 +37,10 @@ public class RTConsumer extends SBConsumer {
@Value("${azure.sb.paaInviaRT.name}")
private String queueName;

@Value("${wisp-converter.rt-send.max-retries}")
@Value("${wisp-converter.rt-send.max-retries:48}")
private Integer maxRetries;

@Value("${wisp-converter.rt-send.scheduling-time-in-hours}")
@Value("${wisp-converter.rt-send.scheduling-time-in-hours:1}")
private Integer schedulingTimeInHours;

@Autowired
Expand Down Expand Up @@ -148,7 +147,7 @@ private void resendRTToCreditorInstitution(String receiptId, RTRequestEntity rec
log.debug("Sending receipt [{}]", receiptId);

// unzip retrieved zipped payload from GZip format
byte[] unzippedPayload = ZipUtil.unzip(receipt.getPayload().getBytes(StandardCharsets.UTF_8));
byte[] unzippedPayload = ZipUtil.unzip(AppBase64Util.base64Decode(receipt.getPayload()));
SOAPMessage envelopeElement = jaxbElementUtil.getMessage(unzippedPayload);
IntestazionePPT header = jaxbElementUtil.getHeader(envelopeElement, IntestazionePPT.class);

Expand Down
217 changes: 190 additions & 27 deletions src/test/java/it/gov/pagopa/wispconverter/consumer/ConsumerTest.java

Large diffs are not rendered by default.

404 changes: 306 additions & 98 deletions src/test/java/it/gov/pagopa/wispconverter/endpoint/ReceiptTest.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import it.gov.pagopa.wispconverter.Application;
import it.gov.pagopa.wispconverter.controller.model.ReceiptTimerRequest;
import it.gov.pagopa.wispconverter.repository.CacheRepository;
import it.gov.pagopa.wispconverter.repository.RPTRequestRepository;
import it.gov.pagopa.wispconverter.repository.RTRequestRepository;
import it.gov.pagopa.wispconverter.repository.ReEventRepository;
import it.gov.pagopa.wispconverter.service.ConfigCacheService;
import it.gov.pagopa.wispconverter.service.PaaInviaRTSenderService;
import it.gov.pagopa.wispconverter.service.ReceiptTimerService;
import it.gov.pagopa.wispconverter.service.ServiceBusService;
import it.gov.pagopa.wispconverter.repository.*;
import it.gov.pagopa.wispconverter.service.*;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -78,10 +72,14 @@ public class ReceiptTimerTest {
private ReEventRepository reEventRepository;
@MockBean
private CacheRepository cacheRepository;
@MockBean
private IdempotencyKeyRepository idempotencyKeyRepository;
@Autowired
private MockMvc mockMvc;
@MockBean
private ReceiptTimerService receiptTimerService;
@MockBean
private ReceiptService receiptService;

/*
* CREATE receipt/timer
Expand Down
11 changes: 8 additions & 3 deletions src/test/java/it/gov/pagopa/wispconverter/utils/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,25 @@ public static it.gov.pagopa.gen.wispconverter.client.cache.model.ConfigDataV1Dto
return configDataV1;
}

public static it.gov.pagopa.gen.wispconverter.client.cache.model.ConfigDataV1Dto configDataCreditorInstitutionStations
(StationCreditorInstitutionDto stationCreditorInstitutionDto) {

public static it.gov.pagopa.gen.wispconverter.client.cache.model.ConfigDataV1Dto configDataCreditorInstitutionStations(StationCreditorInstitutionDto stationCreditorInstitutionDto) {
return configDataCreditorInstitutionStations(stationCreditorInstitutionDto, "/path", 2);
}

public static it.gov.pagopa.gen.wispconverter.client.cache.model.ConfigDataV1Dto configDataCreditorInstitutionStations(StationCreditorInstitutionDto stationCreditorInstitutionDto, String servicePath, int primitiveVersion) {
it.gov.pagopa.gen.wispconverter.client.cache.model.ConfigDataV1Dto configDataV1 = new it.gov.pagopa.gen.wispconverter.client.cache.model.ConfigDataV1Dto();
configDataV1.setCreditorInstitutionStations(new HashMap<>());
configDataV1.getCreditorInstitutionStations().put(stationCreditorInstitutionDto.getCreditorInstitutionCode(), stationCreditorInstitutionDto);
configDataV1.setStations(new HashMap<>());
it.gov.pagopa.gen.wispconverter.client.cache.model.StationDto station = new it.gov.pagopa.gen.wispconverter.client.cache.model.StationDto();
station.setStationCode(stationCreditorInstitutionDto.getStationCode());
station.setPrimitiveVersion(primitiveVersion);
station.setConnection(new ConnectionDto());
station.getConnection().setIp("127.0.0.1");
station.getConnection().setPort(8888L);
station.getConnection().setProtocol(ConnectionDto.ProtocolEnum.HTTP);
station.setService(new ServiceDto());
station.getService().setPath("/path");
station.getService().setPath(servicePath);
station.setRedirect(new it.gov.pagopa.gen.wispconverter.client.cache.model.RedirectDto());
station.getRedirect().setIp("127.0.0.1");
station.getRedirect().setPath("/redirect");
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ logging.level.it.gov.pagopa.wispconverter.util.client.checkout.CheckoutClientLog
logging.level.it.gov.pagopa.wispconverter.util.client.decouplercaching.DecouplerCachingClientLoggingInterceptor=DEBUG
logging.level.it.gov.pagopa.wispconverter.util.client.gpd.GpdClientLoggingInterceptor=DEBUG
logging.level.it.gov.pagopa.wispconverter.util.client.iuvgenerator.IuvGeneratorClientLoggingInterceptor=DEBUG

azure.sb.connectionString=Endpoint=sb://ServiceBusEndpoint;SharedAccessKeyName=sharedAccessKeyName;SharedAccessKey=sharedAccessKey
186 changes: 93 additions & 93 deletions src/test/resources/requests/paSendRTV2.xml
Original file line number Diff line number Diff line change
@@ -1,95 +1,95 @@
<soapenv:Envelope xmlns:pafn="http://pagopa-api.pagopa.gov.it/pa/paForNode.xsd" xmlns:ppt="http://ws.pagamenti.telematici.gov/ppthead" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.pagamenti.telematici.gov/">
<soapenv:Envelope xmlns:pafn="http://pagopa-api.pagopa.gov.it/pa/paForNode.xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<pafn:paSendRTReq>
<idPA>77777777777</idPA>
<idBrokerPA>77777777777</idBrokerPA>
<idStation>mystation</idStation>
<receipt>
<receiptId>c110729d258c4ab1b765fe902aae41d6</receiptId>
<noticeNumber>311111111112222222</noticeNumber>
<fiscalCode>77777777777</fiscalCode>
<outcome>OK</outcome>
<creditorReferenceId>11111111112222222</creditorReferenceId>
<paymentAmount>30.00</paymentAmount>
<description>test</description>
<companyName>company EC1</companyName>
<officeName>office EC</officeName>
<debtor>
<uniqueIdentifier>
<entityUniqueIdentifierType>F</entityUniqueIdentifierType>
<entityUniqueIdentifierValue>JHNDOE00A01F205N</entityUniqueIdentifierValue>
</uniqueIdentifier>
<fullName>John Doe</fullName>
<streetName>street</streetName>
<civicNumber>12</civicNumber>
<postalCode>89020</postalCode>
<city>city</city>
<stateProvinceRegion>MI</stateProvinceRegion>
<country>IT</country>
<e-mail>john.doe@test.it</e-mail>
</debtor>
<transferList>
<transfer>
<idTransfer>1</idTransfer>
<transferAmount>20.00</transferAmount>
<fiscalCodePA>77777777777</fiscalCodePA>
<companyName>company EC1</companyName>
<IBAN>IT0000000000000000000000000</IBAN>
<remittanceInformation>remittanceInformation1</remittanceInformation>
<transferCategory>0101100IM</transferCategory>
<metadata>
<mapEntry>
<key>keytest</key>
<value>1</value>
</mapEntry>
</metadata>
</transfer>
<transfer>
<idTransfer>2</idTransfer>
<transferAmount>10.00</transferAmount>
<fiscalCodePA>77777777778</fiscalCodePA>
<companyName>company EC2</companyName>
<IBAN>IT0000000000000000000000001</IBAN>
<remittanceInformation>remittanceInformation2</remittanceInformation>
<transferCategory>0201102IM</transferCategory>
</transfer>
</transferList>
<idPSP>88888888888</idPSP>
<pspFiscalCode>88888888888</pspFiscalCode>
<pspPartitaIVA>88888888888</pspPartitaIVA>
<PSPCompanyName>PSP name</PSPCompanyName>
<idChannel>88888888888_01</idChannel>
<channelDescription>app</channelDescription>
<payer>
<uniqueIdentifier>
<entityUniqueIdentifierType>F</entityUniqueIdentifierType>
<entityUniqueIdentifierValue>JHNDOE00A01F205N</entityUniqueIdentifierValue>
</uniqueIdentifier>
<fullName>John Doe</fullName>
<streetName>street</streetName>
<civicNumber>12</civicNumber>
<postalCode>89020</postalCode>
<city>city</city>
<stateProvinceRegion>MI</stateProvinceRegion>
<country>IT</country>
<e-mail>john.doe@test.it</e-mail>
</payer>
<paymentMethod>creditCard</paymentMethod>
<fee>2.00</fee>
<primaryCiIncurredFee>0.50</primaryCiIncurredFee>
<idBundle>1</idBundle>
<idCiBundle>2</idCiBundle>
<paymentDateTime>2021-10-01T17:48:22</paymentDateTime>
<applicationDate>2021-10-01</applicationDate>
<transferDate>2021-10-02</transferDate>
<metadata>
<mapEntry>
<key>keytest</key>
<value>1</value>
</mapEntry>
</metadata>
<standin>false</standin>
</receipt>
</pafn:paSendRTReq>
<pafn:paSendRTReq>
<idPA>77777777777</idPA>
<idBrokerPA>77777777777</idBrokerPA>
<idStation>mystation</idStation>
<receipt>
<receiptId>c110729d258c4ab1b765fe902aae41d6</receiptId>
<noticeNumber>348111111112222222</noticeNumber>
<fiscalCode>77777777777</fiscalCode>
<outcome>OK</outcome>
<creditorReferenceId>48111111112222222</creditorReferenceId>
<paymentAmount>30.00</paymentAmount>
<description>test</description>
<companyName>company EC1</companyName>
<officeName>office EC</officeName>
<debtor>
<uniqueIdentifier>
<entityUniqueIdentifierType>F</entityUniqueIdentifierType>
<entityUniqueIdentifierValue>JHNDOE00A01F205N</entityUniqueIdentifierValue>
</uniqueIdentifier>
<fullName>John Doe</fullName>
<streetName>street</streetName>
<civicNumber>12</civicNumber>
<postalCode>89020</postalCode>
<city>city</city>
<stateProvinceRegion>MI</stateProvinceRegion>
<country>IT</country>
<e-mail>john.doe@test.it</e-mail>
</debtor>
<transferList>
<transfer>
<idTransfer>1</idTransfer>
<transferAmount>20.00</transferAmount>
<fiscalCodePA>77777777777</fiscalCodePA>
<companyName>company EC1</companyName>
<IBAN>IT0000000000000000000000000</IBAN>
<remittanceInformation>remittanceInformation1</remittanceInformation>
<transferCategory>0101100IM</transferCategory>
<metadata>
<mapEntry>
<key>keytest</key>
<value>1</value>
</mapEntry>
</metadata>
</transfer>
<transfer>
<idTransfer>2</idTransfer>
<transferAmount>10.00</transferAmount>
<fiscalCodePA>77777777778</fiscalCodePA>
<companyName>company EC2</companyName>
<IBAN>IT0000000000000000000000001</IBAN>
<remittanceInformation>remittanceInformation2</remittanceInformation>
<transferCategory>0201102IM</transferCategory>
</transfer>
</transferList>
<idPSP>88888888888</idPSP>
<pspFiscalCode>88888888888</pspFiscalCode>
<pspPartitaIVA>88888888888</pspPartitaIVA>
<PSPCompanyName>PSP name</PSPCompanyName>
<idChannel>88888888888_01</idChannel>
<channelDescription>app</channelDescription>
<payer>
<uniqueIdentifier>
<entityUniqueIdentifierType>F</entityUniqueIdentifierType>
<entityUniqueIdentifierValue>JHNDOE00A01F205N</entityUniqueIdentifierValue>
</uniqueIdentifier>
<fullName>John Doe</fullName>
<streetName>street</streetName>
<civicNumber>12</civicNumber>
<postalCode>89020</postalCode>
<city>city</city>
<stateProvinceRegion>MI</stateProvinceRegion>
<country>IT</country>
<e-mail>john.doe@test.it</e-mail>
</payer>
<paymentMethod>creditCard</paymentMethod>
<fee>2.00</fee>
<primaryCiIncurredFee>0.50</primaryCiIncurredFee>
<idBundle>1</idBundle>
<idCiBundle>2</idCiBundle>
<paymentDateTime>2021-10-01T17:48:22</paymentDateTime>
<applicationDate>2021-10-01</applicationDate>
<transferDate>2021-10-02</transferDate>
<metadata>
<mapEntry>
<key>keytest</key>
<value>1</value>
</mapEntry>
</metadata>
<standin>false</standin>
</receipt>
</pafn:paSendRTReq>
</soapenv:Body>
</soapenv:Envelope>
</soapenv:Envelope>
19 changes: 19 additions & 0 deletions src/test/resources/requests/paaInviaRT.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<ns3:intestazionePPT xmlns:ns3="http://ws.pagamenti.telematici.gov/ppthead">
<identificativoIntermediarioPA>15376371009</identificativoIntermediarioPA>
<identificativoStazioneIntermediarioPA>15376371009_48</identificativoStazioneIntermediarioPA>
<identificativoDominio>15376371009</identificativoDominio>
<identificativoUnivocoVersamento>633836153345163</identificativoUnivocoVersamento>
<codiceContestoPagamento>437642378654347</codiceContestoPagamento>
</ns3:intestazionePPT>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns3:paaInviaRT xmlns:ns3="http://ws.pagamenti.telematici.gov/">
<rt>

</rt>
</ns3:paaInviaRT>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

0 comments on commit 00b20f8

Please sign in to comment.