01: package com.reeltwo.jumble.fast;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: /**
07: * <code>NormalJumbleResult</code> is a JumbleResult for a test pass
08: * (that is, the mutation caused a test failure).
09: *
10: * @author <a href="mailto:len@reeltwo.com">Len Trigg</a>
11: * @version $Revision: 496 $
12: */
13: public class NormalJumbleResult extends AbstractJumbleResult {
14:
15: private List mTestClassNames;
16:
17: private MutationResult[] mAllMutations;
18:
19: private long mTimeoutLength;
20:
21: public NormalJumbleResult(String className, List testClassNames,
22: MutationResult[] allMutations, long timeout) {
23: super (className);
24: mTestClassNames = testClassNames;
25: mAllMutations = allMutations;
26: mTimeoutLength = timeout;
27: }
28:
29: /** {@inheritDoc} */
30: public MutationResult[] getAllMutations() {
31: return mAllMutations;
32: }
33:
34: /** {@inheritDoc} */
35: public int getNumberOfMutations() {
36: return mAllMutations.length;
37: }
38:
39: /** {@inheritDoc} */
40: public MutationResult[] getCovered() {
41: return filter(MutationResult.PASS);
42: }
43:
44: /** {@inheritDoc} */
45: public MutationResult[] getTimeouts() {
46: return filter(MutationResult.TIMEOUT);
47: }
48:
49: /** {@inheritDoc} */
50: public MutationResult[] getMissed() {
51: return filter(MutationResult.FAIL);
52: }
53:
54: /** {@inheritDoc} */
55: public long getTimeoutLength() {
56: return mTimeoutLength;
57: }
58:
59: /** {@inheritDoc} */
60: public String[] getTestClasses() {
61: return (String[]) mTestClassNames
62: .toArray(new String[mTestClassNames.size()]);
63: }
64:
65: /** {@inheritDoc} */
66: private MutationResult[] filter(int mutationType) {
67: MutationResult[] all = getAllMutations();
68: ArrayList ret = new ArrayList();
69:
70: for (int i = 0; i < all.length; i++) {
71: if (all[i].getStatus() == mutationType) {
72: ret.add(all[i]);
73: }
74: }
75:
76: return (MutationResult[]) ret.toArray(new MutationResult[ret
77: .size()]);
78: }
79:
80: }
|