88import com .webfirmframework .wffweb .tag .html .lists .Li ;
99import com .webfirmframework .wffweb .tag .html .lists .Ol ;
1010import com .webfirmframework .wffweb .tag .html .metainfo .Head ;
11+ import com .webfirmframework .wffweb .tag .html .stylesandsemantics .Div ;
1112import com .webfirmframework .wffweb .tag .htmlwff .NoTag ;
1213import org .apache .log4j .Logger ;
1314import org .json .simple .JSONArray ;
1718
1819import java .io .*;
1920import java .nio .charset .StandardCharsets ;
21+ import java .text .SimpleDateFormat ;
22+ import java .util .Date ;
23+
24+ import static util .validator .Constants .*;
25+
2026
21- /**
22- * Created by ZayCo on 25/11/16.
23- */
2427public class HtmlReportBuilder {
2528
26- private static final String TARGET_AUTOMOTION_JSON = "target/automotion/json/" ;
27- private static final String TARGET_AUTOMOTION = "target/automotion/" ;
2829 private final Logger LOG = Logger .getLogger (HtmlReportBuilder .class );
2930
3031 public void buildReport () throws IOException , ParseException , InterruptedException {
3132 Thread .sleep (3000 );
32- Html html = new Html (null ) {{
33+ Html html = new Html (null , new Style ( "background-color: rgb(255,250,250)" ) ) {{
3334 new Head (this ) {{
3435 new TitleTag (this ) {{
3536 new NoTag (this , "Automotion report" );
3637 }};
3738 }};
3839 new Body (this ) {{
3940
40-
41+ new Div (this , new Style ("width: 100%; background-color: rgb(0,191,255); color: white; padding: 10px" )) {{
42+ new H1 (this ) {{
43+ new NoTag (this , "Results from: " + new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss" ).format (new Date ()));
44+ }};
45+ }};
4146 File folder = new File (TARGET_AUTOMOTION_JSON );
4247 File [] listOfFiles = folder .listFiles ();
4348
@@ -47,20 +52,20 @@ public void buildReport() throws IOException, ParseException, InterruptedExcepti
4752 Object obj = parser .parse (new FileReader (file ));
4853
4954 JSONObject jsonObject = (JSONObject ) obj ;
50- JSONArray details = (JSONArray ) jsonObject .get ("details" );
55+ JSONArray details = (JSONArray ) jsonObject .get (DETAILS );
5156 new H1 (this ,
52- new Style ("color: black " )) {{
53- new NoTag (this , "Element: " + jsonObject .get ("elementName" ) );
57+ new Style ("color: rgb(0,139,139); margin-top: 50px; " )) {{
58+ new NoTag (this , "Element: \" " + jsonObject .get (ELEMENT_NAME ) + " \" " );
5459 }};
5560 new H2 (this ,
56- new Style ("color: red " )) {{
61+ new Style ("color: rgb(255,69,0) " )) {{
5762 new NoTag (this , "Failures:" );
5863 }};
5964 new Ol (this ) {{
6065 for (Object details : details ) {
6166 JSONObject det = (JSONObject ) details ;
62- JSONObject reason = (JSONObject ) det .get ("reason" );
63- String numE = (String ) reason .get ("message" );
67+ JSONObject reason = (JSONObject ) det .get (REASON );
68+ String numE = (String ) reason .get (MESSAGE );
6469
6570 new Li (this ) {{
6671 new NoTag (this , numE .toString ());
@@ -69,9 +74,9 @@ public void buildReport() throws IOException, ParseException, InterruptedExcepti
6974 }};
7075 new P (this ) {{
7176 new Img (this ,
72- new Src ("img/" + jsonObject .get ("screenshot" )),
77+ new Src ("img/" + jsonObject .get (SCREENSHOT )),
7378 new Alt ("screenshot" ),
74- new Style ("width: 100 %" ));
79+ new Style ("width: 90%; margin-left:5 %" ));
7580 }};
7681 }
7782 }
0 commit comments