Clover coverage report - jMock - 1.0-beta1
Coverage timestamp: Sat Nov 29 2003 19:35:59 GMT
file stats: LOC: 70   Methods: 9
NCLOC: 55   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
InvocationMocker.java 100% 91.3% 77.8% 90.5%
coverage coverage
 1   
 /* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */
 2   
 package org.jmock.dynamic;
 3   
 
 4   
 import org.jmock.InvocationMatcher;
 5   
 import org.jmock.Stub;
 6   
 import org.jmock.matcher.MethodNameMatcher;
 7   
 
 8   
 import java.util.ArrayList;
 9   
 import java.util.Iterator;
 10   
 import java.util.List;
 11   
 
 12   
 public class InvocationMocker implements Invokable {
 13   
 
 14   
     private List matchers = new ArrayList();
 15   
     private Stub stub;
 16   
 
 17  38
     public InvocationMocker(String methodName, InvocationMatcher arguments, Stub stub) {
 18  38
         this(stub);
 19  38
         addMatcher(new MethodNameMatcher(methodName));
 20  38
         addMatcher(arguments);
 21   
     }
 22   
 
 23  22
     public InvocationMocker(InvocationMatcher[] matchers, Stub stub) {
 24  22
         this(stub);
 25  20
         for (int i = 0; i < matchers.length; i++) addMatcher(matchers[i]);
 26   
     }
 27   
 
 28  60
     public InvocationMocker(Stub stub) {
 29  60
         this.stub = stub;
 30   
     }
 31   
 
 32  0
     public String getDescription() {
 33  0
         return null; // TODO
 34   
     }
 35   
 
 36  46
     public boolean matches(Invocation invocation) {
 37  46
         Iterator i = matchers.iterator();
 38  46
         while (i.hasNext()) {
 39  108
             if (!((InvocationMatcher) i.next()).matches(invocation)) {
 40  22
                 return false;
 41   
             }
 42   
         }
 43  24
         return true;
 44   
     }
 45   
 
 46  24
     public Object invoke(Invocation invocation) throws Throwable {
 47  24
         Iterator i = matchers.iterator();
 48  24
         while (i.hasNext()) {
 49  58
             ((InvocationMatcher) i.next()).invoked(invocation);
 50   
         }
 51  24
         return stub.invoke(invocation);
 52   
     }
 53   
 
 54  20
     public void verify() {
 55  20
         Iterator i = matchers.iterator();
 56  20
         while (i.hasNext()) {
 57  56
             ((InvocationMatcher) i.next()).verify();
 58   
         }
 59   
     }
 60   
 
 61  134
     public InvocationMocker addMatcher(InvocationMatcher matcher) {
 62  134
         matchers.add(matcher);
 63  134
         return this;
 64   
     }
 65   
 
 66  0
     public void setStub(Stub stub) {
 67  0
         this.stub = stub;
 68   
     }
 69   
 }
 70