|
50 | 50 |
|
51 | 51 | import static org.junit.jupiter.api.Assertions.assertEquals; |
52 | 52 |
|
| 53 | +import org.junit.jupiter.api.Assertions; |
53 | 54 | import org.junit.jupiter.params.ParameterizedTest; |
54 | 55 | import org.junit.jupiter.params.provider.ValueSource; |
55 | 56 | import org.w3c.dom.NodeList; |
56 | 57 |
|
57 | | -public class TableSyntaxTests { |
| 58 | +public final class TableSyntaxTests { |
58 | 59 | @ParameterizedTest(name = "{index} command=''{0}''") |
59 | 60 | @ValueSource(strings = { |
60 | 61 | "table", |
| 62 | + "tableWithComma", |
| 63 | + "tableWildcard" |
61 | 64 | }) |
62 | | - public void tableSyntaxParseTest(String arg) throws Exception { |
63 | | - String fileName = "src/test/resources/antlr4/commands/table/" + arg + ".txt"; |
64 | | - ParserSyntaxTestingUtility parserSyntaxTestingUtility |
| 65 | + void tableSyntaxParseTest(String arg) throws Exception { |
| 66 | + final String fileName = "src/test/resources/antlr4/commands/table/" + arg + ".txt"; |
| 67 | + final ParserSyntaxTestingUtility parserSyntaxTestingUtility |
65 | 68 | = new ParserSyntaxTestingUtility(fileName, false); |
66 | 69 | parserSyntaxTestingUtility.syntaxParseTest(arg); |
67 | 70 | } |
68 | 71 | @ParameterizedTest |
69 | 72 | @ValueSource(strings = { |
70 | 73 | "table", |
| 74 | + "tableWithComma", |
| 75 | + "tableWildcard" |
71 | 76 | }) |
72 | | - void xpathTest1(String arg) throws Exception { |
| 77 | + void testTableTransformationExists(String arg) throws Exception { |
73 | 78 | ParserStructureTestingUtility pstu = new ParserStructureTestingUtility(); |
74 | | - String fileName = "src/test/resources/antlr4/commands/table/" + arg + ".txt"; |
75 | | - String xpathExp = "/root/transformStatement/tableTransformation"; |
| 79 | + final String fileName = "src/test/resources/antlr4/commands/table/" + arg + ".txt"; |
| 80 | + final String xpathExp = "/root/transformStatement/tableTransformation"; |
76 | 81 |
|
77 | | - NodeList nodesA = (NodeList) pstu.xpathQueryFile(fileName, xpathExp, false); |
| 82 | + final NodeList nodesA = (NodeList) pstu.xpathQueryFile(fileName, xpathExp, false); |
78 | 83 | // Check that 1 found |
79 | 84 | assertEquals(1,nodesA.getLength()); |
80 | 85 | } |
81 | 86 | @ParameterizedTest |
82 | 87 | @ValueSource(strings = { |
83 | 88 | "table", |
84 | 89 | }) |
85 | | - void xpathTest2(String arg) throws Exception { |
86 | | - ParserStructureTestingUtility pstu = new ParserStructureTestingUtility(); |
87 | | - String fileName = "src/test/resources/antlr4/commands/table/" + arg + ".txt"; |
88 | | - String xpathExp = "/root/transformStatement/tableTransformation/t_table_wcfieldListParameter/t_table_fieldType[1]/t_table_stringType/value"; |
| 90 | + void testTableWithSpaceDelim(String arg) throws Exception { |
| 91 | + final ParserStructureTestingUtility pstu = new ParserStructureTestingUtility(); |
| 92 | + final String fileName = "src/test/resources/antlr4/commands/table/" + arg + ".txt"; |
| 93 | + final String xpathExp = "/root/transformStatement/tableTransformation/t_table_wcfieldListParameter/t_table_fieldType"; |
89 | 94 |
|
90 | | - NodeList nodesA = (NodeList) pstu.xpathQueryFile(fileName, xpathExp, false); |
91 | | - // Check that 1 found |
92 | | - assertEquals(1,nodesA.getLength()); |
| 95 | + final NodeList nodesA = (NodeList) pstu.xpathQueryFile(fileName, xpathExp, false); |
| 96 | + // Check that 3 found |
| 97 | + Assertions.assertEquals(3,nodesA.getLength()); |
| 98 | + Assertions.assertEquals("fuu",nodesA.item(0).getTextContent()); |
| 99 | + Assertions.assertEquals("bli",nodesA.item(1).getTextContent()); |
| 100 | + Assertions.assertEquals("byr*",nodesA.item(2).getTextContent()); |
| 101 | + } |
| 102 | + |
| 103 | + @ParameterizedTest |
| 104 | + @ValueSource(strings = { |
| 105 | + "tableWithComma", |
| 106 | + }) |
| 107 | + void testTableWithCommaDelim(String arg) throws Exception { |
| 108 | + final ParserStructureTestingUtility pstu = new ParserStructureTestingUtility(); |
| 109 | + final String fileName = "src/test/resources/antlr4/commands/table/" + arg + ".txt"; |
| 110 | + final String xpathExp = "/root/transformStatement/tableTransformation/t_table_wcfieldListParameter/t_table_fieldType"; |
| 111 | + |
| 112 | + final NodeList nodesA = (NodeList) pstu.xpathQueryFile(fileName, xpathExp, false); |
| 113 | + // Check that 3 found |
| 114 | + Assertions.assertEquals(3,nodesA.getLength()); |
| 115 | + Assertions.assertEquals("fuu",nodesA.item(0).getTextContent()); |
| 116 | + Assertions.assertEquals("bli",nodesA.item(1).getTextContent()); |
| 117 | + Assertions.assertEquals("byr*",nodesA.item(2).getTextContent()); |
| 118 | + } |
| 119 | + |
| 120 | + @ParameterizedTest |
| 121 | + @ValueSource(strings = { |
| 122 | + "tableWildcard", |
| 123 | + }) |
| 124 | + void testTableWithWildcard(String arg) throws Exception { |
| 125 | + final ParserStructureTestingUtility pstu = new ParserStructureTestingUtility(); |
| 126 | + final String fileName = "src/test/resources/antlr4/commands/table/" + arg + ".txt"; |
| 127 | + final String xpathExp = "/root/transformStatement/tableTransformation/t_table_wcfieldListParameter/t_table_fieldType"; |
| 128 | + |
| 129 | + final NodeList nodesA = (NodeList) pstu.xpathQueryFile(fileName, xpathExp, false); |
| 130 | + // Check that 4 found |
| 131 | + Assertions.assertEquals(4,nodesA.getLength()); |
| 132 | + Assertions.assertEquals("*",nodesA.item(0).getTextContent()); |
| 133 | + Assertions.assertEquals("*foo",nodesA.item(1).getTextContent()); |
| 134 | + Assertions.assertEquals("foo*bar",nodesA.item(2).getTextContent()); |
| 135 | + Assertions.assertEquals("ba*",nodesA.item(3).getTextContent()); |
93 | 136 | } |
94 | 137 | } |
0 commit comments