ThemeListImpl implements ThemeList, Serializable { @Override public boolean removeAll(Collection<?> themeNamesToRemove) { boolean changed = themes.removeAll(themeNamesToRemove); 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 removeAll() { String themeToRemove1 = "theme3"; String themeToRemove2 = "theme2"; String themeToLeave = "theme1"; MockElement element = new MockElement(themeToLeave, themeToRemove1, themeToRemove2); ThemeListImpl themeList = new ThemeListImpl(element); themeList.removeAll(Arrays.asList(themeToRemove1, themeToRemove2)); assertEquals( "Only one theme should be present in ThemeList after removal", themeList.size(), 1); assertTrue("ThemeList should contain theme that was not removed", themeList.contains(themeToLeave)); assertEquals( "Corresponding element should contain only the theme that was not removed", element.getAttribute(ThemeListImpl.THEME_ATTRIBUTE_NAME), themeToLeave); }