Coverage Report - org.apache.maven.surefire.report.CategorizedReportEntry
 
Classes in this File Line Coverage Branch Coverage Complexity
CategorizedReportEntry
0%
0/28
0%
0/22
2,5
 
 1  
 package org.apache.maven.surefire.report;
 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 CategorizedReportEntry
 26  
     extends SimpleReportEntry
 27  
     implements ReportEntry
 28  
 {
 29  
     private static final String GROUP_PREFIX = " (of ";
 30  
 
 31  
     private static final String GROUP_SUFIX = ")";
 32  
 
 33  
     private final String group;
 34  
 
 35  
     public CategorizedReportEntry( String source, String name, String group )
 36  
     {
 37  0
         this( source, name, group, null, null );
 38  0
     }
 39  
 
 40  
     public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
 41  
                                    Integer elapsed )
 42  
     {
 43  0
         super( source, name, stackTraceWriter, elapsed );
 44  0
         this.group = group;
 45  0
     }
 46  
 
 47  
     public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
 48  
                                    Integer elapsed, String message )
 49  
     {
 50  0
         super( source, name, stackTraceWriter, elapsed, message );
 51  0
         this.group = group;
 52  0
     }
 53  
 
 54  
     public static ReportEntry reportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
 55  
                                            Integer elapsed, String message )
 56  
     {
 57  0
         return group != null
 58  
             ? new CategorizedReportEntry( source, name, group, stackTraceWriter, elapsed, message )
 59  
             : new SimpleReportEntry( source, name, stackTraceWriter, elapsed, message );
 60  
     }
 61  
 
 62  
     public String getGroup()
 63  
     {
 64  0
         return group;
 65  
     }
 66  
 
 67  
     @Override
 68  
     public String getNameWithGroup()
 69  
     {
 70  0
         StringBuilder result = new StringBuilder();
 71  0
         result.append( getName() );
 72  
 
 73  0
         if ( getGroup() != null && !getName().equals( getGroup() ) )
 74  
         {
 75  0
             result.append( GROUP_PREFIX );
 76  0
             result.append( getGroup() );
 77  0
             result.append( GROUP_SUFIX );
 78  
         }
 79  
 
 80  0
         return result.toString();
 81  
     }
 82  
 
 83  
     public boolean equals( Object o )
 84  
     {
 85  0
         if ( this == o )
 86  
         {
 87  0
             return true;
 88  
         }
 89  0
         if ( o == null || getClass() != o.getClass() )
 90  
         {
 91  0
             return false;
 92  
         }
 93  0
         if ( !super.equals( o ) )
 94  
         {
 95  0
             return false;
 96  
         }
 97  
 
 98  0
         CategorizedReportEntry that = (CategorizedReportEntry) o;
 99  
 
 100  0
         return !( group != null ? !group.equals( that.group ) : that.group != null );
 101  
 
 102  
     }
 103  
 
 104  
     public int hashCode()
 105  
     {
 106  0
         int result = super.hashCode();
 107  0
         result = 31 * result + ( group != null ? group.hashCode() : 0 );
 108  0
         return result;
 109  
     }
 110  
 }