DomainConfiguration implements Named { public void removePassword(String passwordName) { ArgumentNotValid.checkNotNullOrEmpty(passwordName, "passwordName"); if (!usesPassword(passwordName)) { throw new UnknownID("No password named '" + passwordName + "' found in '" + this + "'"); } for (Iterator<Password> i = passwords.iterator(); i.hasNext();) { Password p = i.next(); if (p.getName().equals(passwordName)) { i.remove(); } } } DomainConfiguration(String theConfigName, Domain domain, List<SeedList> seedlists, List<Password> passwords);  DomainConfiguration(String theConfigName, String domainName, DomainHistory history,
            List<String> crawlertraps, List<SeedList> seedlists, List<Password> passwords); static String cfgToString(DomainConfiguration cfg); void setOrderXmlName(String ordername); void setMaxObjects(long max); void setMaxRequestRate(int maxrate); void setMaxBytes(long maxBytes); String getName(); String getComments(); String getOrderXmlName(); long getMaxObjects(); int getMaxRequestRate(); long getMaxBytes(); String getDomainName(); Iterator<SeedList> getSeedLists(); void addSeedList(Domain domain, SeedList seedlist); void setSeedLists(Domain domain, List<SeedList> newSeedlists); Iterator<Password> getPasswords(); void addPassword(Domain domain, Password password); long getExpectedNumberOfObjects(long objectLimit, long byteLimit); long minObjectsBytesLimit(long objectLimit, long byteLimit, long expectedObjectSize); void setComments(String comments); void removePassword(String passwordName); boolean usesPassword(String passwordName); void setPasswords(Domain domain, List<Password> newPasswords); Long getID(); String toString(); void setCrawlertraps(List<String> someCrawlertraps); List<String> getCrawlertraps(); DomainHistory getDomainhistory(); void setDomainhistory(DomainHistory newDomainhistory); void setName(String configName); List<AttributeAndType> getAttributesAndTypes(); void setAttributesAndTypes(List<AttributeAndType> attributesAndTypes);  }
@Test public void testRemovePassword() { DomainConfiguration conf = createDefaultDomainConfiguration(); Domain domain = mock(Domain.class); when(domain.getPassword(PASSWORD.getName())).thenReturn(PASSWORD); conf.addPassword(domain, PASSWORD); conf.removePassword(PASSWORD_NAME); assertFalse("Configuration should have password removed", conf.usesPassword(PASSWORD_NAME)); }
@Test(expected = UnknownID.class) public void testRemoveUnusedPassword() { DomainConfiguration conf = createDefaultDomainConfiguration(); conf.removePassword(PASSWORD_NAME); }