Coverage Report - org.apache.maven.surefire.report.SimpleReportEntry
 
Classes in this File Line Coverage Branch Coverage Complexity
SimpleReportEntry
0%
0/50
0%
0/46
2,706
 
 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 SimpleReportEntry
 26  
     implements ReportEntry
 27  
 {
 28  
     private final String source;
 29  
 
 30  
     private final String name;
 31  
 
 32  
     private final StackTraceWriter stackTraceWriter;
 33  
 
 34  
     private final Integer elapsed;
 35  
 
 36  
     private final String message;
 37  
 
 38  
     public SimpleReportEntry( String source, String name )
 39  
     {
 40  0
         this( source, name, null, null );
 41  0
     }
 42  
 
 43  
     private SimpleReportEntry( String source, String name, StackTraceWriter stackTraceWriter )
 44  
     {
 45  0
         this( source, name, stackTraceWriter, null );
 46  0
     }
 47  
 
 48  
     public SimpleReportEntry( String source, String name, Integer elapsed )
 49  
     {
 50  0
         this( source, name, null, elapsed );
 51  0
     }
 52  
 
 53  
     protected SimpleReportEntry( String source, String name, StackTraceWriter stackTraceWriter, Integer elapsed,
 54  
                                  String message )
 55  0
     {
 56  0
         if ( source == null )
 57  
         {
 58  0
             throw new NullPointerException( "source is null" );
 59  
         }
 60  0
         if ( name == null )
 61  
         {
 62  0
             throw new NullPointerException( "name is null" );
 63  
         }
 64  
 
 65  0
         this.source = source;
 66  
 
 67  0
         this.name = name;
 68  
 
 69  0
         this.stackTraceWriter = stackTraceWriter;
 70  
 
 71  0
         this.message = message;
 72  
 
 73  0
         this.elapsed = elapsed;
 74  0
     }
 75  
 
 76  
 
 77  
     public SimpleReportEntry( String source, String name, StackTraceWriter stackTraceWriter, Integer elapsed )
 78  
     {
 79  
         //noinspection ThrowableResultOfMethodCallIgnored
 80  0
         this( source, name, stackTraceWriter, elapsed, safeGetMessage( stackTraceWriter ) );
 81  0
     }
 82  
 
 83  
     public static SimpleReportEntry ignored( String source, String name, String message )
 84  
     {
 85  0
         return new SimpleReportEntry( source, name, null, null, message );
 86  
     }
 87  
 
 88  
     public static SimpleReportEntry withException( String source, String name, StackTraceWriter stackTraceWriter )
 89  
     {
 90  0
         return new SimpleReportEntry( source, name, stackTraceWriter );
 91  
     }
 92  
 
 93  
     private static String safeGetMessage( StackTraceWriter stackTraceWriter )
 94  
     {
 95  
         try
 96  
         {
 97  0
             return ( stackTraceWriter != null && stackTraceWriter.getThrowable() != null )
 98  
                 ? stackTraceWriter.getThrowable().getMessage()
 99  
                 : null;
 100  
         }
 101  0
         catch ( Throwable t )
 102  
         {
 103  0
             return t.getMessage();
 104  
         }
 105  
     }
 106  
 
 107  
     public String getSourceName()
 108  
     {
 109  0
         return source;
 110  
     }
 111  
 
 112  
     public String getName()
 113  
     {
 114  0
         return name;
 115  
     }
 116  
 
 117  
     public String getGroup()
 118  
     {
 119  0
         return null;
 120  
     }
 121  
 
 122  
     public StackTraceWriter getStackTraceWriter()
 123  
     {
 124  0
         return stackTraceWriter;
 125  
     }
 126  
 
 127  
     public Integer getElapsed()
 128  
     {
 129  0
         return elapsed;
 130  
     }
 131  
 
 132  
     public String toString()
 133  
     {
 134  0
         return "ReportEntry{" + "source='" + source + '\'' + ", name='" + name + '\'' + ", stackTraceWriter="
 135  
             + stackTraceWriter + ", elapsed=" + elapsed + ",message=" + message + '}';
 136  
     }
 137  
 
 138  
     public String getMessage()
 139  
     {
 140  0
         return message;
 141  
     }
 142  
 
 143  
     /**
 144  
      * @noinspection RedundantIfStatement
 145  
      */
 146  
     public boolean equals( Object o )
 147  
     {
 148  0
         if ( this == o )
 149  
         {
 150  0
             return true;
 151  
         }
 152  0
         if ( o == null || getClass() != o.getClass() )
 153  
         {
 154  0
             return false;
 155  
         }
 156  
 
 157  0
         SimpleReportEntry that = (SimpleReportEntry) o;
 158  
 
 159  0
         if ( elapsed != null ? !elapsed.equals( that.elapsed ) : that.elapsed != null )
 160  
         {
 161  0
             return false;
 162  
         }
 163  0
         if ( name != null ? !name.equals( that.name ) : that.name != null )
 164  
         {
 165  0
             return false;
 166  
         }
 167  0
         if ( source != null ? !source.equals( that.source ) : that.source != null )
 168  
         {
 169  0
             return false;
 170  
         }
 171  0
         if ( stackTraceWriter != null
 172  
             ? !stackTraceWriter.equals( that.stackTraceWriter )
 173  
             : that.stackTraceWriter != null )
 174  
         {
 175  0
             return false;
 176  
         }
 177  
 
 178  0
         return true;
 179  
     }
 180  
 
 181  
     public int hashCode()
 182  
     {
 183  0
         int result = source != null ? source.hashCode() : 0;
 184  0
         result = 31 * result + ( name != null ? name.hashCode() : 0 );
 185  0
         result = 31 * result + ( stackTraceWriter != null ? stackTraceWriter.hashCode() : 0 );
 186  0
         result = 31 * result + ( elapsed != null ? elapsed.hashCode() : 0 );
 187  0
         return result;
 188  
     }
 189  
 
 190  
 
 191  
 }