private String retrieveUserName(String namespace) { if (namespace.equals(MailboxConstants.USER_NAMESPACE)) { return ImapSessionUtils.getUserName(session); } return null; }
private MailboxPath buildRelativePath(String mailboxName) { return buildMailboxPath(MailboxConstants.USER_NAMESPACE, ImapSessionUtils.getUserName(session), mailboxName); }
user = ImapSessionUtils.getUserName(session);
@Test public void getUserNameShouldThrowOnNullImapSession() { assertThatThrownBy(() -> ImapSessionUtils.getUserName(null)) .isInstanceOf(NullPointerException.class); }
@Test public void getUserNameShouldReturnUserWhenMailboxSession() { fakeImapSession.setAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY, MAILBOX_SESSION); assertThat(ImapSessionUtils.getUserName(fakeImapSession)) .isEqualTo(USERNAME); }
@Override protected void doProcess(GetAnnotationRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) { try { proceed(message, session, tag, command, responder); } catch (MailboxNotFoundException e) { LOGGER.info("The command: {} is failed because not found mailbox {}", command.getName(), message.getMailboxName()); no(command, tag, responder, HumanReadableText.FAILURE_NO_SUCH_MAILBOX, ResponseCode.tryCreate()); } catch (MailboxException e) { LOGGER.error("GetAnnotation on mailbox {} failed for user {}", message.getMailboxName(), ImapSessionUtils.getUserName(session), e); no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING); } }
@Test public void getUserNameShouldReturnNullWhenNoMailboxSession() { assertThat(ImapSessionUtils.getUserName(fakeImapSession)) .isNull(); }
final String user = ImapSessionUtils.getUserName(session); final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
String user = ImapSessionUtils.getUserName(session); final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session); try {