generated from pagopa/template-java-spring-microservice
-
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: [PAGOPA-2032] sendRTV2 log (#123)
Co-authored-by: aacitelli <[email protected]>
- Loading branch information
1 parent
db54d60
commit a3cb7bd
Showing
5 changed files
with
213 additions
and
10 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
78 changes: 78 additions & 0 deletions
78
src/main/java/it/gov/pagopa/wispconverter/util/ReceiptRequestHandler.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,78 @@ | ||
package it.gov.pagopa.wispconverter.util; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.xml.sax.Attributes; | ||
import org.xml.sax.SAXException; | ||
import org.xml.sax.helpers.DefaultHandler; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper=false) | ||
@Component | ||
public class ReceiptRequestHandler extends DefaultHandler { | ||
|
||
private static final String NOTICE_NUMBER = "noticeNumber"; | ||
private static final String FISCAL_CODE = "fiscalCode"; | ||
private static final String CREDITOR_REFERENCE_ID = "creditorReferenceId"; | ||
|
||
private PaSendRTV2Request paSendRTV2Request; | ||
private StringBuilder elementValue; | ||
|
||
@Override | ||
public void characters(char[] ch, int start, int length) throws SAXException { | ||
if (elementValue == null) { | ||
elementValue = new StringBuilder(); | ||
} else { | ||
elementValue.append(ch, start, length); | ||
} | ||
} | ||
|
||
@Override | ||
public void startDocument() throws SAXException { | ||
paSendRTV2Request = new PaSendRTV2Request(); | ||
} | ||
|
||
@Override | ||
public void startElement(String uri, String lName, String qName, Attributes attr) throws SAXException { | ||
switch (qName) { | ||
case NOTICE_NUMBER: | ||
elementValue = new StringBuilder(); | ||
break; | ||
case FISCAL_CODE: | ||
elementValue = new StringBuilder(); | ||
break; | ||
case CREDITOR_REFERENCE_ID: | ||
elementValue = new StringBuilder(); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
@Override | ||
public void endElement(String uri, String localName, String qName) throws SAXException { | ||
switch (qName) { | ||
case NOTICE_NUMBER: | ||
paSendRTV2Request.setNoticeNumber(elementValue.toString()); | ||
break; | ||
case FISCAL_CODE: | ||
paSendRTV2Request.setFiscalCode(elementValue.toString()); | ||
break; | ||
case CREDITOR_REFERENCE_ID: | ||
paSendRTV2Request.setCreditorReferenceId(elementValue.toString()); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
@Data | ||
public class PaSendRTV2Request{ | ||
private String noticeNumber; | ||
private String fiscalCode; | ||
private String creditorReferenceId; | ||
} | ||
|
||
} |
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
31 changes: 31 additions & 0 deletions
31
src/test/java/it/gov/pagopa/wispconverter/utils/ReceiptRequestHandlerTest.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,31 @@ | ||
package it.gov.pagopa.wispconverter.utils; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.xml.parsers.ParserConfigurationException; | ||
import javax.xml.parsers.SAXParser; | ||
import javax.xml.parsers.SAXParserFactory; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.xml.sax.SAXException; | ||
|
||
import it.gov.pagopa.wispconverter.util.ReceiptRequestHandler; | ||
import it.gov.pagopa.wispconverter.util.ReceiptRequestHandler.PaSendRTV2Request; | ||
|
||
class ReceiptRequestHandlerTest { | ||
|
||
@Test | ||
void parsePaSendRTV2Request() throws ParserConfigurationException, SAXException, IOException { | ||
ReceiptRequestHandler receiptRequestHandler = new ReceiptRequestHandler(); | ||
SAXParserFactory factory = SAXParserFactory.newInstance(); | ||
SAXParser saxParser = factory.newSAXParser(); | ||
saxParser.parse("src/test/resources/requests/paSendRTV2Request.xml", receiptRequestHandler); | ||
|
||
PaSendRTV2Request result = receiptRequestHandler.getPaSendRTV2Request(); | ||
assertEquals("348172725623804858", result.getNoticeNumber()); | ||
assertEquals("15376371009", result.getFiscalCode()); | ||
assertEquals("863965926210520", result.getCreditorReferenceId()); | ||
} | ||
} |
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,67 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> | ||
<soapenv:Envelope | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" | ||
xmlns:tns="http://pagopa-api.pagopa.gov.it/paForNode" | ||
xmlns:common="http://pagopa-api.pagopa.gov.it/xsd/common-types/v1.0.0/" | ||
xmlns:pafn="http://pagopa-api.pagopa.gov.it/pa/paForNode.xsd"> | ||
<soapenv:Body> | ||
<pafn:paSendRTV2Request> | ||
<idPA>15376371009</idPA> | ||
<idBrokerPA>15376371009</idBrokerPA> | ||
<idStation>15376371009_48</idStation> | ||
<receipt> | ||
<receiptId>a0fffc676950472c94ca8e1456dc7b03</receiptId> | ||
<noticeNumber>348172725623804858</noticeNumber> | ||
<fiscalCode>15376371009</fiscalCode> | ||
<outcome>OK</outcome> | ||
<creditorReferenceId>863965926210520</creditorReferenceId> | ||
<paymentAmount>16.00</paymentAmount> | ||
<description>/RFB/863965926210520/16.00/TXT/DEBITORE/JHNDOE00A01F205N</description> | ||
<companyName>PagoPA S.p.A.</companyName> | ||
<debtor> | ||
<uniqueIdentifier> | ||
<entityUniqueIdentifierType>M</entityUniqueIdentifierType> | ||
<entityUniqueIdentifierValue>JHNDOE00A01F205N</entityUniqueIdentifierValue> | ||
</uniqueIdentifier> | ||
<fullName>John Doe</fullName> | ||
<streetName>Via qualsiasi</streetName> | ||
<civicNumber>1</civicNumber> | ||
<postalCode>00100</postalCode> | ||
<city>Roma</city> | ||
<stateProvinceRegion>RM</stateProvinceRegion> | ||
<country>IT</country> | ||
<e-mail>[email protected]</e-mail> | ||
</debtor> | ||
<transferList> | ||
<transfer> | ||
<idTransfer>1</idTransfer> | ||
<transferAmount>16.00</transferAmount> | ||
<fiscalCodePA>77777777777</fiscalCodePA> | ||
<companyName></companyName> | ||
<MBDAttachment>attachment</MBDAttachment> | ||
<remittanceInformation>/RFB/863965926210520/16.00/TXT/DEBITORE/JHNDOE00A01F205N</remittanceInformation> | ||
<transferCategory>9/0301116TS</transferCategory> | ||
<metadata> | ||
<mapEntry> | ||
<key>DatiSpecificiRiscossione</key> | ||
<value>9/0301116TS/9/11111111111</value> | ||
</mapEntry> | ||
</metadata> | ||
</transfer> | ||
</transferList> | ||
<idPSP>BCITITMM</idPSP> | ||
<pspFiscalCode>88888888888</pspFiscalCode> | ||
<PSPCompanyName>Intesa Sanpaolo S.p.A</PSPCompanyName> | ||
<idChannel>88888888888_01</idChannel> | ||
<channelDescription>app</channelDescription> | ||
<paymentMethod>creditCard</paymentMethod> | ||
<paymentNote>734b9b88-6186-4034-a79e-813efacf36a0</paymentNote> | ||
<fee>0.35</fee> | ||
<paymentDateTime>2024-09-25T11:24:01</paymentDateTime> | ||
<applicationDate>2024-09-25</applicationDate> | ||
<transferDate>2024-09-26</transferDate> | ||
</receipt> | ||
</pafn:paSendRTV2Request> | ||
</soapenv:Body> | ||
</soapenv:Envelope> |