@Before public void setUp() throws Exception { parser = new StoreCommandParser(); command = ImapCommand.anyStateCommand("Command"); session = mock(ImapSession.class); }
@Before public void setUp() throws Exception { parser = new SearchCommandParser(); command = ImapCommand.anyStateCommand("Command"); message = mock(ImapMessage.class); mockStatusResponseFactory = mock(StatusResponseFactory.class); session = mock(ImapSession.class); parser.setStatusResponseFactory(mockStatusResponseFactory); }
@Before public void setUp() throws Exception { parser = new FetchCommandParser(); command = ImapCommand.anyStateCommand("Command"); session = mock(ImapSession.class); }
@Test public void testUnsupportedRight() throws Exception { SetACLRequest setACLRequest = new SetACLRequest("TAG", ImapCommand.anyStateCommand("Name"), MAILBOX_NAME, USER_1, UNSUPPORTED_RIGHT); when(mailboxManager.hasRight(path, MailboxACL.Right.Lookup, mailboxSession)) .thenReturn(false); subject.doProcess(setACLRequest, responder, imapSession); verify(responder, times(1)).respond(argumentCaptor.capture()); verifyNoMoreInteractions(responder); assertThat(argumentCaptor.getAllValues()) .hasSize(1); assertThat(argumentCaptor.getAllValues().get(0)) .matches(StatusResponseTypeMatcher.BAD_RESPONSE_MATCHER::matches); }
@Before public void setUp() throws Exception { parser = new SearchCommandParser(); command = ImapCommand.anyStateCommand("Command"); message = mock(ImapMessage.class); session = mock(ImapSession.class); mockStatusResponseFactory = mock(StatusResponseFactory.class); parser.setStatusResponseFactory(mockStatusResponseFactory); }
@Before public void setUp() throws Exception { sharedSpaces = new ArrayList<>(); statusResponseStub = mock(StatusResponseFactory.class); mailboxManagerStub = mock(MailboxManager.class); subject = new NamespaceProcessor(mock(ImapProcessor.class), mailboxManagerStub, statusResponseStub, new NoopMetricFactory()); imapSessionStub = mock(ImapSession.class); mailboxSessionStub = mock(MailboxSession.class); namespaceRequest = new NamespaceRequest(ImapCommand.anyStateCommand("Name"), "TAG"); }
@Before public void setUp() throws Exception { parser = new SearchCommandParser(); command = ImapCommand.anyStateCommand("Command"); }
@Before public void setUp() throws Exception { parser = new SearchCommandParser(); command = ImapCommand.anyStateCommand("Command"); }
@Before public void setUp() throws Exception { parser = new SearchCommandParser(); command = ImapCommand.anyStateCommand("Command"); }
@Before public void setUp() throws Exception { parser = new SearchCommandParser(); command = ImapCommand.anyStateCommand("Command"); }
@Before public void setUp() throws Exception { parser = new SearchCommandParser(); command = ImapCommand.anyStateCommand("Command"); }
@Before public void setUp() throws Exception { parser = new SearchCommandParser(); command = ImapCommand.anyStateCommand("Command"); }
@Before public void setUp() throws Exception { factory = createInstance(); command = ImapCommand.anyStateCommand("Command"); }
@Test public void testQuotedMailbox() throws DecodingException { GetQuotaRootCommandParser parser = new GetQuotaRootCommandParser(); ImapCommand command = ImapCommand.anyStateCommand("Command"); String commandString = "\"INBOX\" \n"; InputStream inputStream = new ByteArrayInputStream(commandString.getBytes()); ImapRequestStreamLineReader lineReader = new ImapRequestStreamLineReader(inputStream, null); GetQuotaRootRequest request = (GetQuotaRootRequest) parser.decode(command, lineReader, "A003", null); GetQuotaRootRequest expected = new GetQuotaRootRequest("A003", command, "INBOX"); assertThat(request.getMailboxName()).isEqualTo(expected.getMailboxName()); }
@Test public void testNonQuotedMailbox() throws DecodingException { GetQuotaRootCommandParser parser = new GetQuotaRootCommandParser(); ImapCommand command = ImapCommand.anyStateCommand("Command"); String commandString = "INBOX\n"; InputStream inputStream = new ByteArrayInputStream(commandString.getBytes()); ImapRequestStreamLineReader lineReader = new ImapRequestStreamLineReader(inputStream, null); GetQuotaRootRequest request = (GetQuotaRootRequest) parser.decode(command, lineReader, "A003", null); GetQuotaRootRequest expected = new GetQuotaRootRequest("A003", command, "INBOX"); assertThat(request.getMailboxName()).isEqualTo(expected.getMailboxName()); }
@Test public void testQuotaParsing() throws DecodingException { CopyCommandParser parser = new CopyCommandParser(); ImapCommand command = ImapCommand.anyStateCommand("Command"); String commandString = " 42:69 foo \n"; InputStream inputStream = new ByteArrayInputStream(commandString.getBytes()); ImapRequestStreamLineReader lineReader = new ImapRequestStreamLineReader(inputStream, null); CopyRequest request = (CopyRequest) parser.decode(command, lineReader, "A003", null); CopyRequest expected = new CopyRequest(command, new IdRange[] {new IdRange(42, 69)}, "foo", false, "A003"); assertThat(request).isEqualTo(expected); } }
@Test public void testQuotaParsing() throws DecodingException { GetQuotaCommandParser parser = new GetQuotaCommandParser(); ImapCommand command = ImapCommand.anyStateCommand("Command"); String commandString = "quotaRoot \n"; InputStream inputStream = new ByteArrayInputStream(commandString.getBytes()); ImapRequestStreamLineReader lineReader = new ImapRequestStreamLineReader(inputStream, null); GetQuotaRequest request = (GetQuotaRequest) parser.decode(command, lineReader, "A003", null); GetQuotaRequest expected = new GetQuotaRequest("A003", command, "quotaRoot"); assertThat(request.getQuotaRoot()).isEqualTo(expected.getQuotaRoot()); } }
@Test public void testQuotaParsing() throws DecodingException { MoveCommandParser parser = new MoveCommandParser(); ImapCommand command = ImapCommand.anyStateCommand("Command"); String commandString = " 42:69 foo \n"; InputStream inputStream = new ByteArrayInputStream(commandString.getBytes()); ImapRequestStreamLineReader lineReader = new ImapRequestStreamLineReader(inputStream, null); MoveRequest request = (MoveRequest) parser.decode(command, lineReader, "A003", null); MoveRequest expected = new MoveRequest(command, new IdRange[] {new IdRange(42, 69)}, "foo", false, "A003"); assertThat(request).isEqualTo(expected); } }
@Test public void processShouldNotHandleCopyRequests() { CopyRequest copyRequest = new CopyRequest(ImapCommand.anyStateCommand("Name"), new IdRange[] {new IdRange(4, 6)}, ImapConstants.INBOX_NAME, true, TAG); testee.process(copyRequest, mockResponder, mockImapSession); verify(mockNextProcessor).process(copyRequest, mockResponder, mockImapSession); verifyNoMoreInteractions(mockMailboxManager, mockResponder, mockNextProcessor); } }
@Test public void processShouldNotHandleMoveRequests() { MoveRequest moveRequest = new MoveRequest(ImapCommand.anyStateCommand("Name"), new IdRange[] {new IdRange(4, 6)}, ImapConstants.INBOX_NAME, true, TAG); testee.process(moveRequest, mockResponder, mockImapSession); verify(mockNextProcessor).process(moveRequest, mockResponder, mockImapSession); verifyNoMoreInteractions(mockMailboxManager, mockResponder, mockNextProcessor); }