1 package org.apache.maven.plugin.surefire.runorder;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 /**
23 * @author Kristian Rosenvold
24 */
25 public class Priority
26 {
27 private final String className;
28
29 int priority;
30
31 int totalRuntime = 0;
32
33 int minSuccessRate = Integer.MAX_VALUE;
34
35 public Priority( String className )
36 {
37 this.className = className;
38 }
39
40 /**
41 * Returns a priority that applies to a new testclass (that has never been run/recorded)
42 *
43 * @param className The class name
44 * @return A priority
45 */
46 public static Priority newTestClassPriority( String className )
47 {
48 Priority priority1 = new Priority( className );
49 priority1.setPriority( 0 );
50 priority1.minSuccessRate = 0;
51 return priority1;
52 }
53
54 public void addItem( RunEntryStatistics itemStat )
55 {
56 totalRuntime += itemStat.getRunTime();
57 minSuccessRate = Math.min( minSuccessRate, itemStat.getSuccessfulBuilds() );
58 }
59
60
61 public int getTotalRuntime()
62 {
63 return totalRuntime;
64 }
65
66 public int getMinSuccessRate()
67 {
68 return minSuccessRate;
69 }
70
71 public String getClassName()
72 {
73 return className;
74 }
75
76 public int getPriority()
77 {
78 return priority;
79 }
80
81 public void setPriority( int priority )
82 {
83 this.priority = priority;
84 }
85 }