@@ -22,16 +22,13 @@ public class ChainTestSimpleGenerator extends FileGenerator implements Generator
2222 private static final String GENERATOR_NAME = "simple" ;
2323 private static final String BASE_PROPERTY = "chaintest.generator.simple" ;
2424 private static final String PROP_ENABLED = BASE_PROPERTY + ".enabled" ;
25- private static final String PROP_OUT_FILE_NAME = BASE_PROPERTY + ".output-file" ;
2625 private static final String PROP_SAVE_OFFLINE = BASE_PROPERTY + ".offline" ;
2726 private static final String PROP_DATETIME_FORMAT = BASE_PROPERTY + ".datetime-format" ;
2827 private static final String PROP_DOCUMENT_TITLE = BASE_PROPERTY + ".document-title" ;
2928 private static final String PROP_DARK_THEME = BASE_PROPERTY + ".dark-theme" ;
3029 private static final String PROP_JS = BASE_PROPERTY + ".js" ;
3130 private static final String PROP_CSS = BASE_PROPERTY + ".css" ;
3231 private static final String BASE_TEMPLATE_NAME = "index.ftl" ;
33- private static final String DEFAULT_OUT_FILE_NAME = "Simple.html" ;
34- private static final String DEFAULT_OUT_DIR = "target/chaintest/" ;
3532 private static final String RESOURCES_DIR = "/resources" ;
3633 private static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss a" ;
3734 private static final List <String > OFFLINE_RESOURCE_LIST = List .of (
@@ -48,6 +45,7 @@ public class ChainTestSimpleGenerator extends FileGenerator implements Generator
4845 "esc" , "Reset all filters"
4946 );
5047
48+ private Map <String , String > _config ;
5149 private boolean _started ;
5250 private Build _build ;
5351 private String _projectName ;
@@ -59,6 +57,10 @@ public class ChainTestSimpleGenerator extends FileGenerator implements Generator
5957 private boolean _offline ;
6058 private boolean _darkTheme = false ;
6159
60+ public ChainTestSimpleGenerator () {
61+ super (GENERATOR_NAME );
62+ }
63+
6264 @ Override
6365 public void start (final Optional <Map <String , String >> config , final String testRunner , final Build build ) {
6466 if (config .isEmpty ()) {
@@ -67,33 +69,29 @@ public void start(final Optional<Map<String, String>> config, final String testR
6769 return ;
6870 }
6971
70- if (!Boolean .parseBoolean (config .get ().get (PROP_ENABLED ))) {
72+ _config = config .get ();
73+
74+ if (!Boolean .parseBoolean (_config .get (PROP_ENABLED ))) {
7175 log .debug ("{} generator was not enabled. To enable, set property {}=true in your configuration" , GENERATOR_NAME , PROP_ENABLED );
7276 return ;
7377 }
7478
75- String outputFileName = Optional .ofNullable (config .get ().get (PROP_OUT_FILE_NAME ))
76- .filter (name -> !name .isEmpty ())
77- .orElse (DEFAULT_OUT_DIR + DEFAULT_OUT_FILE_NAME );
78- if (!(outputFileName .endsWith ("htm" ) || outputFileName .endsWith ("html" ))) {
79- outputFileName += "/" + DEFAULT_OUT_FILE_NAME ;
80- }
81- _outFile = new File (outputFileName );
79+ _outFile = getOutFile (_config );
8280
83- _offline = Boolean .parseBoolean (config . get () .get (PROP_SAVE_OFFLINE ));
81+ _offline = Boolean .parseBoolean (_config .get (PROP_SAVE_OFFLINE ));
8482 if (_offline ) {
8583 saveResources ();
8684 }
8785
88- _projectName = Optional .ofNullable (config . get () .get (ChainTestPropertyKeys .PROJECT_NAME )).orElse ("" );
89- _datetimeFormat = Optional .ofNullable (config . get () .get (PROP_DATETIME_FORMAT ))
86+ _projectName = Optional .ofNullable (_config .get (ChainTestPropertyKeys .PROJECT_NAME )).orElse ("" );
87+ _datetimeFormat = Optional .ofNullable (_config .get (PROP_DATETIME_FORMAT ))
9088 .filter (DateTimeUtil ::isPatternValid )
9189 .orElse (DATETIME_FORMAT );
92- _documentTitle = Optional .ofNullable (config . get () .get (PROP_DOCUMENT_TITLE ))
90+ _documentTitle = Optional .ofNullable (_config .get (PROP_DOCUMENT_TITLE ))
9391 .orElse (ChainTestPropertyKeys .CHAINTEST );
94- _darkTheme = Boolean .parseBoolean (config . get () .get (PROP_DARK_THEME ));
95- _js = config . get () .get (PROP_JS );
96- _css = config . get () .get (PROP_CSS );
92+ _darkTheme = Boolean .parseBoolean (_config .get (PROP_DARK_THEME ));
93+ _js = _config .get (PROP_JS );
94+ _css = _config .get (PROP_CSS );
9795 _build = build ;
9896
9997 log .trace ("Start was called for testRunner: {}" , testRunner );
@@ -111,6 +109,7 @@ public boolean started() {
111109 }
112110
113111 private void saveResources () {
112+ _outFile = getOutFile (_config );
114113 final File parentDir = _outFile .getParentFile ();
115114 new File (parentDir .getPath () + RESOURCES_DIR ).mkdirs ();
116115
0 commit comments