@VisibleForTesting public RegisteredDelegatingMailboxListener(EventSerializer eventSerializer, Publisher publisher, MessageConsumer messageConsumer, MailboxPathRegister mailboxPathRegister) throws Exception { this(eventSerializer, publisher, messageConsumer, mailboxPathRegister, new SynchronousEventDelivery(new NoopMetricFactory())); }
@VisibleForTesting public BroadcastDelegatingMailboxListener(Publisher publisher, MessageConsumer messageConsumer, EventSerializer eventSerializer, String globalTopic) throws Exception { this(publisher, messageConsumer, eventSerializer, new SynchronousEventDelivery(new NoopMetricFactory()), globalTopic); }
@VisibleForTesting public DefaultDelegatingMailboxListener() { this(new SynchronousEventDelivery(new NoopMetricFactory()), new MailboxListenerRegistry()); }
protected ProtocolHandler create(String className) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { try { return (ProtocolHandler) Thread.currentThread().getContextClassLoader().loadClass(className).newInstance(); } catch (InstantiationException e) { return (ProtocolHandler) Thread.currentThread().getContextClassLoader().loadClass(className).getConstructor(MetricFactory.class).newInstance(new NoopMetricFactory()); } }
protected ProtocolHandler create(String className) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { try { return (ProtocolHandler) Thread.currentThread().getContextClassLoader().loadClass(className).newInstance(); } catch (InstantiationException e) { return (ProtocolHandler) Thread.currentThread().getContextClassLoader().loadClass(className).getConstructor(MetricFactory.class).newInstance(new NoopMetricFactory()); } }
@Before public void setUp() { mockNextProcessor = mock(ImapProcessor.class); mockMailboxManager = mock(MailboxManager.class); mockStatusResponseFactory = mock(StatusResponseFactory.class); mockResponder = mock(ImapProcessor.Responder.class); mockImapSession = mock(ImapSession.class); mockMailboxSession = mock(MailboxSession.class); testee = new CopyProcessor(mockNextProcessor, mockMailboxManager, mockStatusResponseFactory, new NoopMetricFactory()); }
@Test public void filterShouldReturnUnauthorizedWhenNoStrategy() throws Exception { when(mockedRequest.getHeader("Authorization")) .thenReturn(TOKEN); AuthenticationFilter sut = new AuthenticationFilter(ImmutableList.of(), new NoopMetricFactory()); sut.doFilter(mockedRequest, mockedResponse, filterChain); verify(mockedResponse).sendError(HttpServletResponse.SC_UNAUTHORIZED); }
@Before public void setup() throws Exception { usersRepository = MemoryUsersRepository.withoutVirtualHosting(); sut = new UserProvisioningFilter(usersRepository, new NoopMetricFactory()); request = mock(HttpServletRequest.class); response = mock(HttpServletResponse.class); chain = mock(FilterChain.class); }
@Before public void setUp() { mockNextProcessor = mock(ImapProcessor.class); mockMailboxManager = mock(MailboxManager.class); mockStatusResponseFactory = mock(StatusResponseFactory.class); mockResponder = mock(ImapProcessor.Responder.class); mockImapSession = mock(ImapSession.class); mockMailboxSession = mock(MailboxSession.class); when(mockMailboxManager.hasCapability(eq(MailboxCapabilities.Move))).thenReturn(true); testee = new MoveProcessor(mockNextProcessor, mockMailboxManager, mockStatusResponseFactory, new NoopMetricFactory()); verify(mockMailboxManager).hasCapability(MailboxCapabilities.Move); }
@Before public void before() { session = new MockMailboxSession(USERNAME); mailboxManager = mock(MailboxManager.class); subscriptionManager = mock(SubscriptionManager.class); sut = new DefaultMailboxesProvisioningFilter(mailboxManager, subscriptionManager, new NoopMetricFactory()); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); initAndMockData(); processor = new SetAnnotationProcessor(mockNextProcessor, mockMailboxManager, mockStatusResponseFactory, new NoopMetricFactory()); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); initAndMockData(); processor = new GetAnnotationProcessor(mockNextProcessor, mockMailboxManager, mockStatusResponseFactory, new NoopMetricFactory()); }
@BeforeEach void setUp() { event = mock(MailboxListener.MailboxEvent.class); listener = newListener(); inVmEventDelivery = new InVmEventDelivery(new NoopMetricFactory()); }
@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() { mailboxManager = mock(MailboxManager.class); mailboxIdFactory = new InMemoryId.Factory(); sut = new SetMailboxesCreationProcessor(mailboxManager, subscriptionManager, mailboxFactory, mailboxIdFactory, new NoopMetricFactory()); }
@Test public void getImplementedCapabilitiesShouldNotContainMoveWhenUnSupportedByMailboxManager() { when(mockMailboxManager.hasCapability(eq(MailboxCapabilities.Move))).thenReturn(false); assertThat(new MoveProcessor(mockNextProcessor, mockMailboxManager, mockStatusResponseFactory, new NoopMetricFactory()) .getImplementedCapabilities(null)).isEmpty(); }
@Before public void setUp() { mailboxSession = new MockMailboxSession("plop"); UnpooledStatusResponseFactory statusResponseFactory = new UnpooledStatusResponseFactory(); mockedImapSession = mock(ImapSession.class); mockedResponder = mock(ImapProcessor.Responder.class); mockedMailboxManager = mock(MailboxManager.class); testee = new SetQuotaProcessor(mock(ImapProcessor.class), mockedMailboxManager, statusResponseFactory, new NoopMetricFactory()); }
@BeforeEach void setUp() { deadLetters = new MemoryEventDeadLetters(); eventBus = new InVMEventBus( new InVmEventDelivery(new NoopMetricFactory()), RetryBackoffConfiguration.DEFAULT, deadLetters); }
@Test public void deserializerShouldTakeFirstNodeWhenSeveral() throws Exception { String expectedExtractedContent = "content A"; TikaTextExtractor textExtractor = new TikaTextExtractor( new NoopMetricFactory(), (inputStream, contentType) -> Optional.of(new ByteArrayInputStream(("[{\"X-TIKA:content\": \"" + expectedExtractedContent + "\"}, " + "{\"X-TIKA:content\": \"content B\"}]") .getBytes(StandardCharsets.UTF_8)))); InputStream inputStream = null; ParsedContent parsedContent = textExtractor.extractContent(inputStream, "text/plain"); assertThat(parsedContent.getTextualContent()).contains(expectedExtractedContent); }
@Test public void filterShouldNotTryToAddUserWhenReadOnlyUsersRepository() throws Exception { UsersRepository usersRepository = mock(UsersRepository.class); when(usersRepository.isReadOnly()).thenReturn(true); sut = new UserProvisioningFilter(usersRepository, new NoopMetricFactory()); MailboxSession mailboxSession = new MockMailboxSession(MAIL); when(request.getAttribute(AuthenticationFilter.MAILBOX_SESSION)) .thenReturn(mailboxSession); sut.doFilter(request, response, chain); verify(usersRepository).isReadOnly(); verifyNoMoreInteractions(usersRepository); }