Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. class Handler {
  2. private final Map<String, String> map;
  3.  
  4. public void handle(RequestResponse rr) {
  5. if (rr.isPut()) {
  6. map.put(rr.key(), rr.value());
  7. rr.response("OK");
  8. } else {
  9. rr.response(map.get(rr.key());
  10. }
  11. }
  12. }
  13.  
  14. when(rr.isPut()).thenReturn(true);
  15. when(rr.key()).thenReturn("key");
  16. when(rr.value()).thenReturn("value");
  17. handler.handle(rr);
  18. verify(rr).response("OK");
  19.  
  20. reset(rr);
  21.  
  22. when(rr.isPut()).thenReturn(false);
  23. when(rr.key()).thenReturn("key");
  24. handler.handle(rr);
  25. verify(rr).response("value");
  26.  
  27. reset(rr);
  28.  
  29. when(rr.isPut()).thenReturn(false);
  30. when(rr.key()).thenReturn("anotherKey");
  31. handler.handle(rr);
  32. verify(rr).response(null);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement