11package com .mxgraph .svg2xml ;
22
3+ import static com .mxgraph .FileTooling .destinationFolder ;
4+ import static com .mxgraph .FileTooling .svgSourceFiles ;
35import static com .mxgraph .utils .FileUtils .EOL ;
46import static com .mxgraph .utils .FileUtils .fileContent ;
57import static org .assertj .core .api .Assertions .assertThat ;
1012
1113class Svg2XmlTest {
1214
15+ private static Svg2Xml newSvg2Xml () {
16+ return new Svg2Xml ().infoLog (false );
17+ }
18+
1319 @ Test
1420 void convertToXml_single_file () {
15- Svg2Xml svg2Xml = new Svg2Xml ();
21+ Svg2Xml svg2Xml = newSvg2Xml ();
1622
1723 File destPath = destinationFolder ("Simple-Single file" );
1824 svg2Xml .convertToXml (svgSourceFiles ("simple-01/circle-green.svg" ), destPath );
@@ -29,7 +35,7 @@ void convertToXml_single_file() {
2935
3036 @ Test
3137 void convertToXml_two_files_from_the_same_folder () {
32- Svg2Xml svg2Xml = new Svg2Xml ();
38+ Svg2Xml svg2Xml = newSvg2Xml ();
3339
3440 File destPath = destinationFolder ("Simple-Two files" );
3541 svg2Xml .convertToXml (svgSourceFiles ("simple-01/circle-green.svg" , "simple-01/rectangle-blue.svg" ), destPath );
@@ -48,7 +54,7 @@ void convertToXml_two_files_from_the_same_folder() {
4854
4955 @ Test
5056 void convertToXml_files_from_two_folders_without_subfolders_files_given_ordered_by_folders () {
51- Svg2Xml svg2Xml = new Svg2Xml ();
57+ Svg2Xml svg2Xml = newSvg2Xml ();
5258
5359 File destPath = destinationFolder ("files from 2 folders - no subfolders" );
5460 // in the current implementation, the files are supposed to be passed ordered by folder
@@ -72,26 +78,4 @@ void convertToXml_files_from_two_folders_without_subfolders_files_given_ordered_
7278 );
7379 }
7480
75- // =================================================================================================================
76- // UTILS
77- // =================================================================================================================
78-
79- private static void assertFirstLine (String fileContent , String expectedStart , String expectedEnd ) {
80- String firstLine = fileContent .substring (0 , fileContent .indexOf (EOL ));
81- assertThat (firstLine ).describedAs ("1st line of the generated file" )
82- .startsWith (expectedStart )
83- .endsWith (expectedEnd );
84- }
85-
86- private static File [] svgSourceFiles (String ... fileNames ) {
87- File parent = new File (System .getProperty ("user.dir" ), "src/test/resources/svg" ); // ensure we pass absolute path
88- return Arrays .stream (fileNames )
89- .map (fileName -> new File (parent , fileName ))
90- .toArray (File []::new );
91- }
92-
93- private static File destinationFolder (String folderName ) {
94- return new File ("target/test/output/" , folderName );
95- }
96-
9781}
0 commit comments