JamesMailetContext implements MailetContext, Configurable, Disposable { @Override public boolean isLocalUser(String name) { return localResources.isLocalUser(name); } @Inject  JamesMailetContext(DNSService dns, DomainList domains, LocalResources localResources, MailQueueFactory<?> mailQueueFactory); @PreDestroy @Override void dispose(); @Override Collection<String> getMailServers(Domain host); @Override Object getAttribute(String key); @Override void setAttribute(String key, Object object); @Override void removeAttribute(String key); @Override Iterator<String> getAttributeNames(); @Override void bounce(Mail mail, String message); @Override void bounce(Mail mail, String message, MailAddress bouncer); @Override List<String> dnsLookup(String s, RecordType recordType); @Override boolean isLocalUser(String name); @Override boolean isLocalEmail(MailAddress mailAddress); @Override Collection<MailAddress> localRecipients(Collection<MailAddress> recipients); @Override MailAddress getPostmaster(); @Override int getMajorVersion(); @Override int getMinorVersion(); @Override @Deprecated Iterator<org.apache.mailet.HostAddress> getSMTPHostAddresses(Domain domainName); @Override String getServerInfo(); @Override boolean isLocalServer(Domain domain); @Override @Deprecated void log(String arg0); @Override @Deprecated void log(String arg0, Throwable arg1); @Override @Deprecated void log(LogLevel logLevel, String s); @Override @Deprecated void log(LogLevel logLevel, String s, Throwable throwable); @Override void sendMail(MimeMessage message); @Override void sendMail(MailAddress sender, Collection<MailAddress> recipients, MimeMessage message); @Override void sendMail(Mail mail); @Override void sendMail(Mail mail, long delay, TimeUnit unit); @Override void sendMail(Mail mail, String state); @Override void sendMail(Mail mail, String state, long delay, TimeUnit unit); @Override void sendMail(MailAddress sender, Collection<MailAddress> recipients, MimeMessage message, String state); @Override void configure(HierarchicalConfiguration<ImmutableNode> config); @Override Logger getLogger();  }
@Test public void isLocalUserShouldBeFalseOnNullUser() { assertThat(testee.isLocalUser(null)).isFalse(); }
@Test public void isLocalUserShouldPropagateDomainExceptions() throws Exception { when(domainList.getDefaultDomain()).thenThrow(new DomainListException("fail!")); assertThatThrownBy(() -> testee.isLocalUser("user")) .isInstanceOf(RuntimeException.class); }
@Test public void isLocalUserShouldBeTrueWhenUsernameExist() throws Exception { domainList.addDomain(DOMAIN_COM); usersRepository.addUser(USERMAIL, PASSWORD); assertThat(testee.isLocalUser(USERMAIL.asString())).isTrue(); }
@Test public void isLocalUserShouldBeFalseWhenUsernameDoNotExist() { assertThat(testee.isLocalUser(USERMAIL.asString())).isFalse(); }