KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > ExpectationMap


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