Skip to content

Commit c4816a4

Browse files
committed
[responsive-validator] - improved HTML reporting. Added new validations
1 parent 3eeca4a commit c4816a4

File tree

5 files changed

+329
-341
lines changed

5 files changed

+329
-341
lines changed

src/main/java/util/general/HtmlReportBuilder.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.webfirmframework.wffweb.tag.html.lists.Li;
99
import com.webfirmframework.wffweb.tag.html.lists.Ol;
1010
import com.webfirmframework.wffweb.tag.html.metainfo.Head;
11+
import com.webfirmframework.wffweb.tag.html.stylesandsemantics.Div;
1112
import com.webfirmframework.wffweb.tag.htmlwff.NoTag;
1213
import org.apache.log4j.Logger;
1314
import org.json.simple.JSONArray;
@@ -17,27 +18,31 @@
1718

1819
import java.io.*;
1920
import 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-
*/
2427
public 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
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package util.validator;
2+
3+
public class Constants {
4+
public static final String X = "x";
5+
public static final String Y = "y";
6+
public static final String WIDTH = "width";
7+
public static final String HEIGHT = "height";
8+
public static final String ERROR_KEY = "error";
9+
public static final String MESSAGE = "message";
10+
public static final String DETAILS = "details";
11+
public static final Object REASON = "reason";
12+
public static final String ELEMENT = "element";
13+
public static final String SCREENSHOT = "screenshot";
14+
public static final String ELEMENT_NAME = "elementName";
15+
public static final String ROOT_ELEMENT = "rootElement";
16+
public static final String TARGET_AUTOMOTION_JSON = "target/automotion/json/";
17+
public static final String TARGET_AUTOMOTION_IMG = "target/automotion/img/";
18+
public static final String TARGET_AUTOMOTION = "target/automotion/";
19+
}

0 commit comments

Comments
 (0)