### Question:
UserDataCacheService { public void incrementNewMessageCountFor(String username) { Element cacheElementForUser = userDataCache.get(username); if (cacheElementForUser != null) { int count = (Integer) cacheElementForUser.getValue(); userDataCache.put(new Element(username, ++count)); } } UserDataCacheService(Ehcache userDataCache); Integer getNewPmCountFor(String username); void putNewPmCount(String username, int count); void incrementNewMessageCountFor(String username); void decrementNewMessageCountFor(String username);  }### Answer:
@Test public void testIncrementNewMessageCountFor() throws Exception { Element cacheElement = new Element(USERNAME, 1); when(cache.get(USERNAME)).thenReturn(cacheElement); userDataCacheService.incrementNewMessageCountFor(USERNAME); verify(cache).get(USERNAME); verify(cache).put(new Element(USERNAME, 2)); }
@Test public void testIncrementNewMessageCountForKeyNotInCache() throws Exception { when(cache.get(USERNAME)).thenReturn(null); userDataCacheService.incrementNewMessageCountFor(USERNAME); verify(cache).get(USERNAME); }