Coverage Report - org.kuali.rice.krms.framework.engine.result.TimingResult
 
Classes in this File Line Coverage Branch Coverage Complexity
TimingResult
54%
17/31
0%
0/2
1.2
 
 1  
 package org.kuali.rice.krms.framework.engine.result;
 2  
 
 3  
 import java.util.Collections;
 4  
 import java.util.EventObject;
 5  
 import java.util.Map;
 6  
 
 7  
 import org.joda.time.DateTime;
 8  
 import org.joda.time.format.DateTimeFormat;
 9  
 import org.joda.time.format.DateTimeFormatter;
 10  
 import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
 11  
 import org.kuali.rice.krms.api.engine.ResultEvent;
 12  
 
 13  
 public class TimingResult extends EventObject implements ResultEvent {
 14  
     
 15  
         private static final long serialVersionUID = 5335636381355236617L;
 16  
 
 17  1
     private static final DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH.mm.ss.SSS");
 18  
         
 19  
     private String type;
 20  
         private DateTime start;
 21  
         private DateTime end;
 22  
         private ExecutionEnvironment environment;
 23  
         private String description;
 24  
         private Map<String, ?> resultDetails;
 25  
 
 26  
         public TimingResult(String description, String type, Object source, ExecutionEnvironment environment, DateTime start, DateTime end){
 27  0
                 super(source);
 28  0
                 this.type = type;
 29  0
                 this.environment = environment;
 30  0
                 this.start = start;
 31  0
                 this.end = end;
 32  0
                 this.description = description;
 33  0
         }
 34  
         
 35  
         public TimingResult(String type, Object source, ExecutionEnvironment environment, DateTime start, DateTime end){
 36  29
                 super(source);
 37  29
                 this.type = type;
 38  29
                 this.environment = environment;
 39  29
                 this.start = start;
 40  29
                 this.end = end;
 41  29
         }
 42  
         
 43  
         public Long getElapsedTimeInMilliseconds(){
 44  435
                 return Long.valueOf(end.getMillis() - start.getMillis());
 45  
         }
 46  
         
 47  
         public ExecutionEnvironment getEnvironment(){
 48  464
                 return environment;
 49  
         };
 50  
         
 51  
         public String toString(){
 52  435
                 StringBuffer sb = new StringBuffer();
 53  435
                 sb.append(fmt.print(end));
 54  435
                 sb.append(" EventType: "+ type);
 55  435
                 sb.append(" (Start = " + fmt.print(start));
 56  435
                 sb.append(", End = " + fmt.print(end));
 57  435
                 sb.append(",  Elapsed Time = "+ getElapsedTimeInMilliseconds().toString());
 58  435
                 sb.append(" milliseconds.)");
 59  435
                 return sb.toString();
 60  
         }
 61  
 
 62  
         @Override
 63  
         public Boolean getResult() {
 64  0
                 return null;
 65  
         }
 66  
 
 67  
         @Override
 68  
         public DateTime getTimestamp() {
 69  0
                 return end;
 70  
         }
 71  
 
 72  
         @Override
 73  
         public String getType() {
 74  0
                 return type;
 75  
         }
 76  
         
 77  
         @Override
 78  
         public Map<String, ?> getResultDetails() {
 79  0
             if (resultDetails == null) {
 80  0
                 return Collections.emptyMap();
 81  
             } else {
 82  0
                 return Collections.unmodifiableMap(resultDetails);
 83  
             }
 84  
         }
 85  
         
 86  
         @Override
 87  
         public String getDescription() {
 88  0
                 return description;
 89  
         }
 90  
 }