// Path: src/test/java/com/qoomon/banking/TestUtils.java
// public class TestUtils {
// 
//     public static <T> List<T> collectUntilNull(Callable<T> function) throws Exception {
//         List<T> resultList = new LinkedList<>();
//         T result;
//         while ((result = function.call()) != null) {
//             resultList.add(result);
//         }
//         return resultList;
//     }
// }
// 
// Path: src/main/java/com/qoomon/banking/swift/message/exception/SwiftMessageParseException.java
// public class SwiftMessageParseException extends Exception {
// 
//     private final int lineNumber;
// 
//     public SwiftMessageParseException(String message, int lineNumber) {
//         super(message + " at line number " + lineNumber);
//         this.lineNumber = lineNumber;
//     }
// 
//     public SwiftMessageParseException(String message, int lineNumber, Throwable cause) {
//         super(message + " at line number " + lineNumber, cause);
//         this.lineNumber = lineNumber;
//     }
// 
//     public SwiftMessageParseException(int lineNumber, Throwable cause) {
//         super("at line number " + lineNumber, cause);
//         this.lineNumber = lineNumber;
//     }
// 
//     public SwiftMessageParseException(BlockParseException e) {
//         super(e);
//         lineNumber = 0;
//     }
// 
//     public int getLineNumber() {
//         return lineNumber;
//     }
// }


import com.google.common.base.Throwables;
import com.google.common.io.Resources;
import com.qoomon.banking.TestUtils;
import com.qoomon.banking.swift.message.exception.SwiftMessageParseException;
import org.assertj.core.api.SoftAssertions;
import org.junit.Test;
import java.io.FileReader;
import java.io.StringReader;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.*;

        // When
        String content = classUnderTest.getContent();

        // Then
        assertThat(content).isEqualTo(contentInput);
    }

    @Test
    public void parse_WHEN_funds_code_does_not_match_statement_currency_THROW_exception() throws Exception {

        // Given
        String mt940MessageText = ":20:02618\n" +
                ":21:123456/DEV\n" +
                ":25:6-9412771\n" +
                ":28C:00102\n" +
                ":60F:C000103USD672,\n" + // currency USD
                ":61:0312091211DX880,FTRFBPHP/081203/0003//59512112915002\n" + // wrong funds code X expect usD
                ":62F:C000103USD987,\n" +
                "-";

        MT940PageReader classUnderTest = new MT940PageReader(new StringReader(mt940MessageText));

        // When
        Throwable exception = catchThrowable(classUnderTest::read);

        // Then
        assertThat(exception).isInstanceOf(SwiftMessageParseException.class).hasRootCauseInstanceOf(IllegalArgumentException.class);
    }

// Path: src/test/java/com/qoomon/banking/TestUtils.java
// public class TestUtils {
// 
//     public static <T> List<T> collectUntilNull(Callable<T> function) throws Exception {
//         List<T> resultList = new LinkedList<>();
//         T result;
//         while ((result = function.call()) != null) {
//             resultList.add(result);
//         }
//         return resultList;
//     }
// }
// 
// Path: src/main/java/com/qoomon/banking/swift/message/exception/SwiftMessageParseException.java
// public class SwiftMessageParseException extends Exception {
// 
//     private final int lineNumber;
// 
//     public SwiftMessageParseException(String message, int lineNumber) {
//         super(message + " at line number " + lineNumber);
//         this.lineNumber = lineNumber;
//     }
// 
//     public SwiftMessageParseException(String message, int lineNumber, Throwable cause) {
//         super(message + " at line number " + lineNumber, cause);
//         this.lineNumber = lineNumber;
//     }
// 
//     public SwiftMessageParseException(int lineNumber, Throwable cause) {
//         super("at line number " + lineNumber, cause);
//         this.lineNumber = lineNumber;
//     }
// 
//     public SwiftMessageParseException(BlockParseException e) {
//         super(e);
//         lineNumber = 0;
//     }
// 
//     public int getLineNumber() {
//         return lineNumber;
//     }
// }


// Path: src/test/java/com/qoomon/banking/swift/submessage/mt940/MT940PageReaderTest.java
import com.google.common.base.Throwables;
import com.google.common.io.Resources;
import com.qoomon.banking.TestUtils;
import com.qoomon.banking.swift.message.exception.SwiftMessageParseException;
import org.assertj.core.api.SoftAssertions;
import org.junit.Test;
import java.io.FileReader;
import java.io.StringReader;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Stream;
import static org.assertj.core.api.Assertions.*;


        // When
        String content = classUnderTest.getContent();

        // Then
        assertThat(content).isEqualTo(contentInput);
    }

    @Test
    public void parse_WHEN_funds_code_does_not_match_statement_currency_THROW_exception() throws Exception {

        // Given
        String mt940MessageText = ":20:02618\n" +
                ":21:123456/DEV\n" +
                ":25:6-9412771\n" +
                ":28C:00102\n" +
                ":60F:C000103USD672,\n" + // currency USD
                ":61:0312091211DX880,FTRFBPHP/081203/0003//59512112915002\n" + // wrong funds code X expect usD
                ":62F:C000103USD987,\n" +
                "-";

        MT940PageReader classUnderTest = new MT940PageReader(new StringReader(mt940MessageText));

        // When
        Throwable exception = catchThrowable(classUnderTest::read);

        // Then
        assertThat(exception).isInstanceOf(SwiftMessageParseException.class).hasRootCauseInstanceOf(IllegalArgumentException.class);
    }

    @Test