Coverage Report - org.apache.maven.plugin.surefire.runorder.RunEntryStatistics
 
Classes in this File Line Coverage Branch Coverage Complexity
RunEntryStatistics
32%
8/25
0%
0/2
1,1
 
 1  
 package org.apache.maven.plugin.surefire.runorder;
 2  
 /*
 3  
  * Licensed to the Apache Software Foundation (ASF) under one
 4  
  * or more contributor license agreements.  See the NOTICE file
 5  
  * distributed with this work for additional information
 6  
  * regarding copyright ownership.  The ASF licenses this file
 7  
  * to you under the Apache License, Version 2.0 (the
 8  
  * "License"); you may not use this file except in compliance
 9  
  * with the License.  You may obtain a copy of the License at
 10  
  *
 11  
  *     http://www.apache.org/licenses/LICENSE-2.0
 12  
  *
 13  
  * Unless required by applicable law or agreed to in writing,
 14  
  * software distributed under the License is distributed on an
 15  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 16  
  * KIND, either express or implied.  See the License for the
 17  
  * specific language governing permissions and limitations
 18  
  * under the License.
 19  
  */
 20  
 
 21  
 import java.util.StringTokenizer;
 22  
 import org.apache.maven.surefire.report.ReportEntry;
 23  
 
 24  
 /**
 25  
  * @author Kristian Rosenvold
 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  16
     {
 37  16
         this.runTime = runTime;
 38  16
         this.successfulBuilds = successfulBuilds;
 39  16
         this.testName = testName;
 40  16
     }
 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  16
         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  16
         return runTime;
 71  
     }
 72  
 
 73  
 
 74  
     public int getSuccessfulBuilds()
 75  
     {
 76  16
         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  
 }