ThemeListImpl implements ThemeList, Serializable { @Override public boolean retainAll(Collection<?> themeNamesToRetain) { boolean changed = themes.retainAll(themeNamesToRetain); if (changed) { updateThemeAttribute(); } return changed; } ThemeListImpl(Element element); @Override Iterator<String> iterator(); @Override boolean add(String themeName); @Override boolean addAll(Collection<? extends String> themeNames); @Override boolean remove(Object themeName); @Override boolean retainAll(Collection<?> themeNamesToRetain); @Override boolean removeAll(Collection<?> themeNamesToRemove); @Override void clear(); @Override int size(); @Override boolean isEmpty(); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Override boolean contains(Object themeName); @Override boolean containsAll(Collection<?> themeNames); @Override String toString(); static final String THEME_ATTRIBUTE_NAME; }
@Test public void retainAll() { List<String> elementsToRetain = Arrays.asList("retained", "notRetained"); String[] themeNames = { elementsToRetain.get(0), "theme2", "theme3" }; MockElement element = new MockElement(themeNames); ThemeListImpl themeList = new ThemeListImpl(element); themeList.retainAll(elementsToRetain); assertEquals("ThemeList should contain one retained theme", themeList.size(), 1); assertEquals( "Corresponding element should contain the only element present in ThemeList", element.getAttribute(ThemeListImpl.THEME_ATTRIBUTE_NAME), themeList.iterator().next()); }