@@ -44,7 +44,7 @@ private void writeReport(String reportName) throws InterruptedException, IOExcep
4444
4545 long ms = System .currentTimeMillis ();
4646
47- try (Writer writer = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (TARGET_AUTOMOTION + reportName + ms + ".html" ), StandardCharsets .UTF_8 ))) {
47+ try (Writer writer = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (TARGET_AUTOMOTION + reportName . replace ( " " , "" ) + ms + ".html" ), StandardCharsets .UTF_8 ))) {
4848 writer .write (html .toHtmlString ());
4949 } catch (IOException ex ) {
5050 LOG .error ("Cannot create html report: " + ex .getMessage ());
@@ -82,44 +82,46 @@ private Html buildHtml() throws IOException, ParseException {
8282 File folder = new File (TARGET_AUTOMOTION_JSON );
8383 File [] listOfFiles = folder .listFiles ();
8484
85- for (File file : listOfFiles ) {
86- if (file .isFile ()) {
87- JSONParser parser = new JSONParser ();
88- Object obj = parser .parse (new FileReader (file ));
89-
90- JSONObject jsonObject = (JSONObject ) obj ;
91- JSONArray details = (JSONArray ) jsonObject .get (DETAILS );
92- new H1 (this ,
93- new Style ("color: rgb(0,139,139); margin-top: 50px;" )) {{
94- new NoTag (this , "Element: \" " + jsonObject .get (ELEMENT_NAME ) + "\" " );
95- }};
96- new H2 (this ,
97- new Style ("color: rgb(255,69,0)" )) {{
98- new NoTag (this , "Failures:" );
99- }};
100- new Ol (this ) {{
101- for (Object details : details ) {
102- JSONObject det = (JSONObject ) details ;
103- JSONObject reason = (JSONObject ) det .get (REASON );
104- String numE = (String ) reason .get (MESSAGE );
105-
106- new Li (this ) {{
107- new NoTag (this , numE .toString ());
108- }};
109- }
110- }};
111- new H4 (this ,
112- new Style ("color: rgb(105,105,105)" )) {{
113- new NoTag (this , "Time execution: " + jsonObject .get (TIME_EXECUTION ));
114- }};
115- new P (this ) {{
116- new Img (this ,
117- new Src ("img/" + jsonObject .get (SCREENSHOT )),
118- new Alt ("screenshot" ),
119- new Style ("width: 96%; margin-left:2%" ));
120- }};
121-
122- while (!file .delete ());
85+ if (listOfFiles != null ) {
86+ for (File file : listOfFiles ) {
87+ if (file .isFile ()) {
88+ JSONParser parser = new JSONParser ();
89+ Object obj = parser .parse (new FileReader (file ));
90+
91+ JSONObject jsonObject = (JSONObject ) obj ;
92+ JSONArray details = (JSONArray ) jsonObject .get (DETAILS );
93+ new H1 (this ,
94+ new Style ("color: rgb(0,139,139); margin-top: 50px;" )) {{
95+ new NoTag (this , "Element: \" " + jsonObject .get (ELEMENT_NAME ) + "\" " );
96+ }};
97+ new H2 (this ,
98+ new Style ("color: rgb(255,69,0)" )) {{
99+ new NoTag (this , "Failures:" );
100+ }};
101+ new Ol (this ) {{
102+ for (Object details : details ) {
103+ JSONObject det = (JSONObject ) details ;
104+ JSONObject reason = (JSONObject ) det .get (REASON );
105+ String numE = (String ) reason .get (MESSAGE );
106+
107+ new Li (this ) {{
108+ new NoTag (this , numE .toString ());
109+ }};
110+ }
111+ }};
112+ new H4 (this ,
113+ new Style ("color: rgb(105,105,105)" )) {{
114+ new NoTag (this , "Time execution: " + jsonObject .get (TIME_EXECUTION ));
115+ }};
116+ new P (this ) {{
117+ new Img (this ,
118+ new Src ("img/" + jsonObject .get (SCREENSHOT )),
119+ new Alt ("screenshot" ),
120+ new Style ("width: 96%; margin-left:2%" ));
121+ }};
122+
123+ while (!file .delete ()) ;
124+ }
123125 }
124126 }
125127 }};
0 commit comments