Skip to content

Commit

Permalink
Merge pull request #80 from pagopa/PAGOPA-1384-fix-date-format-exception
Browse files Browse the repository at this point in the history
fix: Update PaGetPaymentRes [PAGOPA-1384]
  • Loading branch information
cap-ang authored Nov 30, 2023
2 parents 4bc6c92 + 0cc62b6 commit 4aeda8c
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 26 deletions.
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-gpd-payments
description: Microservice that exposes API for payment receipts retrieving and other operations
type: application
version: 0.49.0
appVersion: 0.12.0-1-fix
version: 0.54.0
appVersion: 0.12.0-6-PAGOPA-1384-fix-date-format-exception
dependencies:
- name: microservice-chart
version: 2.4.0
Expand Down
2 changes: 1 addition & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-gpd-payments
tag: "0.12.0-1-fix"
tag: "0.12.0-6-PAGOPA-1384-fix-date-format-exception"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-gpd-payments
tag: "0.12.0-1-fix"
tag: "0.12.0-6-PAGOPA-1384-fix-date-format-exception"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-gpd-payments
tag: "0.12.0-1-fix"
tag: "0.12.0-6-PAGOPA-1384-fix-date-format-exception"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "PagoPA API Payments",
"description": "Payments",
"termsOfService": "https://www.pagopa.gov.it/",
"version": "0.12.0-1-fix"
"version": "0.12.0-6-PAGOPA-1384-fix-date-format-exception"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>it.gov.pagopa</groupId>
<artifactId>payments</artifactId>
<version>0.12.0-1-fix</version>
<version>0.12.0-6-PAGOPA-1384-fix-date-format-exception</version>
<name>Payments</name>
<description>Payments</description>

Expand Down
34 changes: 20 additions & 14 deletions src/main/java/it/gov/pagopa/payments/service/PartnerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
Expand Down Expand Up @@ -369,13 +371,15 @@ private PaGetPaymentRes generatePaGetPaymentResponse(
responseData.setCreditorReferenceId(
request.getQrCode().getNoticeNumber().substring(1)); // set IUV from notice number request
responseData.setPaymentAmount(BigDecimal.valueOf(source.getAmount()));
responseData.setDueDate(
DatatypeFactory.newInstance().newXMLGregorianCalendar(source.getDueDate().toString()));
responseData.setRetentionDate(
source.getRetentionDate() != null
? DatatypeFactory.newInstance()
.newXMLGregorianCalendar(source.getRetentionDate().toString())
: null);

DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
XMLGregorianCalendar dueDateXMLGregorian = datatypeFactory.newXMLGregorianCalendar(CommonUtil.convertToGregorianCalendar(source.getDueDate()));
XMLGregorianCalendar retentionDateXMLGregorian = datatypeFactory.newXMLGregorianCalendar(CommonUtil.convertToGregorianCalendar(source.getRetentionDate()));
//dueDateXMLGregorian.setTimezone(DatatypeConstants.FIELD_UNDEFINED); TODO after update xsd to common:stISODateTime
retentionDateXMLGregorian.setTimezone(DatatypeConstants.FIELD_UNDEFINED);

responseData.setDueDate(dueDateXMLGregorian);
responseData.setRetentionDate(source.getRetentionDate() != null ? retentionDateXMLGregorian : null);
responseData.setLastPayment(false); // de-scoping
responseData.setDescription(source.getDescription());
responseData.setCompanyName(Optional.ofNullable(source.getCompanyName()).orElse("NA"));
Expand Down Expand Up @@ -435,13 +439,15 @@ private PaGetPaymentV2Response generatePaGetPaymentResponse(
responseData.setCreditorReferenceId(
request.getQrCode().getNoticeNumber().substring(1)); // set IUV from notice number request
responseData.setPaymentAmount(BigDecimal.valueOf(source.getAmount()));
responseData.setDueDate(
DatatypeFactory.newInstance().newXMLGregorianCalendar(source.getDueDate().toString()));
responseData.setRetentionDate(
source.getRetentionDate() != null
? DatatypeFactory.newInstance()
.newXMLGregorianCalendar(source.getRetentionDate().toString())
: null);

DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
XMLGregorianCalendar dueDateXMLGregorian = datatypeFactory.newXMLGregorianCalendar(CommonUtil.convertToGregorianCalendar(source.getDueDate()));
XMLGregorianCalendar retentionDateXMLGregorian = datatypeFactory.newXMLGregorianCalendar(CommonUtil.convertToGregorianCalendar(source.getRetentionDate()));
//dueDateXMLGregorian.setTimezone(DatatypeConstants.FIELD_UNDEFINED); TODO after update xsd to common:stISODateTime
retentionDateXMLGregorian.setTimezone(DatatypeConstants.FIELD_UNDEFINED);

responseData.setDueDate(dueDateXMLGregorian);
responseData.setRetentionDate(source.getRetentionDate() != null ? retentionDateXMLGregorian : null);
responseData.setLastPayment(false); // de-scoping
responseData.setDescription(source.getDescription());
responseData.setCompanyName(Optional.ofNullable(source.getCompanyName()).orElse("NA"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import java.security.InvalidKeyException;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;

Expand Down Expand Up @@ -306,7 +308,9 @@ void paGetPaymentTest()
// Test post condition
assertThat(responseBody.getData().getCreditorReferenceId()).isEqualTo("11111111112222222");
assertThat(responseBody.getData().getDescription()).isEqualTo("string");
assertThat(responseBody.getData().getDueDate())
XMLGregorianCalendar dueDate = responseBody.getData().getDueDate();
dueDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
assertThat(dueDate)
.isEqualTo(
DatatypeFactory.newInstance().newXMLGregorianCalendar("2122-02-24T17:03:59.408"));
assertThat(responseBody.getData().getRetentionDate())
Expand Down Expand Up @@ -354,7 +358,9 @@ void paGetPaymentIncompleteAddressTest()
assertThat(responseBody.getData().getCreditorReferenceId()).isEqualTo("11111111112222222");
assertThat(responseBody.getData().getDescription())
.isEqualTo("Canone Unico Patrimoniale - CORPORATE");
assertThat(responseBody.getData().getDueDate())
XMLGregorianCalendar dueDate = responseBody.getData().getDueDate();
dueDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
assertThat(dueDate)
.isEqualTo(
DatatypeFactory.newInstance().newXMLGregorianCalendar("2125-04-20T12:15:38.927"));
assertThat(responseBody.getData().getRetentionDate())
Expand Down Expand Up @@ -806,7 +812,9 @@ void paGetPaymentV2Test()
// Test post condition
assertThat(responseBody.getData().getCreditorReferenceId()).isEqualTo("11111111112222222");
assertThat(responseBody.getData().getDescription()).isEqualTo("string");
assertThat(responseBody.getData().getDueDate())
XMLGregorianCalendar dueDate = responseBody.getData().getDueDate();
dueDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
assertThat(dueDate)
.isEqualTo(
DatatypeFactory.newInstance().newXMLGregorianCalendar("2122-02-24T17:03:59.408"));
assertThat(responseBody.getData().getRetentionDate())
Expand Down Expand Up @@ -864,12 +872,14 @@ void paGetPaymentIncompleteAddressV2Test()

// Test execution
PaGetPaymentV2Response responseBody = pService.paGetPaymentV2(requestBody);

System.out.println(responseBody.getData().getDueDate());
// Test post condition
assertThat(responseBody.getData().getCreditorReferenceId()).isEqualTo("11111111112222222");
assertThat(responseBody.getData().getDescription())
.isEqualTo("Canone Unico Patrimoniale - CORPORATE");
assertThat(responseBody.getData().getDueDate())
XMLGregorianCalendar dueDate = responseBody.getData().getDueDate();
dueDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
assertThat(dueDate)
.isEqualTo(
DatatypeFactory.newInstance().newXMLGregorianCalendar("2125-04-20T12:15:38.927"));
assertThat(responseBody.getData().getRetentionDate())
Expand Down

0 comments on commit 4aeda8c

Please sign in to comment.