Skip to content

Commit

Permalink
Merge branch 'SRU2023' into SRU2023_v10
Browse files Browse the repository at this point in the history
  • Loading branch information
zubri authored Sep 22, 2023
2 parents ca77829 + e7e5918 commit c2dd8b7
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Prowide Core - CHANGELOG

#### 10.1.6 - September 2023
* (PW-1478) Fixed Field 44J parse and getValue to enable proper data preservation when the field contains multiline content

#### 10.1.5 - September 2023
* Added support for an optional `pw-swift-core.properties` to customize the behavior of the SafeXmlUtils class

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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);
}
}

/**
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}

0 comments on commit c2dd8b7

Please sign in to comment.