### Question:
GreenMail extends ConfiguredGreenMail { @Override public MimeMessage[] getReceivedMessagesForDomain(String domain) { List<StoredMessage> msgs = managers.getImapHostManager().getAllMessages(); List<MimeMessage> ret = new ArrayList<>(); try { for (StoredMessage msg : msgs) { String tos = GreenMailUtil.getAddressList(msg.getMimeMessage().getAllRecipients()); if (tos.toLowerCase().contains(domain.toLowerCase())) { ret.add(msg.getMimeMessage()); } } } catch (MessagingException e) { throw new RuntimeException(e); } return ret.toArray(new MimeMessage[ret.size()]); } GreenMail();  GreenMail(ServerSetup config);  GreenMail(ServerSetup[] config); @Override synchronized void start(); @Override synchronized void stop(); @Override void reset(); @Override SmtpServer getSmtp(); @Override ImapServer getImap(); @Override Pop3Server getPop3(); @Override SmtpServer getSmtps(); @Override ImapServer getImaps(); @Override Pop3Server getPop3s(); @Override Managers getManagers(); @Override boolean waitForIncomingEmail(long timeout, int emailCount); @Override boolean waitForIncomingEmail(int emailCount); @Override MimeMessage[] getReceivedMessages(); @Override MimeMessage[] getReceivedMessagesForDomain(String domain); @Override GreenMailUser setUser(String login, String password); @Override GreenMailUser setUser(String email, String login, String password); @Override void setQuotaSupported(boolean isEnabled); @Override void setUsers(Properties users); @Override GreenMail withConfiguration(GreenMailConfiguration config); @Override void purgeEmailFromAllMailboxes();  }### Answer:
@Test public void getReceivedMessagesForDomainLowerCaseRecipientAddress() { final String to = "to@localhost.com"; GreenMailUtil.sendTextEmailTest(to, "from@localhost.com", "subject", "body"); final MimeMessage[] receivedMessagesForDomain = greenMail.getReceivedMessagesForDomain(to); assertThat(receivedMessagesForDomain.length).isEqualTo(1); }
@Test public void getReceivedMessagesForDomainWithUpperCaseRecipientAddress() { final String to = "someReceiver@localhost.com"; GreenMailUtil.sendTextEmailTest(to, "from@localhost.com", "subject", "body"); final MimeMessage[] receivedMessagesForDomain = greenMail.getReceivedMessagesForDomain(to); assertThat(receivedMessagesForDomain.length).isEqualTo(1); }