PathConverter { public MailboxPath buildFullPath(String mailboxName) { if (Strings.isNullOrEmpty(mailboxName)) { return buildRelativePath(""); } if (isAbsolute(mailboxName)) { return buildAbsolutePath(mailboxName); } else { return buildRelativePath(mailboxName); } } private  PathConverter(ImapSession session); static PathConverter forSession(ImapSession session); MailboxPath buildFullPath(String mailboxName);  }
@Test public void buildFullPathShouldAcceptNull() { assertThat(pathConverter.buildFullPath(null)) .isEqualTo(new MailboxPath("", USERNAME, "")); }
@Test public void buildPathShouldAcceptEmpty() { assertThat(pathConverter.buildFullPath("")) .isEqualTo(new MailboxPath("", USERNAME, "")); }
@Test public void buildPathShouldAcceptRelativeMailboxName() { String mailboxName = "mailboxName"; assertThat(pathConverter.buildFullPath(mailboxName)) .isEqualTo(MailboxPath.forUser(USERNAME, mailboxName)); }
@Test public void buildFullPathShouldAcceptUserNamespace() { assertThat(pathConverter.buildFullPath(MailboxConstants.USER_NAMESPACE)) .isEqualTo(MailboxPath.forUser(USERNAME, "")); }
@Test public void buildFullPathShouldAcceptUserNamespaceAndDelimiter() { assertThat(pathConverter.buildFullPath(MailboxConstants.USER_NAMESPACE + PATH_DELIMITER)) .isEqualTo(MailboxPath.forUser(USERNAME, "")); }
@Test public void buildFullPathShouldAcceptFullAbsoluteUserPath() { String mailboxName = "mailboxName"; assertThat(pathConverter.buildFullPath(MailboxConstants.USER_NAMESPACE + PATH_DELIMITER + mailboxName)) .isEqualTo(MailboxPath.forUser(USERNAME, mailboxName)); }
@Test public void buildFullPathShouldAcceptRelativePathWithSubFolder() { String mailboxName = "mailboxName" + PATH_DELIMITER + "subFolder"; assertThat(pathConverter.buildFullPath(mailboxName)) .isEqualTo(MailboxPath.forUser(USERNAME, mailboxName)); }
@Test public void buildFullPathShouldAcceptAbsoluteUserPathWithSubFolder() { String mailboxName = "mailboxName.subFolder"; assertThat(pathConverter.buildFullPath(MailboxConstants.USER_NAMESPACE + PATH_DELIMITER + mailboxName)) .isEqualTo(MailboxPath.forUser(USERNAME, mailboxName)); }
@Test public void buildFullPathShouldDenyMailboxPathNotBelongingToTheUser() { expectedException.expect(DeniedAccessOnSharedMailboxException.class); pathConverter.buildFullPath("#any"); }