Coverage Report - org.kuali.rice.krms.framework.engine.result.BasicResult
 
Classes in this File Line Coverage Branch Coverage Complexity
BasicResult
78%
29/37
50%
3/6
1.333
 
 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.apache.commons.lang.StringUtils;
 8  
 import org.joda.time.DateTime;
 9  
 import org.joda.time.format.DateTimeFormat;
 10  
 import org.joda.time.format.DateTimeFormatter;
 11  
 import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
 12  
 import org.kuali.rice.krms.api.engine.ResultEvent;
 13  
 
 14  
 public class BasicResult extends EventObject implements ResultEvent {
 15  
         private static final long serialVersionUID = -4124200802034785921L;
 16  
 
 17  1
     private static final DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH.mm.ss.SSS");
 18  
 
 19  
         protected String type;
 20  
         protected DateTime timestamp;
 21  
         protected ExecutionEnvironment environment;
 22  77
         protected Boolean result = null;
 23  
         protected String description;
 24  
         protected Map<String, ?> resultDetails;
 25  
 
 26  
     public BasicResult(Map<String, ?> resultDetails, String eventType, Object source, ExecutionEnvironment environment, boolean result) {
 27  3
         this(resultDetails, null, eventType, source, environment, result);
 28  3
     }
 29  
         
 30  
     public BasicResult(Map<String, ?> resultDetails, String description, String eventType, Object source, ExecutionEnvironment environment, boolean result) {
 31  3
         this(eventType, source, environment);
 32  3
         this.resultDetails = resultDetails;
 33  3
         this.result = new Boolean(result);
 34  3
         this.description = (description == null) ? StringUtils.EMPTY : description;
 35  3
     }
 36  
 
 37  
     public BasicResult(String description, String eventType, Object source, ExecutionEnvironment environment, boolean result) {
 38  0
                 this(eventType, source, environment);
 39  0
                 this.result = new Boolean(result);
 40  0
                 this.description = description;
 41  0
         }
 42  
 
 43  
         public BasicResult(String eventType, Object source, ExecutionEnvironment environment, boolean result) {
 44  73
                 this(eventType, source, environment);
 45  73
                 this.result = new Boolean(result);
 46  73
         }
 47  
 
 48  
         public BasicResult(String eventType, Object source, ExecutionEnvironment environment) {
 49  77
                 super(source);
 50  77
                 this.type = eventType;
 51  77
                 this.timestamp = new DateTime(); 
 52  77
                 this.environment = environment;
 53  77
         }
 54  
 
 55  
         @Override
 56  
         public String getType() {
 57  973
                 return type;
 58  
         }
 59  
 
 60  
         @Override
 61  
         public DateTime getTimestamp() {
 62  973
                 return timestamp;
 63  
         }
 64  
         
 65  
         @Override
 66  
         public ExecutionEnvironment getEnvironment(){
 67  1050
                 return environment;
 68  
         }
 69  
         
 70  
         @Override
 71  
         public Boolean getResult(){
 72  1937
                 return result;
 73  
         }
 74  
 
 75  
         @Override
 76  
         public String getDescription() {
 77  0
             return description;
 78  
         }
 79  
         
 80  
         @Override
 81  
         public Map<String, ?> getResultDetails() {
 82  0
             if (resultDetails == null) {
 83  0
                 return Collections.emptyMap();
 84  
             } else {
 85  0
                 return Collections.unmodifiableMap(resultDetails);
 86  
             }
 87  
         }
 88  
 
 89  
         public String toString(){
 90  973
                 StringBuffer sb = new StringBuffer();
 91  973
         sb.append(fmt.print(this.getTimestamp()));
 92  973
                 sb.append(" EventType: "+ getType());
 93  973
                 sb.append(" ( "+ this.getSource().toString());
 94  973
                 if (this.getResult() != null){
 95  964
                         sb.append(" evaluated to: "+ this.getResult().toString());
 96  
                 }
 97  973
                 sb.append(" )");
 98  973
                 return sb.toString();
 99  
         }
 100  
 }