@Before public void setup() { ObjectMapperFactory objectMapperFactory = new ObjectMapperFactory(new InMemoryId.Factory(), new InMemoryMessageId.Factory()); jmapRequestParser = new JmapRequestParserImpl(objectMapperFactory); jmapResponseWriter = new JmapResponseWriterImpl(objectMapperFactory); mockHttpServletRequest = mock(HttpServletRequest.class); testee = new RequestHandler(ImmutableSet.of(new TestMethod()), jmapRequestParser, jmapResponseWriter); }
@Test public void processShouldReturnNotCreatedWhenMailboxExceptionOccured() throws Exception { MailboxCreationId parentId = MailboxCreationId.of("0"); MailboxId parentMailboxId = mailboxIdFactory.fromString(parentId.getCreationId()); MailboxCreationId mailboxCreationId = MailboxCreationId.of("1"); SetMailboxesRequest request = SetMailboxesRequest.builder() .create(mailboxCreationId, MailboxCreateRequest.builder().name("name").parentId(parentId).build()) .build(); MailboxSession mailboxSession = mock(MailboxSession.class); when(mailboxManager.getMailbox(parentMailboxId, mailboxSession)) .thenThrow(new MailboxException()); SetMailboxesResponse setMailboxesResponse = sut.process(request, mailboxSession); assertThat(setMailboxesResponse.getCreated()).isEmpty(); assertThat(setMailboxesResponse.getNotCreated()).containsEntry(mailboxCreationId, SetError.builder() .type(SetError.Type.ERROR) .description("An error occurred when creating the mailbox '1'") .build()); } }
@Override protected void initializeMailboxManager() throws Exception { Client client = MailboxIndexCreationUtil.prepareDefaultClient( new TestingClientProvider(embeddedElasticSearch.getNode()).get()); storeMailboxManager = new InMemoryIntegrationResources() .createMailboxManager(new SimpleGroupMembershipResolver()); ElasticSearchListeningMessageSearchIndex elasticSearchListeningMessageSearchIndex = new ElasticSearchListeningMessageSearchIndex( storeMailboxManager.getMapperFactory(), new ElasticSearchIndexer(client, Executors.newSingleThreadExecutor(), MailboxElasticSearchConstants.DEFAULT_MAILBOX_WRITE_ALIAS, MailboxElasticSearchConstants.MESSAGE_TYPE, BATCH_SIZE), new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), SEARCH_SIZE, new InMemoryId.Factory(), storeMailboxManager.getMessageIdFactory(), MailboxElasticSearchConstants.DEFAULT_MAILBOX_READ_ALIAS, MailboxElasticSearchConstants.MESSAGE_TYPE), new MessageToElasticSearchJson(textExtractor, ZoneId.of("Europe/Paris"), IndexAttachments.YES)); messageIdManager = new StoreMessageIdManager( storeMailboxManager, storeMailboxManager.getMapperFactory(), storeMailboxManager.getEventDispatcher(), storeMailboxManager.getMessageIdFactory(), storeMailboxManager.getQuotaManager(), storeMailboxManager.getQuotaRootResolver()); storeMailboxManager.setMessageSearchIndex(elasticSearchListeningMessageSearchIndex); storeMailboxManager.addGlobalListener(elasticSearchListeningMessageSearchIndex, new MockMailboxSession("admin")); this.messageSearchIndex = elasticSearchListeningMessageSearchIndex; }
@Before public void setup() { parser = new ObjectMapperFactory(new InMemoryId.Factory(), new InMemoryMessageId.Factory()).forParsing(); }
@Before public void setup() { testee = new ObjectMapperFactory(new InMemoryId.Factory(), new InMemoryMessageId.Factory()); }
@Before public void setup() { mailboxManager = mock(MailboxManager.class); mailboxIdFactory = new InMemoryId.Factory(); sut = new SetMailboxesCreationProcessor(mailboxManager, subscriptionManager, mailboxFactory, mailboxIdFactory, new NoopMetricFactory()); }
@Before public void setup() { testee = new ObjectMapperFactory(new InMemoryId.Factory(), new TestMessageId.Factory()); }
@Before public void setup() { testee = new JmapResponseWriterImpl(new ObjectMapperFactory(new InMemoryId.Factory(), new InMemoryMessageId.Factory())); }
@Before public void setup() { testee = new JmapRequestParserImpl(new ObjectMapperFactory(new InMemoryId.Factory(), new InMemoryMessageId.Factory())); }
@Override public void beforeEach(ExtensionContext extensionContext) throws Exception { FilteringManagement filteringManagement = new EventSourcingFilteringManagement(new InMemoryEventStore()); MemoryUsersRepository usersRepository = MemoryUsersRepository.withoutVirtualHosting(); InMemoryMailboxManager mailboxManager = new InMemoryIntegrationResources().createMailboxManager(new SimpleGroupMembershipResolver()); ActionApplier.Factory actionApplierFactory = ActionApplier.factory(mailboxManager, new InMemoryId.Factory()); JMAPFiltering jmapFiltering = new JMAPFiltering(filteringManagement, usersRepository, actionApplierFactory); testSystem = new JMAPFilteringTestSystem(jmapFiltering, filteringManagement, mailboxManager); }