Clover coverage report - EasyMock 2.2
Coverage timestamp: Mo Apr 17 2006 21:21:22 CEST
file stats: LOC: 54   Methods: 3
NCLOC: 41   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LegacyMatcherProvider.java 100% 100% 100% 100%
coverage
 1    /*
 2    * Copyright (c) 2001-2006 OFFIS, Tammo Freese.
 3    * This program is made available under the terms of the MIT License.
 4    */
 5    package org.easymock.internal;
 6   
 7    import java.lang.reflect.Method;
 8    import java.util.HashMap;
 9    import java.util.Map;
 10   
 11    import org.easymock.ArgumentsMatcher;
 12    import org.easymock.MockControl;
 13   
 14    public class LegacyMatcherProvider {
 15   
 16    private ArgumentsMatcher defaultMatcher;
 17   
 18    private boolean defaultMatcherSet;
 19   
 20    private Map<Method, ArgumentsMatcher> matchers = new HashMap<Method, ArgumentsMatcher>();
 21   
 22  14 public ArgumentsMatcher getMatcher(Method method) {
 23  14 if (!matchers.containsKey(method)) {
 24  5 if (!defaultMatcherSet) {
 25  1 setDefaultMatcher(MockControl.EQUALS_MATCHER);
 26    }
 27  5 matchers.put(method, defaultMatcher);
 28    }
 29  14 return matchers.get(method);
 30    }
 31   
 32  7 public void setDefaultMatcher(ArgumentsMatcher matcher) {
 33  7 if (defaultMatcherSet) {
 34  1 throw new RuntimeExceptionWrapper(
 35    new IllegalStateException(
 36    "default matcher can only be set once directly after creation of the MockControl"));
 37    }
 38  6 defaultMatcher = matcher;
 39  6 defaultMatcherSet = true;
 40    }
 41   
 42  13 public void setMatcher(Method method, ArgumentsMatcher matcher) {
 43  13 if (matchers.containsKey(method) && matchers.get(method) != matcher) {
 44  2 throw new RuntimeExceptionWrapper(new IllegalStateException(
 45    "for method "
 46    + method.getName()
 47    + "("
 48  2 + (method.getParameterTypes().length == 0 ? ""
 49    : "...")
 50    + "), a matcher has already been set"));
 51    }
 52  11 matchers.put(method, matcher);
 53    }
 54    }