Clover coverage report - jMock - 1.0-beta1
Coverage timestamp: Sat Nov 29 2003 19:35:59 GMT
file stats: LOC: 50   Methods: 4
NCLOC: 27   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
IsEventFrom.java 100% 87.5% 75% 85.7%
coverage coverage
 1   
 /* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */
 2   
 package org.jmock.constraint;
 3   
 
 4   
 import org.jmock.Constraint;
 5   
 
 6   
 import java.util.EventObject;
 7   
 
 8   
 /**
 9   
  * Tests if the value is an event announced by a specific object.
 10   
  */
 11   
 public class IsEventFrom
 12   
         implements Constraint {
 13   
     private Class _event_class;
 14   
     private Object _source;
 15   
 
 16   
     /**
 17   
      * Constructs an IsEventFrom predicate that returns true for any object
 18   
      * derived from {@link java.util.EventObject} announced by
 19   
      * <var>source</var>.
 20   
      */
 21  2
     public IsEventFrom(Object source) {
 22  2
         this(EventObject.class, source);
 23   
     }
 24   
 
 25   
     /**
 26   
      * Constructs an IsEventFrom predicate that returns true for any object
 27   
      * derived from <var>event_class</var> announced by
 28   
      * <var>source</var>.
 29   
      */
 30  4
     public IsEventFrom(Class event_class, Object source) {
 31  4
         _event_class = event_class;
 32  4
         _source = source;
 33   
     }
 34   
 
 35  14
     public boolean eval(Object o) {
 36  14
         if (o instanceof EventObject) {
 37  12
             EventObject ev = (EventObject) o;
 38  12
             return _event_class.isInstance(o) && ev.getSource() == _source;
 39   
 
 40   
         } else {
 41  2
             return false;
 42   
         }
 43   
     }
 44   
 
 45  0
     public String toString() {
 46  0
         return "an event of type " + _event_class.getName() +
 47   
                 " from " + _source;
 48   
     }
 49   
 }
 50