### Question:
DefaultPortalPreferenceService implements PortalPreferenceService { @Override public Map<String, PortalPreference> getPreferencesAsMap() { final List<PortalPreference> portalPreferences = repository.getAll(); Map<String, PortalPreference> preferenceMap = new HashMap<String, PortalPreference>(); for (PortalPreference preference : portalPreferences) { preferenceMap.put(preference.getKey(), preference); } return preferenceMap; } @Autowired  DefaultPortalPreferenceService(PortalPreferenceRepository repository, RaveEventManager manager); @Override Map<String, PortalPreference> getPreferencesAsMap(); @Override PortalPreference getPreference(String key); @Override SearchResult<PortalPreference> getAll(); @Override SearchResult<PortalPreference> getLimitedList(int offset, int pageSize); @Override @Transactional void savePreference(String key, String value); @Override @Transactional void savePreference(String key, List<String> values); @Override @Transactional void savePreference(PortalPreference preference);  }### Answer:
@Test public void testGetPreferencesAsMap() { expect(repository.getAll()).andReturn(portalPreferenceList()); replay(repository); final Map<String, PortalPreference> map = service.getPreferencesAsMap(); verify(repository); assertEquals(2, map.size()); assertEquals("Rave", map.get("title").getValue()); final List<String> colors = map.get("colors").getValues(); assertTrue(colors.contains("red")); assertTrue(colors.contains("yellow")); assertTrue(colors.contains("blue")); }