Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub action test environment run fixes #146

Merged
merged 3 commits into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
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;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
Expand All @@ -37,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(
"<pacs:CreDtTm>2021-10-19T12:13:14" + OffsetDateTime.now().getOffset() + "</pacs:CreDtTm>"));
assertTrue(xml.contains("<pacs:CreDtTm>2021-10-19T12:13:14+00:00</pacs:CreDtTm>"));
assertTrue(xml.contains("<pacs:IntrBkSttlmDt>2021-10-19</pacs:IntrBkSttlmDt>"));
assertTrue(xml.contains("<pacs:CLSTm>12:13:14" + OffsetDateTime.now().getOffset() + "</pacs:CLSTm>"));
assertTrue(xml.contains("<pacs:CLSTm>12:13:14+00:00</pacs:CLSTm>"));

final MxPacs00800102 mx2 = MxPacs00800102.parse(xml);
// System.out.println(mx2.message());
Expand Down Expand Up @@ -88,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();
Expand Down Expand Up @@ -139,18 +135,15 @@ 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));
XMLGregorianCalendar fractionalSecond = sampleGregorianCalendar();
fractionalSecond.setFractionalSecond(new BigDecimal("0.123"));
MxPacs00800102 mx1 = sample(fractionalSecond);

final String xml = mx1.message();
// System.out.println(xml);
assertTrue(xml.contains(
"<pacs:CreDtTm>2021-10-19T12:13:14.123" + OffsetDateTime.now().getOffset() + "</pacs:CreDtTm>"));
assertTrue(xml.contains("<pacs:CreDtTm>2021-10-19T12:13:14.123+00:00</pacs:CreDtTm>"));
assertTrue(xml.contains("<pacs:IntrBkSttlmDt>2021-10-19</pacs:IntrBkSttlmDt>"));
assertTrue(
xml.contains("<pacs:CLSTm>12:13:14.123" + OffsetDateTime.now().getOffset() + "</pacs:CLSTm>"));
assertTrue(xml.contains("<pacs:CLSTm>12:13:14.123+00:00</pacs:CLSTm>"));

final MxPacs00800102 mx2 = MxPacs00800102.parse(xml);
// System.out.println(mx2.message());
Expand Down Expand Up @@ -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);
zubri marked this conversation as resolved.
Show resolved Hide resolved
MxPacs00800102 mx1 = sample(noFractionalSecond);

MxWriteConfiguration conf = new MxWriteConfiguration();
Expand Down Expand Up @@ -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();
Expand All @@ -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("<CreDt>2021-10-19T12:13:14" + OffsetDateTime.now().getOffset() + "</CreDt>"));
assertTrue(xml.contains("<CreDt>2021-10-19T12:13:14+00:00</CreDt>"));

final BusinessAppHdrV02 h2 = (BusinessAppHdrV02) AppHdrParser.parse(xml).get();
// System.out.println(mx2.message());
Expand All @@ -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);
}
zubri marked this conversation as resolved.
Show resolved Hide resolved
}
Loading