| 1 | /* |
| 2 | * JTiger Unit Testing Framework for J2SE 1.5 |
| 3 | * Copyright (C) 2005 Tony Morris |
| 4 | * |
| 5 | * This software is licenced under the |
| 6 | * Common Public Licence version 1.0 |
| 7 | * http://www.opensource.org/licenses/cpl1.0.php |
| 8 | * |
| 9 | * You received a copy of this licence with this software. |
| 10 | */ |
| 11 | package org.jtiger.report.html; |
| 12 | |
| 13 | import org.jtiger.framework.TestResultType; |
| 14 | import static org.jtiger.framework.TestResultType.SUCCESS; |
| 15 | import static org.jtiger.framework.TestResultType.FAILURE; |
| 16 | import static org.jtiger.framework.TestResultType.FAILURE_SETUP; |
| 17 | import static org.jtiger.framework.TestResultType.FAILURE_TEARDOWN; |
| 18 | import static org.jtiger.framework.TestResultType.IGNORED_ANNOTATED; |
| 19 | import static org.jtiger.framework.TestResultType.IGNORED_CANNOT_INVOKE; |
| 20 | |
| 21 | final class OverallTotalFactory |
| 22 | { |
| 23 | private OverallTotalFactory() |
| 24 | { |
| 25 | |
| 26 | } |
| 27 | |
| 28 | static OverallTotal newOverallTotal(final org.jtiger.framework.FixtureResults results) throws NullPointerException |
| 29 | { |
| 30 | if(results == null) |
| 31 | { |
| 32 | throw new NullPointerException(); |
| 33 | } |
| 34 | |
| 35 | return new OverallTotalImpl(results); |
| 36 | } |
| 37 | |
| 38 | private static final class OverallTotalImpl implements OverallTotal |
| 39 | { |
| 40 | private long success; |
| 41 | private long failure; |
| 42 | private long failureSetUp; |
| 43 | private long failureTearDown; |
| 44 | private long ignoredAnnotated; |
| 45 | private long ignoredCannotInvoke; |
| 46 | private final long total; |
| 47 | |
| 48 | OverallTotalImpl(final org.jtiger.framework.FixtureResults results) |
| 49 | { |
| 50 | for(org.jtiger.framework.FixtureResult result : results) |
| 51 | { |
| 52 | for(org.jtiger.framework.TestResult tr : result) |
| 53 | { |
| 54 | final TestResultType r = tr.getTestResultType(); |
| 55 | |
| 56 | if(r == SUCCESS) |
| 57 | { |
| 58 | success++; |
| 59 | } |
| 60 | else if(r == FAILURE) |
| 61 | { |
| 62 | failure++; |
| 63 | } |
| 64 | else if(r == FAILURE_SETUP) |
| 65 | { |
| 66 | failureSetUp++; |
| 67 | } |
| 68 | else if(r == FAILURE_TEARDOWN) |
| 69 | { |
| 70 | failureTearDown++; |
| 71 | } |
| 72 | else if(r == IGNORED_ANNOTATED) |
| 73 | { |
| 74 | ignoredAnnotated++; |
| 75 | } |
| 76 | else if(r == IGNORED_CANNOT_INVOKE) |
| 77 | { |
| 78 | ignoredCannotInvoke++; |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | total = success + failure + failureSetUp + failureTearDown + ignoredAnnotated + ignoredCannotInvoke; |
| 84 | } |
| 85 | |
| 86 | public long getSuccess() |
| 87 | { |
| 88 | return success; |
| 89 | } |
| 90 | |
| 91 | public long getFailure() |
| 92 | { |
| 93 | return failure; |
| 94 | } |
| 95 | |
| 96 | public long getFailureSetUp() |
| 97 | { |
| 98 | return failureSetUp; |
| 99 | } |
| 100 | |
| 101 | public long getFailureTearDown() |
| 102 | { |
| 103 | return failureTearDown; |
| 104 | } |
| 105 | |
| 106 | public long getIgnoredAnnotated() |
| 107 | { |
| 108 | return ignoredAnnotated; |
| 109 | } |
| 110 | |
| 111 | public long getIgnoredCannotInvoke() |
| 112 | { |
| 113 | return ignoredCannotInvoke; |
| 114 | } |
| 115 | |
| 116 | public long getTotal() |
| 117 | { |
| 118 | return total; |
| 119 | } |
| 120 | } |
| 121 | } |