// Path: versions/development/parsers/antlr4/Java/src/test/java/org/openwdl/wdl/parser/WdlParserTestErrorListener.java
// public static class SyntaxError {
// 
//     private final Object offendingSymbol;
//     private final int line;
//     private final int position;
//     private final String message;
// 
//     SyntaxError(Object offendingSymbol, int line, int position, String message) {
//         this.offendingSymbol = offendingSymbol;
//         this.line = line;
//         this.position = position;
//         this.message = message;
//     }
// 
//     public Object getOffendingSymbol() {
//         return offendingSymbol;
//     }
// 
//     public int getLine() {
//         return line;
//     }
// 
//     public int getPosition() {
//         return position;
//     }
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     public AssertionError getAssertionError() {
//         return new AssertionError(toString());
//     }
// 
//     @Override
//     public String toString() {
//         return "line " + line + ":" + position + " " + message;
//     }
// }


import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.tree.ParseTree;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.openwdl.wdl.parser.WdlParser.*;
import org.openwdl.wdl.parser.WdlParserTestErrorListener.SyntaxError;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
    }

    public static Stream<Arguments> failingWdlFiles() throws IOException {
        List<Arguments> testArguments = new ArrayList<>();
        File exampleDir = new File(examplesDirectory);

        for (File wdlFile : exampleDir.listFiles()) {
            if (wdlFile.getName().endsWith(".error")) {
                String name = wdlFile.getName();
                testArguments.add(Arguments.of(Files.readAllBytes(wdlFile.toPath()), name));
            }
        }
        return testArguments.stream();
    }

    @ParameterizedTest
    @MethodSource("failingWdlFiles")
    public void testWdlFiles_shouldFailParings(byte[] fileBytes, String fileName) {
        System.out.println("Testing WDL File: " + fileName + " should fail to parse");
        WdlParserTestErrorListener errorListener = new WdlParserTestErrorListener();
        CodePointBuffer codePointBuffer = CodePointBuffer.withBytes(ByteBuffer.wrap(fileBytes));
        CommentAggregatingTokenSource tokenSource = new CommentAggregatingTokenSource(CodePointCharStream
            .fromBuffer(codePointBuffer));
        WdlParser parser = new WdlParser(new CommonTokenStream(tokenSource));
        parser.removeErrorListeners();
        parser.addErrorListener(errorListener);
        parser.document();

        Assertions.assertTrue(errorListener.hasErrors());

// Path: versions/development/parsers/antlr4/Java/src/test/java/org/openwdl/wdl/parser/WdlParserTestErrorListener.java
// public static class SyntaxError {
// 
//     private final Object offendingSymbol;
//     private final int line;
//     private final int position;
//     private final String message;
// 
//     SyntaxError(Object offendingSymbol, int line, int position, String message) {
//         this.offendingSymbol = offendingSymbol;
//         this.line = line;
//         this.position = position;
//         this.message = message;
//     }
// 
//     public Object getOffendingSymbol() {
//         return offendingSymbol;
//     }
// 
//     public int getLine() {
//         return line;
//     }
// 
//     public int getPosition() {
//         return position;
//     }
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     public AssertionError getAssertionError() {
//         return new AssertionError(toString());
//     }
// 
//     @Override
//     public String toString() {
//         return "line " + line + ":" + position + " " + message;
//     }
// }


// Path: versions/development/parsers/antlr4/Java/src/test/java/org/openwdl/wdl/parser/WDLParserTest.java
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.tree.ParseTree;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.openwdl.wdl.parser.WdlParser.*;
import org.openwdl.wdl.parser.WdlParserTestErrorListener.SyntaxError;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;

    }

    public static Stream<Arguments> failingWdlFiles() throws IOException {
        List<Arguments> testArguments = new ArrayList<>();
        File exampleDir = new File(examplesDirectory);

        for (File wdlFile : exampleDir.listFiles()) {
            if (wdlFile.getName().endsWith(".error")) {
                String name = wdlFile.getName();
                testArguments.add(Arguments.of(Files.readAllBytes(wdlFile.toPath()), name));
            }
        }
        return testArguments.stream();
    }

    @ParameterizedTest
    @MethodSource("failingWdlFiles")
    public void testWdlFiles_shouldFailParings(byte[] fileBytes, String fileName) {
        System.out.println("Testing WDL File: " + fileName + " should fail to parse");
        WdlParserTestErrorListener errorListener = new WdlParserTestErrorListener();
        CodePointBuffer codePointBuffer = CodePointBuffer.withBytes(ByteBuffer.wrap(fileBytes));
        CommentAggregatingTokenSource tokenSource = new CommentAggregatingTokenSource(CodePointCharStream
            .fromBuffer(codePointBuffer));
        WdlParser parser = new WdlParser(new CommonTokenStream(tokenSource));
        parser.removeErrorListeners();
        parser.addErrorListener(errorListener);
        parser.document();

        Assertions.assertTrue(errorListener.hasErrors());

        List<SyntaxError> errors = errorListener.getErrors();