1 | |
package org.apache.maven.plugin.surefire.runorder; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
import java.util.StringTokenizer; |
22 | |
import org.apache.maven.surefire.report.ReportEntry; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
public class RunEntryStatistics |
28 | |
{ |
29 | |
private final int runTime; |
30 | |
|
31 | |
private final int successfulBuilds; |
32 | |
|
33 | |
private final String testName; |
34 | |
|
35 | |
private RunEntryStatistics( int runTime, int successfulBuilds, String testName ) |
36 | 0 | { |
37 | 0 | this.runTime = runTime; |
38 | 0 | this.successfulBuilds = successfulBuilds; |
39 | 0 | this.testName = testName; |
40 | 0 | } |
41 | |
|
42 | |
public static RunEntryStatistics fromReportEntry( ReportEntry previous ) |
43 | |
{ |
44 | 0 | final Integer elapsed = previous.getElapsed(); |
45 | 0 | return new RunEntryStatistics( elapsed != null ? elapsed.intValue() : 0, 0, previous.getName() ); |
46 | |
} |
47 | |
|
48 | |
public static RunEntryStatistics fromValues( int runTime, int successfulBuilds, Class clazz, String testName ) |
49 | |
{ |
50 | 0 | return new RunEntryStatistics( runTime, successfulBuilds, testName + "(" + clazz.getName() + ")" ); |
51 | |
} |
52 | |
|
53 | |
public RunEntryStatistics nextGeneration( int runTime ) |
54 | |
{ |
55 | 0 | return new RunEntryStatistics( runTime, this.successfulBuilds + 1, this.testName ); |
56 | |
} |
57 | |
|
58 | |
public RunEntryStatistics nextGenerationFailure( int runTime ) |
59 | |
{ |
60 | 0 | return new RunEntryStatistics( runTime, 0, this.testName ); |
61 | |
} |
62 | |
|
63 | |
public String getTestName() |
64 | |
{ |
65 | 0 | return testName; |
66 | |
} |
67 | |
|
68 | |
public int getRunTime() |
69 | |
{ |
70 | 0 | return runTime; |
71 | |
} |
72 | |
|
73 | |
|
74 | |
public int getSuccessfulBuilds() |
75 | |
{ |
76 | 0 | return successfulBuilds; |
77 | |
} |
78 | |
|
79 | |
public static RunEntryStatistics fromString( String line ) |
80 | |
{ |
81 | 0 | StringTokenizer tok = new StringTokenizer( line, "," ); |
82 | 0 | int successfulBuilds = Integer.parseInt( tok.nextToken() ); |
83 | 0 | int runTime = Integer.parseInt( tok.nextToken() ); |
84 | 0 | String className = tok.nextToken(); |
85 | 0 | return new RunEntryStatistics( runTime, successfulBuilds, className ); |
86 | |
} |
87 | |
|
88 | |
public String getAsString() |
89 | |
{ |
90 | 0 | StringBuffer stringBuffer = new StringBuffer(); |
91 | 0 | stringBuffer.append( successfulBuilds ); |
92 | 0 | stringBuffer.append( "," ); |
93 | 0 | stringBuffer.append( runTime ); |
94 | 0 | stringBuffer.append( "," ); |
95 | 0 | stringBuffer.append( testName ); |
96 | 0 | return stringBuffer.toString(); |
97 | |
} |
98 | |
|
99 | |
} |