|
7 | 7 | import java.io.File; |
8 | 8 | import java.io.IOException; |
9 | 9 | import java.nio.file.Files; |
10 | | -import java.nio.file.Path; |
11 | 10 | import java.nio.file.Paths; |
12 | 11 |
|
13 | 12 | public class TvdFormatTest extends AbstractTvdFormatTest { |
14 | 13 |
|
15 | 14 | @Test |
16 | 15 | public void jsonArrayDirTest() throws ScriptException, IOException { |
17 | | - final String configFileContent = "[\"" + tempDir.toString() + "\"]"; |
18 | | - final Path configFile = Paths.get(tempDir + File.separator + "config.json"); |
| 16 | + var configFileContent = """ |
| 17 | + [ |
| 18 | + "#TEMP_DIR#" |
| 19 | + ] |
| 20 | + """.replace("#TEMP_DIR#", tempDir.toString()); |
| 21 | + var configFile = Paths.get(tempDir + File.separator + "config.json"); |
19 | 22 | Files.write(configFile, configFileContent.getBytes()); |
20 | | - String[] args = new String[]{tempDir + File.separator + "config.json", |
| 23 | + var args = new String[]{tempDir + File.separator + "config.json", |
21 | 24 | "xml=" + tempDir + File.separator + "trivadis_advanced_format.xml", |
22 | 25 | "arbori=" + tempDir + File.separator + "trivadis_custom_format.arbori"}; |
23 | 26 | TvdFormat.main(args); |
24 | | - String expected = getExpectedContent("query.sql"); |
25 | | - String actual = getFormattedContent("query.sql"); |
| 27 | + var expected = getExpectedContent("query.sql"); |
| 28 | + var actual = getFormattedContent("query.sql"); |
26 | 29 | Assertions.assertEquals(expected, actual); |
27 | 30 | } |
28 | 31 |
|
29 | 32 | @Test |
30 | 33 | public void jsonArrayFileTest() throws ScriptException, IOException { |
31 | | - final String configFileContent = "[\"" + tempDir.toString() + File.separator + "query.sql\"]"; |
32 | | - final Path configFile = Paths.get(tempDir + File.separator + "config.json"); |
| 34 | + var configFileContent = """ |
| 35 | + [ |
| 36 | + "#TEMP_DIR##FILE_SEP#query.sql" |
| 37 | + ] |
| 38 | + """.replace("#TEMP_DIR#", tempDir.toString()).replace("#FILE_SEP#", File.separator); |
| 39 | + var configFile = Paths.get(tempDir + File.separator + "config.json"); |
33 | 40 | Files.write(configFile, configFileContent.getBytes()); |
34 | | - String[] args = new String[]{tempDir + File.separator + "config.json", |
| 41 | + var args = new String[]{tempDir + File.separator + "config.json", |
35 | 42 | "xml=" + tempDir + File.separator + "trivadis_advanced_format.xml", |
36 | 43 | "arbori=" + tempDir + File.separator + "trivadis_custom_format.arbori"}; |
37 | 44 | TvdFormat.main(args); |
38 | | - String expected = getExpectedContent("query.sql"); |
39 | | - String actual = getFormattedContent("query.sql"); |
| 45 | + var expected = getExpectedContent("query.sql"); |
| 46 | + var actual = getFormattedContent("query.sql"); |
40 | 47 | Assertions.assertEquals(expected, actual); |
41 | 48 | } |
42 | 49 |
|
43 | 50 | @Test |
44 | 51 | public void jsonObjectFileTest() throws ScriptException, IOException { |
45 | | - final String configFileContent = "{\n" |
46 | | - + " \"xml\": \"" + tempDir + File.separator + "trivadis_advanced_format.xml\",\n" |
47 | | - + " \"arbori\": \"" + tempDir + File.separator + "trivadis_custom_format.arbori\",\n" |
48 | | - + " \"files\": [\"" + tempDir.toString() + File.separator + "query.sql\"]\n" |
49 | | - + "}"; |
50 | | - final Path configFile = Paths.get(tempDir + File.separator + "config.json"); |
| 52 | + var configFileContent = """ |
| 53 | + { |
| 54 | + "xml": "#TEMP_DIR##FILE_SEP#trivadis_advanced_format.xml", |
| 55 | + "arbori": "#TEMP_DIR##FILE_SEP#trivadis_custom_format.arbori", |
| 56 | + "files": [ |
| 57 | + "#TEMP_DIR##FILE_SEP#query.sql" |
| 58 | + ] |
| 59 | + } |
| 60 | + """.replace("#TEMP_DIR#", tempDir.toString()).replace("#FILE_SEP#", File.separator); |
| 61 | + var configFile = Paths.get(tempDir + File.separator + "config.json"); |
51 | 62 | Files.write(configFile, configFileContent.getBytes()); |
52 | | - String[] args = new String[]{tempDir + File.separator + "config.json"}; |
| 63 | + var args = new String[]{tempDir + File.separator + "config.json"}; |
53 | 64 | TvdFormat.main(args); |
54 | | - String expected = getExpectedContent("query.sql"); |
55 | | - String actual = getFormattedContent("query.sql"); |
| 65 | + var expected = getExpectedContent("query.sql"); |
| 66 | + var actual = getFormattedContent("query.sql"); |
56 | 67 | Assertions.assertEquals(expected, actual); |
57 | 68 | } |
58 | 69 | } |
0 commit comments