1 3 package org.jmock.expectation; 4 5 import java.util.HashMap ; 6 import org.jmock.core.Verifiable; 7 8 9 public class ExpectationMap implements Expectation, Verifiable 10 { 11 private HashMap myEntries; 12 private ExpectationSet myKeys; 13 14 public ExpectationMap( String name ) { 15 myEntries = new HashMap (); 16 myKeys = new ExpectationSet(name + " keys"); 17 } 18 19 public void addExpected( Object key, Object value ) { 20 myKeys.addExpected(key); 21 myEntries.put(key, value); 22 } 23 24 public void addExpectedMissing( Object key ) { 25 myKeys.addExpected(key); 26 27 } 28 29 public Object get( Object key ) { 30 myKeys.addActual(key); 31 return myEntries.get(key); 32 } 33 34 public boolean hasExpectations() { 35 return myKeys.hasExpectations(); 36 } 37 38 public void setExpectNothing() { 39 myKeys.setExpectNothing(); 40 } 41 42 public void setFailOnVerify() { 43 myKeys.setFailOnVerify(); 44 } 45 46 public void verify() { 47 myKeys.verify(); 48 } 49 } 50 | Popular Tags |