Author: shane.bryzak(a)jboss.com
Date: 2009-03-03 21:10:38 -0500 (Tue, 03 Mar 2009)
New Revision: 16066
Modified:
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
Log:
removed master summary, added highlighting and strikethrough
Modified:
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
===================================================================
---
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-03-03
23:07:49 UTC (rev 16065)
+++
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-03-04
02:10:38 UTC (rev 16066)
@@ -8,6 +8,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.hibernate.tck.config.RuntimeProperties;
import org.hibernate.tck.config.Strings;
@@ -26,6 +28,9 @@
public static final String FISHEYE_BASE_URL_PROPERTY = "fisheye_base_url";
public static final String SVN_BASE_URL_PROPERTY = "svn_base_url";
+
+ private static final Pattern PATTERN_BOLD =
Pattern.compile("([_][^_]*[_])");
+ private static final Pattern PATTERN_STRIKETHROUGH =
Pattern.compile("([~][^~]*[~])");
/*
* References to the spec assertions made by the tck tests
@@ -163,6 +168,8 @@
sb.append(" margin-bottom: 2px; }\n");
sb.append(" .coverageMethod {\n");
sb.append(" font-style: italic; }\n");
+ sb.append(" .highlight {\n");
+ sb.append(" background-color: #ffff00; }\n");
sb.append(" .implied {\n");
sb.append(" color: #fff;\n");
sb.append(" font-weight: bold;\n");
@@ -207,7 +214,6 @@
StringBuilder sb = new StringBuilder();
sb.append("<h3>Contents</h3>");
- sb.append("<div><a href=\"#masterSummary\">Master
Summary</a></div>");
sb.append("<div><a href=\"#chapterSummary\">Chapter
Summary</a></div>");
sb.append("<div><a href=\"#sectionSummary\">Section
Summary</a></div>");
sb.append("<div><a href=\"#coverageDetail\">Coverage
Detail</a></div>");
@@ -216,86 +222,6 @@
out.write(sb.toString().getBytes());
}
- private void writeMasterSummary(OutputStream out) throws IOException {
- StringBuilder sb = new StringBuilder();
-
- sb.append("<h3 id=\"masterSummary\">Master
Summary</h3>\n");
-
- sb.append("<table border=\"0\">");
-
- sb.append("<tr>");
- sb.append("<td>Total number of assertions</td>");
- sb.append("<td>");
-
- int assertionTotal = 0;
- int testableAssertionTotal = 0;
-
- for (List<AuditAssertion> assertions :
auditParser.getAssertions().values())
- {
- assertionTotal += assertions.size();
-
- for (AuditAssertion a : assertions)
- {
- if (a.isTestable()) testableAssertionTotal++;
- }
- }
-
- double untestablePercent = assertionTotal > 0 ? (((assertionTotal -
testableAssertionTotal) * 1.0) / assertionTotal) * 100 : 100;
-
- sb.append(assertionTotal);
- sb.append("</td>");
- sb.append("</tr>");
-
- sb.append("<tr>");
- sb.append("<td>Total number of untestable
assertions</td>");
- sb.append("<td>");
- sb.append(assertionTotal - testableAssertionTotal).append("
(").append(String.format("%.2f%%",
untestablePercent)).append(")");
- sb.append("</td>");
- sb.append("</tr>");
-
- int coverage = 0;
-
- for (String sectionId : auditParser.getSectionIds())
- {
- for (AuditAssertion assertion :
auditParser.getAssertionsForSection(sectionId))
- {
- if (!getCoverageForAssertion(sectionId, assertion.getId()).isEmpty())
- {
- coverage++;
- }
- }
- }
-
- double coveragePercent = testableAssertionTotal > 0 ? ((coverage * 1.0) /
testableAssertionTotal) * 100 : 100;
- String bgColor = coveragePercent < failThreshold ? "#ffaaaa" :
- coveragePercent < passThreshold ? "#ffffaa" :
"#aaffaa";
-
- sb.append("<tr style=\"background-color:" + bgColor + ";
border-color: " + bgColor + "\">");
-
- sb.append("<td style=\"background-color:" + bgColor + ";
border-color: " + bgColor + "\">Total number of tested
assertions</td>");
- sb.append("<td align=\"center\"
style=\"background-color:" + bgColor + "; border-color: " + bgColor +
"\">");
-
- sb.append(coverage).append(" (");
-
- sb.append(String.format("%.2f%%", coveragePercent));
- sb.append(")</td>");
-
- sb.append("</tr>");
-
- sb.append("<tr>");
- sb.append("<td>Total number of unmatched tests</td>");
-
- sb.append("<td>");
- sb.append(unmatched.size());
- sb.append("</td>");
-
- sb.append("</tr>");
-
- sb.append("</table>");
-
- out.write(sb.toString().getBytes());
- }
-
private void writeChapterSummary(OutputStream out) throws IOException {
StringBuilder sb = new StringBuilder();
@@ -657,13 +583,15 @@
sb.append(" <div class=\"results\">");
sb.append("<p class=\"description\">");
+
+ String assertionText =
parseStrikethrough(parseBold(assertion.getText()));
if (!Strings.isEmpty(assertion.getNote()))
{
- sb.append("<a title=\"" + assertion.getNote() +
"\">").append(assertion.getText()).append("</a>");
+ sb.append("<a title=\"" + assertion.getNote() +
"\">").append(assertionText).append("</a>");
}
else
{
- sb.append(assertion.getText());
+ sb.append(assertionText);
}
sb.append("</p>\n");
@@ -737,6 +665,34 @@
}
}
}
+
+ private String parseBold(String text)
+ {
+ Matcher m = PATTERN_BOLD.matcher(text);
+
+ String result = text;
+ while (m.find())
+ {
+ String replacement = "<span class=\"highlight\">" +
m.group().substring(1, m.group().length() - 1) + "</span>";
+ result = m.replaceFirst(replacement);
+ m.reset(result);
+ }
+ return result;
+ }
+
+ private String parseStrikethrough(String text)
+ {
+ Matcher m = PATTERN_STRIKETHROUGH.matcher(text);
+
+ String result = text;
+ while (m.find())
+ {
+ String replacement = "<del>" + m.group().substring(1,
m.group().length() - 1) + "</del>";
+ result = m.replaceFirst(replacement);
+ m.reset(result);
+ }
+ return result;
+ }
private void writeUnmatched(OutputStream out) throws IOException {
if (unmatched.isEmpty()) return;