01: // Modified or written by Object Mentor, Inc. for inclusion with FitNesse.
02: // Copyright (c) 2002 Cunningham & Cunningham, Inc.
03: // Released under the terms of the GNU General Public License version 2 or later.
04: package fit;
05:
06: // Copyright (c) 2002 Cunningham & Cunningham, Inc.
07: // Released under the terms of the GNU General Public License version 2 or later.
08:
09: import java.util.*;
10:
11: public class SummaryFixture extends Fixture {
12: public static String countsKey = "counts";
13:
14: public void doTable(Parse table) {
15: summary.put(countsKey, counts());
16: SortedSet keys = new TreeSet(summary.keySet());
17: table.parts.more = rows(keys.iterator());
18: }
19:
20: protected Parse rows(Iterator keys) {
21: if (keys.hasNext()) {
22: Object key = keys.next();
23: Parse result = tr(td(key.toString(), td(summary.get(key)
24: .toString(), null)), rows(keys));
25: if (key.equals(countsKey)) {
26: mark(result);
27: }
28: return result;
29: } else {
30: return null;
31: }
32: }
33:
34: protected Parse tr(Parse parts, Parse more) {
35: return new Parse("tr", null, parts, more);
36: }
37:
38: protected Parse td(String body, Parse more) {
39: return new Parse("td", gray(body), null, more);
40: }
41:
42: protected void mark(Parse row) {
43: // mark summary good/bad without counting beyond here
44: Counts official = counts;
45: counts = new Counts();
46: Parse cell = row.parts.more;
47: if (official.wrong + official.exceptions > 0) {
48: wrong(cell);
49: } else {
50: right(cell);
51: }
52: counts = official;
53: }
54:
55: }
|