From fa8ff26e296aa87079f06dc5bc969bff5b177f69 Mon Sep 17 00:00:00 2001 From: zubri Date: Tue, 7 Jan 2025 11:22:49 -0300 Subject: [PATCH 1/3] test fix attempt --- .../model/mx/adapters/MxWriteWithAdaptersTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java b/iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java index 18f6bc732..f9cd696d3 100644 --- a/iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java +++ b/iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java @@ -28,6 +28,7 @@ import java.time.OffsetDateTime; import java.util.Calendar; import java.util.GregorianCalendar; +import java.util.TimeZone; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; @@ -139,18 +140,17 @@ public void testDocumentDateTime_DefaultAdapters_Z() throws DatatypeConfiguratio @Test public void testDocumentDateTime_DefaultAdapters_fractionalSecond() throws DatatypeConfigurationException { - XMLGregorianCalendar fractionalSecond = DatatypeFactory.newInstance() - .newXMLGregorianCalendar(new GregorianCalendar(2021, Calendar.OCTOBER, 19, 12, 13, 14)); + GregorianCalendar calendar = new GregorianCalendar(2021, Calendar.OCTOBER, 19, 12, 13, 14); + calendar.setTimeZone(TimeZone.getTimeZone("UTC")); + XMLGregorianCalendar fractionalSecond = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); fractionalSecond.setFractionalSecond(new BigDecimal("0.123")); MxPacs00800102 mx1 = sample(fractionalSecond); final String xml = mx1.message(); // System.out.println(xml); - assertTrue(xml.contains( - "2021-10-19T12:13:14.123" + OffsetDateTime.now().getOffset() + "")); + assertTrue(xml.contains("2021-10-19T12:13:14.123+00:00")); assertTrue(xml.contains("2021-10-19")); - assertTrue( - xml.contains("12:13:14.123" + OffsetDateTime.now().getOffset() + "")); + assertTrue(xml.contains("12:13:14.123+00:00")); final MxPacs00800102 mx2 = MxPacs00800102.parse(xml); // System.out.println(mx2.message()); From b77e7b59a745b952bb6d6f56b7181a32e4b47333 Mon Sep 17 00:00:00 2001 From: zubri Date: Tue, 7 Jan 2025 11:50:54 -0300 Subject: [PATCH 2/3] test fix attempt --- .../mx/adapters/MxWriteWithAdaptersTest.java | 45 ++++++++----------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java b/iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java index f9cd696d3..2d8859c96 100644 --- a/iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java +++ b/iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java @@ -25,7 +25,6 @@ import com.prowidesoftware.swift.model.mx.dic.SettlementTimeRequest2; import java.math.BigDecimal; import java.text.SimpleDateFormat; -import java.time.OffsetDateTime; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; @@ -38,16 +37,14 @@ public class MxWriteWithAdaptersTest { @Test public void testDocumentDateTime_DefaultAdapters_noFractionalSecond() throws DatatypeConfigurationException { - XMLGregorianCalendar noFractionalSecond = DatatypeFactory.newInstance() - .newXMLGregorianCalendar(new GregorianCalendar(2021, Calendar.OCTOBER, 19, 12, 13, 14)); + XMLGregorianCalendar noFractionalSecond = sampleGregorianCalendar(); MxPacs00800102 mx1 = sample(noFractionalSecond); final String xml = mx1.message(); // System.out.println(xml); - assertTrue(xml.contains( - "2021-10-19T12:13:14" + OffsetDateTime.now().getOffset() + "")); + assertTrue(xml.contains("2021-10-19T12:13:14+00:00")); assertTrue(xml.contains("2021-10-19")); - assertTrue(xml.contains("12:13:14" + OffsetDateTime.now().getOffset() + "")); + assertTrue(xml.contains("12:13:14+00:00")); final MxPacs00800102 mx2 = MxPacs00800102.parse(xml); // System.out.println(mx2.message()); @@ -89,9 +86,7 @@ public void testDocumentDateTime_DefaultAdapters_noFractionalSecond() throws Dat @Test public void testDocumentDateTime_DefaultAdapters_Z() throws DatatypeConfigurationException { - XMLGregorianCalendar utc = DatatypeFactory.newInstance() - .newXMLGregorianCalendar(new GregorianCalendar(2021, Calendar.OCTOBER, 19, 12, 13, 14)); - utc.setTimezone(0); + XMLGregorianCalendar utc = sampleGregorianCalendar(); MxPacs00800102 mx1 = sample(utc); final String xml = mx1.message(); @@ -140,9 +135,7 @@ public void testDocumentDateTime_DefaultAdapters_Z() throws DatatypeConfiguratio @Test public void testDocumentDateTime_DefaultAdapters_fractionalSecond() throws DatatypeConfigurationException { - GregorianCalendar calendar = new GregorianCalendar(2021, Calendar.OCTOBER, 19, 12, 13, 14); - calendar.setTimeZone(TimeZone.getTimeZone("UTC")); - XMLGregorianCalendar fractionalSecond = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); + XMLGregorianCalendar fractionalSecond = sampleGregorianCalendar(); fractionalSecond.setFractionalSecond(new BigDecimal("0.123")); MxPacs00800102 mx1 = sample(fractionalSecond); @@ -192,8 +185,8 @@ public void testDocumentDateTime_DefaultAdapters_fractionalSecond() throws Datat @Test public void testDocumentDateTime_CustomPattern() throws DatatypeConfigurationException { - XMLGregorianCalendar noFractionalSecond = DatatypeFactory.newInstance() - .newXMLGregorianCalendar(new GregorianCalendar(2021, Calendar.OCTOBER, 19, 12, 13, 14)); + GregorianCalendar calendar = new GregorianCalendar(2021, Calendar.OCTOBER, 19, 12, 13, 14); + XMLGregorianCalendar noFractionalSecond = DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); MxPacs00800102 mx1 = sample(noFractionalSecond); MxWriteConfiguration conf = new MxWriteConfiguration(); @@ -202,7 +195,7 @@ public void testDocumentDateTime_CustomPattern() throws DatatypeConfigurationExc conf.adapters.dateAdapter = new IsoDateAdapter(new SimpleDateAdapter(new SimpleDateFormat("yy-MM-dd"))); final String xml = mx1.message(conf); - // System.out.println(xml); + System.out.println(xml); assertTrue(xml.contains("21-10-19 12:13")); assertTrue(xml.contains("21-10-19")); @@ -242,8 +235,7 @@ public void testDocumentDateTime_CustomPattern() throws DatatypeConfigurationExc @Test public void testDocumentDateTime_CustomAdapter() throws DatatypeConfigurationException { - XMLGregorianCalendar noFractionalSecond = DatatypeFactory.newInstance() - .newXMLGregorianCalendar(new GregorianCalendar(2021, Calendar.OCTOBER, 19, 12, 13, 14)); + XMLGregorianCalendar noFractionalSecond = sampleGregorianCalendar(); MxPacs00800102 mx1 = sample(noFractionalSecond); MxWriteConfiguration conf = new MxWriteConfiguration(); @@ -263,12 +255,14 @@ public void testDocumentDateTime_CustomAdapter() throws DatatypeConfigurationExc @Test public void testAppHdrDateTime_DefaultAdapters() throws DatatypeConfigurationException { - AppHdr h1 = header(); + XMLGregorianCalendar gregorianCalendar = sampleGregorianCalendar(); + BusinessAppHdrV02 h1 = + AppHdrFactory.createBusinessAppHdrV02("AAAAUSXXXXX", "BBBBUSXXXXX", "ref", new MxId("pacs.008.001.08")); + h1.setCreDt(gregorianCalendar); final String xml = h1.xml(); // System.out.println(xml); - assertTrue( - xml.contains("2021-10-19T12:13:14" + OffsetDateTime.now().getOffset() + "")); + assertTrue(xml.contains("2021-10-19T12:13:14+00:00")); final BusinessAppHdrV02 h2 = (BusinessAppHdrV02) AppHdrParser.parse(xml).get(); // System.out.println(mx2.message()); @@ -288,12 +282,9 @@ private MxPacs00800102 sample(final XMLGregorianCalendar cal) { return mx; } - private AppHdr header() throws DatatypeConfigurationException { - final XMLGregorianCalendar cal = DatatypeFactory.newInstance() - .newXMLGregorianCalendar(new GregorianCalendar(2021, Calendar.OCTOBER, 19, 12, 13, 14)); - BusinessAppHdrV02 bah = - AppHdrFactory.createBusinessAppHdrV02("AAAAUSXXXXX", "BBBBUSXXXXX", "ref", new MxId("pacs.008.001.08")); - bah.setCreDt(cal); - return bah; + private XMLGregorianCalendar sampleGregorianCalendar() throws DatatypeConfigurationException { + GregorianCalendar calendar = new GregorianCalendar(2021, Calendar.OCTOBER, 19, 12, 13, 14); + calendar.setTimeZone(TimeZone.getTimeZone("UTC")); + return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar); } } From cb08f80109d2dbdc91f8d6ecd825a0186d075e6b Mon Sep 17 00:00:00 2001 From: Sebastian Zubrinic Date: Tue, 7 Jan 2025 11:55:07 -0300 Subject: [PATCH 3/3] Update iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../swift/model/mx/adapters/MxWriteWithAdaptersTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java b/iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java index 2d8859c96..c71d5d494 100644 --- a/iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java +++ b/iso20022-core/src/test/java/com/prowidesoftware/swift/model/mx/adapters/MxWriteWithAdaptersTest.java @@ -195,7 +195,7 @@ public void testDocumentDateTime_CustomPattern() throws DatatypeConfigurationExc conf.adapters.dateAdapter = new IsoDateAdapter(new SimpleDateAdapter(new SimpleDateFormat("yy-MM-dd"))); final String xml = mx1.message(conf); - System.out.println(xml); + // System.out.println(xml); assertTrue(xml.contains("21-10-19 12:13")); assertTrue(xml.contains("21-10-19"));