From 74e779350c3c2649118941f3223d1f2612e7a1fe Mon Sep 17 00:00:00 2001 From: zubri Date: Thu, 21 Sep 2023 11:32:19 -0300 Subject: [PATCH 1/2] release --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cddf70267..5808e1cd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Prowide Core - CHANGELOG -#### 9.4.6 - SNAPSHOT +#### 9.4.6 - September 2023 * Added support for an optional `pw-swift-core.properties` to customize the behavior of the SafeXmlUtils class #### 9.4.5 - August 2023 From e7e59186a23bad39cf682fd5184b69b31f348d32 Mon Sep 17 00:00:00 2001 From: Sebastian Zubrinic Date: Thu, 21 Sep 2023 19:09:48 -0300 Subject: [PATCH 2/2] PW-1478: fix field44J parse and getValue (#173) --- CHANGELOG.md | 3 + .../swift/model/field/Field44J.java | 12 ++- .../swift/model/field/Field44JTest.java | 79 +++++++++++++++++++ 3 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 src/test/java/com/prowidesoftware/swift/model/field/Field44JTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 5808e1cd2..1e238e740 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Prowide Core - CHANGELOG +#### 9.4.7 - September 2023 + * (PW-1478) Fixed Field 44J parse and getValue to enable proper data preservation when the field contains multiline content + #### 9.4.6 - September 2023 * Added support for an optional `pw-swift-core.properties` to customize the behavior of the SafeXmlUtils class diff --git a/src/generated/java/com/prowidesoftware/swift/model/field/Field44J.java b/src/generated/java/com/prowidesoftware/swift/model/field/Field44J.java index b1c6e3c22..124fc584a 100644 --- a/src/generated/java/com/prowidesoftware/swift/model/field/Field44J.java +++ b/src/generated/java/com/prowidesoftware/swift/model/field/Field44J.java @@ -193,9 +193,12 @@ public static Tag emptyTag() { @Override public void parse(final String value) { init(3); - setComponent1(SwiftParseUtils.getTokenFirst(value, null, "/")); - setComponent2(SwiftParseUtils.getTokenSecond(value, "/")); - setComponent3(SwiftParseUtils.getTokenThirdLast(value, "/")); + List lines = SwiftParseUtils.getLines(value); + if (!lines.isEmpty()) { + setComponent1(SwiftParseUtils.getTokenFirst(lines.get(0), "/", "/")); + setComponent2(SwiftParseUtils.getTokenSecondLast(lines.get(0), "/")); + SwiftParseUtils.setComponentsFromLines(this, 3, null, 1, lines); + } } /** @@ -209,7 +212,8 @@ public String getValue() { result.append("/").append(getComponent2()); } if (getComponent3() != null) { - result.append("/").append(getComponent3()); + result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); + result.append(getComponent3()); } return result.toString(); } diff --git a/src/test/java/com/prowidesoftware/swift/model/field/Field44JTest.java b/src/test/java/com/prowidesoftware/swift/model/field/Field44JTest.java new file mode 100644 index 000000000..ac5f057bd --- /dev/null +++ b/src/test/java/com/prowidesoftware/swift/model/field/Field44JTest.java @@ -0,0 +1,79 @@ +/* + * Copyright 2006-2023 Prowide + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.prowidesoftware.swift.model.field; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class Field44JTest extends AbstractFieldTest { + Field44J f = null; + + @BeforeEach + public void setup() { + f = null; + } + + @Override + @Test + public void testSerialization() { + testSerializationImpl("44J", "US/FOOBAR\r\n/HELLO WORLD"); + } + + @Test + public void testParse1() { + f = new Field44J("NL"); + assertEquals("NL", f.getComponent1()); + assertNull(f.getComponent2()); + assertNull(f.getComponent3()); + } + + @Test + public void testParse2() { + f = new Field44J("NL/foo bar"); + assertEquals("NL", f.getComponent1()); + assertEquals("foo bar", f.getComponent2()); + assertNull(f.getComponent3()); + } + + @Test + public void testParse3() { + f = new Field44J("NL/foo bar\n/Hello world"); + assertEquals("NL", f.getComponent1()); + assertEquals("foo bar", f.getComponent2()); + // parse preserves the slash on purpose to enable validation of its presence + assertEquals("/Hello world", f.getComponent3()); + } + + @Test + public void testGetValue() { + f = new Field44J("NL/foo bar\n/Hello world"); + assertEquals("NL/foo bar\r\n/Hello world", f.getValue()); + } + + @Test + public void testGetValue2() { + f = new Field44J("NL/foo bar"); + assertEquals("NL/foo bar", f.getValue()); + } + + @Test + public void testGetValue3() { + f = new Field44J("NL"); + assertEquals("NL", f.getValue()); + } +}