DomainConfiguration implements Named { public void addPassword(Domain domain, Password password) { ArgumentNotValid.checkNotNull(password, "password"); Password domainPassword = domain.getPassword(password.getName()); if (!domainPassword.equals(password)) { String message = "Cannot add password " + password + " to " + this + " as it differs from the one defined " + "for " + domain + ": " + domainPassword; log.debug(message); throw new PermissionDenied(message); } passwords.add(domainPassword); } 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 testAddPassword() { DomainConfiguration conf = createDefaultDomainConfiguration(); Domain domain = mock(Domain.class); when(domain.getPassword(PASSWORD.getName())).thenReturn(PASSWORD); conf.addPassword(domain, PASSWORD); assertTrue("Configuration uses password", conf.usesPassword(PASSWORD_NAME)); }