Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Handler {
- private final Map<String, String> map;
- public void handle(RequestResponse rr) {
- if (rr.isPut()) {
- map.put(rr.key(), rr.value());
- rr.response("OK");
- } else {
- rr.response(map.get(rr.key());
- }
- }
- }
- when(rr.isPut()).thenReturn(true);
- when(rr.key()).thenReturn("key");
- when(rr.value()).thenReturn("value");
- handler.handle(rr);
- verify(rr).response("OK");
- reset(rr);
- when(rr.isPut()).thenReturn(false);
- when(rr.key()).thenReturn("key");
- handler.handle(rr);
- verify(rr).response("value");
- reset(rr);
- when(rr.isPut()).thenReturn(false);
- when(rr.key()).thenReturn("anotherKey");
- handler.handle(rr);
- verify(rr).response(null);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement