@Test public void getNameShouldReturnMailboxNameWhenChildOfChildMailbox() throws Exception { String expected = "mailbox"; MailboxPath mailboxPath = MailboxPath.forUser(user, "inbox.children." + expected); String name = sut.getName(mailboxPath, mailboxSession); assertThat(name).isEqualTo(expected); }
@VisibleForTesting String getName(MailboxPath mailboxPath, MailboxSession mailboxSession) { String name = mailboxPath.getName(); if (name.contains(String.valueOf(mailboxSession.getPathDelimiter()))) { List<String> levels = Splitter.on(mailboxSession.getPathDelimiter()).splitToList(name); return levels.get(levels.size() - 1); } return name; }
MailboxFactory { @VisibleForTesting String getName(MailboxPath mailboxPath, MailboxSession mailboxSession) { String name = mailboxPath.getName(); if (name.contains(String.valueOf(mailboxSession.getPathDelimiter()))) { List<String> levels = Splitter.on(mailboxSession.getPathDelimiter()).splitToList(name); return levels.get(levels.size() - 1); } return name; } }
MailboxFactory { @VisibleForTesting String getName(MailboxPath mailboxPath, MailboxSession mailboxSession) { String name = mailboxPath.getName(); if (name.contains(String.valueOf(mailboxSession.getPathDelimiter()))) { List<String> levels = Splitter.on(mailboxSession.getPathDelimiter()).splitToList(name); return levels.get(levels.size() - 1); } return name; } @Inject  MailboxFactory(MailboxManager mailboxManager, QuotaManager quotaManager, QuotaRootResolver quotaRootResolver); }
MailboxFactory { @VisibleForTesting String getName(MailboxPath mailboxPath, MailboxSession mailboxSession) { String name = mailboxPath.getName(); if (name.contains(String.valueOf(mailboxSession.getPathDelimiter()))) { List<String> levels = Splitter.on(mailboxSession.getPathDelimiter()).splitToList(name); return levels.get(levels.size() - 1); } return name; } @Inject  MailboxFactory(MailboxManager mailboxManager, QuotaManager quotaManager, QuotaRootResolver quotaRootResolver); MailboxBuilder builder(); }
MailboxFactory { @VisibleForTesting String getName(MailboxPath mailboxPath, MailboxSession mailboxSession) { String name = mailboxPath.getName(); if (name.contains(String.valueOf(mailboxSession.getPathDelimiter()))) { List<String> levels = Splitter.on(mailboxSession.getPathDelimiter()).splitToList(name); return levels.get(levels.size() - 1); } return name; } @Inject  MailboxFactory(MailboxManager mailboxManager, QuotaManager quotaManager, QuotaRootResolver quotaRootResolver); MailboxBuilder builder();  }