### Question:
UserDataCacheService { public Integer getNewPmCountFor(String username) { Element cacheElementForUser = userDataCache.get(username); if (cacheElementForUser == null) { return null; } return (Integer) cacheElementForUser.getValue(); } 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 testGetNewPmCountFor() throws Exception { when(cache.get(USERNAME)).thenReturn(new Element(USERNAME, 2)); Integer count = userDataCacheService.getNewPmCountFor(USERNAME); assertEquals(count.intValue(), 2); verify(cache).get(USERNAME); }
@Test public void testGetNewPmCountForNonExistentUserInCache() throws Exception { when(cache.get(USERNAME)).thenReturn(null); Integer count = userDataCacheService.getNewPmCountFor(USERNAME); assertNull(count); verify(cache).get(USERNAME); }