ThemeListImpl implements ThemeList, Serializable { @Override public boolean addAll(Collection<? extends String> themeNames) { boolean changed = themes.addAll(themeNames); 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 addAll() { List<String> themesToAdd = Arrays.asList("theme1", "theme2", "theme3"); MockElement element = new MockElement(); ThemeListImpl themeList = new ThemeListImpl(element); themeList.addAll(themesToAdd); assertFalse("ThemeList should not be empty after adding themes", themeList.isEmpty()); assertEquals( "ThemeList size should be equal to number of distinct themes added if it was empty before", themeList.size(), themesToAdd.size()); assertTrue("ThemeList should contain all distinct themes added", themeList.containsAll(themesToAdd)); themesToAdd.forEach(themeName -> assertTrue( "Each distinct theme added to ThemeList should be present in correspondent element's 'theme' attribute", element.getAttribute(ThemeListImpl.THEME_ATTRIBUTE_NAME) .contains(themeName))); }