KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmock > expectation > ExpectationMap


1 /* Copyright (c) 2000-2004 jMock.org
2  */

3 package org.jmock.expectation;
4
5 import java.util.HashMap JavaDoc;
6 import org.jmock.core.Verifiable;
7
8
9 public class ExpectationMap implements Expectation, Verifiable
10 {
11     private HashMap JavaDoc myEntries;
12     private ExpectationSet myKeys;
13
14     public ExpectationMap( String JavaDoc name ) {
15         myEntries = new HashMap JavaDoc();
16         myKeys = new ExpectationSet(name + " keys");
17     }
18
19     public void addExpected( Object JavaDoc key, Object JavaDoc value ) {
20         myKeys.addExpected(key);
21         myEntries.put(key, value);
22     }
23
24     public void addExpectedMissing( Object JavaDoc key ) {
25         myKeys.addExpected(key);
26
27     }
28
29     public Object JavaDoc get( Object JavaDoc 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