This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 3b55c40a21c84d8fbaddb21370ee783ed951dd4c Author: Rene Cordier <[email protected]> AuthorDate: Thu Feb 20 13:25:53 2020 +0700 JAMES-3057 Replace usage of MailboxMapper.create(Mailbox) by MailboxMapper.create(MailboxPath, long) --- .../CassandraMailboxMapperConcurrencyTest.java | 5 +- .../cassandra/mail/CassandraMailboxMapperTest.java | 67 +++++++++++-------- .../mail/migration/MailboxPathV2MigrationTest.java | 17 +++-- ...asticSearchListeningMessageSearchIndexTest.java | 3 +- .../spamassassin/SpamAssassinListenerTest.java | 17 +++-- .../james/mailbox/store/StoreMailboxManager.java | 28 ++++---- .../store/mail/model/MailboxMapperACLTest.java | 8 +-- .../store/mail/model/MailboxMapperTest.java | 78 +++++++--------------- .../store/mail/model/MessageIdMapperTest.java | 4 +- .../store/mail/model/MessageMapperTest.java | 6 +- .../mailbox/store/mail/model/MessageMoveTest.java | 5 +- .../adapter/mailbox/MailboxManagementTest.java | 65 +++++++----------- 12 files changed, 124 insertions(+), 179 deletions(-) diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java index 8fd1bf2..99044c8 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperConcurrencyTest.java @@ -64,7 +64,7 @@ class CassandraMailboxMapperConcurrencyTest { @Test void createShouldBeThreadSafe() throws Exception { ConcurrentTestRunner.builder() - .operation((a, b) -> testee.create(new Mailbox(MAILBOX_PATH, UID_VALIDITY))) + .operation((a, b) -> testee.create(MAILBOX_PATH, UID_VALIDITY)) .threadCount(THREAD_COUNT) .operationCount(OPERATION_COUNT) .runAcceptingErrorsWithin(Duration.ofMinutes(1)); @@ -74,8 +74,7 @@ class CassandraMailboxMapperConcurrencyTest { @Test void renameWithUpdateShouldBeThreadSafe() throws Exception { - Mailbox mailbox = new Mailbox(MAILBOX_PATH, UID_VALIDITY); - testee.create(mailbox); + Mailbox mailbox = testee.create(MAILBOX_PATH, UID_VALIDITY); mailbox.setName("newName"); diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java index a8745d6..220e817 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java @@ -22,6 +22,7 @@ package org.apache.james.mailbox.cassandra.mail; import static org.apache.james.mailbox.model.MailboxAssertingTool.softly; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; @@ -40,6 +41,7 @@ import org.apache.james.core.Username; import org.apache.james.mailbox.cassandra.ids.CassandraId; import org.apache.james.mailbox.cassandra.modules.CassandraAclModule; import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule; +import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.exception.MailboxNotFoundException; import org.apache.james.mailbox.exception.TooLongMailboxNameException; import org.apache.james.mailbox.model.Mailbox; @@ -109,7 +111,6 @@ class CassandraMailboxMapperTest { class ConsistencyTest { private MailboxPath inboxPath; - private Mailbox inbox; private MailboxPath inboxPathRenamed; private Mailbox inboxRenamed; private MailboxQuery.UserBound allMailboxesSearchQuery; @@ -119,8 +120,6 @@ class CassandraMailboxMapperTest { @BeforeEach void setUp() { inboxPath = MailboxPath.forUser(USER, INBOX); - inbox = new Mailbox(inboxPath, UID_VALIDITY); - inboxPathRenamed = MailboxPath.forUser(USER, INBOX_RENAMED); inboxRenamed = new Mailbox(inboxPathRenamed, UID_VALIDITY); allMailboxesSearchQuery = MailboxQuery.builder() @@ -144,9 +143,9 @@ class CassandraMailboxMapperTest { void createShouldBeConsistentWhenFailToPersistMailbox() { doReturn(Mono.error(new RuntimeException("mock exception"))) .when(mailboxDAO) - .save(inbox); + .save(any()); - doQuietly(() -> testee.create(inbox)); + doQuietly(() -> testee.create(inboxPath, UID_VALIDITY)); SoftAssertions.assertSoftly(softly -> { softly.assertThatThrownBy(() -> testee.findMailboxByPath(inboxPath)) @@ -160,7 +159,8 @@ class CassandraMailboxMapperTest { @Test void renameThenFailToRetrieveMailboxShouldBeConsistentWhenFindByInbox() throws Exception { - CassandraId inboxId = (CassandraId) testee.create(inbox); + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); + CassandraId inboxId = (CassandraId) inbox.getMailboxId(); inboxRenamed.setMailboxId(inboxId); when(mailboxDAO.retrieveMailbox(inboxId)) @@ -186,7 +186,8 @@ class CassandraMailboxMapperTest { @Disabled("JAMES-3056 returning two mailboxes with same name and id") @Test void renameThenFailToRetrieveMailboxShouldBeConsistentWhenFindAll() throws Exception { - CassandraId inboxId = (CassandraId) testee.create(inbox); + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); + CassandraId inboxId = (CassandraId) inbox.getMailboxId(); inboxRenamed.setMailboxId(inboxId); when(mailboxDAO.retrieveMailbox(inboxId)) @@ -206,7 +207,8 @@ class CassandraMailboxMapperTest { @Disabled("JAMES-3056 find by renamed name returns unexpected results") @Test void renameThenFailToRetrieveMailboxShouldBeConsistentWhenFindByRenamedInbox() throws Exception { - CassandraId inboxId = (CassandraId) testee.create(inbox); + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); + CassandraId inboxId = (CassandraId) inbox.getMailboxId(); inboxRenamed.setMailboxId(inboxId); when(mailboxDAO.retrieveMailbox(inboxId)) @@ -225,7 +227,8 @@ class CassandraMailboxMapperTest { @Test void renameThenFailToDeleteMailboxPathShouldBeConsistentWhenFindByInbox() throws Exception { - CassandraId inboxId = (CassandraId) testee.create(inbox); + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); + CassandraId inboxId = (CassandraId) inbox.getMailboxId(); inboxRenamed.setMailboxId(inboxId); when(mailboxPathV2DAO.delete(inboxPath)) @@ -251,7 +254,8 @@ class CassandraMailboxMapperTest { @Disabled("JAMES-3056 returning two mailboxes with same name and id") @Test void renameThenFailToDeleteMailboxPathShouldBeConsistentWhenFindAll() throws Exception { - CassandraId inboxId = (CassandraId) testee.create(inbox); + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); + CassandraId inboxId = (CassandraId) inbox.getMailboxId(); inboxRenamed.setMailboxId(inboxId); when(mailboxPathV2DAO.delete(inboxPath)) @@ -271,7 +275,8 @@ class CassandraMailboxMapperTest { @Disabled("JAMES-3056 find by renamed name returns unexpected results") @Test void renameThenFailToDeleteMailboxPathShouldBeConsistentWhenFindByRenamedInbox() throws Exception { - CassandraId inboxId = (CassandraId) testee.create(inbox); + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); + CassandraId inboxId = (CassandraId) inbox.getMailboxId(); inboxRenamed.setMailboxId(inboxId); when(mailboxPathV2DAO.delete(inboxPath)) @@ -291,7 +296,8 @@ class CassandraMailboxMapperTest { @Disabled("JAMES-3056 find by mailbox name returns unexpected results") @Test void deleteShouldBeConsistentWhenFailToDeleteMailbox() throws Exception { - CassandraId inboxId = (CassandraId) testee.create(inbox); + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); + CassandraId inboxId = (CassandraId) inbox.getMailboxId(); doReturn(Mono.error(new RuntimeException("mock exception"))) .when(mailboxDAO) @@ -318,7 +324,8 @@ class CassandraMailboxMapperTest { @Disabled("JAMES-3056 both mailboxes of the same user have 'INBOX' name") @Test void missedMigrationShouldNotLeadToGhostMailbox() throws Exception { - CassandraId inboxId = (CassandraId) testee.create(inbox); + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); + CassandraId inboxId = (CassandraId) inbox.getMailboxId(); // simulate mailbox old data has not been migrated to v2 mailboxPathDAO.save(inboxPath, inboxId).block(); mailboxPathV2DAO.delete(inboxPath).block(); @@ -335,14 +342,14 @@ class CassandraMailboxMapperTest { @Disabled("JAMES-3057 org.apache.james.mailbox.exception.MailboxNotFoundException: INBOX can not be found") @Test - void createAfterPreviousFailedCreateShouldCreateAMailbox() { - when(mailboxDAO.save(inbox)) + void createAfterPreviousFailedCreateShouldCreateAMailbox() throws MailboxException { + when(mailboxDAO.save(any())) .thenReturn(Mono.error(new RuntimeException("mock exception"))) .thenCallRealMethod(); - doQuietly(() -> testee.create(inbox)); - inbox.setMailboxId(null); - doQuietly(() -> testee.create(inbox)); + doQuietly(() -> testee.create(inboxPath, UID_VALIDITY)); + + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); SoftAssertions.assertSoftly(Throwing.consumer(softly -> { softly(softly) @@ -360,20 +367,19 @@ class CassandraMailboxMapperTest { } @Test - void createAfterPreviousDeleteOnFailedCreateShouldCreateAMailbox() { + void createAfterPreviousDeleteOnFailedCreateShouldCreateAMailbox() throws MailboxException { doReturn(Mono.error(new RuntimeException("mock exception"))) .when(mailboxDAO) - .save(inbox); + .save(any()); - doQuietly(() -> testee.create(inbox)); - doQuietly(() -> testee.delete(inbox)); - inbox.setMailboxId(null); + doQuietly(() -> testee.create(inboxPath, UID_VALIDITY)); + doQuietly(() -> testee.delete(new Mailbox(inboxPath, UID_VALIDITY, CassandraId.timeBased()))); doCallRealMethod() .when(mailboxDAO) - .save(inbox); + .save(any()); - doQuietly(() -> testee.create(inbox)); + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); SoftAssertions.assertSoftly(Throwing.consumer(softly -> { softly(softly) @@ -392,7 +398,8 @@ class CassandraMailboxMapperTest { @Test void deleteAfterAFailedDeleteShouldDeleteTheMailbox() throws Exception { - CassandraId inboxId = (CassandraId) testee.create(inbox); + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); + CassandraId inboxId = (CassandraId) inbox.getMailboxId(); when(mailboxDAO.delete(inboxId)) .thenReturn(Mono.error(new RuntimeException("mock exception"))) @@ -417,7 +424,8 @@ class CassandraMailboxMapperTest { "findMailboxWithPathLike() returns a list with two same mailboxes") @Test void renameAfterRenameFailOnRetrieveMailboxShouldRenameTheMailbox() throws Exception { - CassandraId inboxId = (CassandraId) testee.create(inbox); + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); + CassandraId inboxId = (CassandraId) inbox.getMailboxId(); inboxRenamed.setMailboxId(inboxId); when(mailboxDAO.retrieveMailbox(inboxId)) @@ -450,7 +458,8 @@ class CassandraMailboxMapperTest { @Disabled("JAMES-3056 mailbox name is not updated to INBOX_RENAMED") @Test void renameAfterRenameFailOnDeletePathShouldRenameTheMailbox() throws Exception { - CassandraId inboxId = (CassandraId) testee.create(inbox); + Mailbox inbox = testee.create(inboxPath, UID_VALIDITY); + CassandraId inboxId = (CassandraId) inbox.getMailboxId(); inboxRenamed.setMailboxId(inboxId); when(mailboxPathV2DAO.delete(inboxPath)) @@ -493,7 +502,7 @@ class CassandraMailboxMapperTest { @Disabled("JAMES-2514 Cassandra 3 supports long mailbox names. Hence we can not rely on this for failing") @Test void renameShouldNotRemoveOldMailboxPathWhenCreatingTheNewMailboxPathFails() throws Exception { - testee.create(new Mailbox(MAILBOX_PATH, UID_VALIDITY)); + testee.create(MAILBOX_PATH, UID_VALIDITY); Mailbox mailbox = testee.findMailboxByPath(MAILBOX_PATH); Mailbox newMailbox = new Mailbox(tooLongMailboxPath(mailbox.generateAssociatedPath()), UID_VALIDITY, mailbox.getMailboxId()); diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java index 738da9c..2657eb7 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/migration/MailboxPathV2MigrationTest.java @@ -38,6 +38,7 @@ import org.apache.james.mailbox.cassandra.mail.CassandraMailboxPathV2DAO; import org.apache.james.mailbox.cassandra.mail.CassandraUserMailboxRightsDAO; import org.apache.james.mailbox.cassandra.modules.CassandraAclModule; import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule; +import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.Mailbox; import org.apache.james.mailbox.model.MailboxPath; import org.assertj.core.api.SoftAssertions; @@ -49,7 +50,6 @@ class MailboxPathV2MigrationTest { private static final MailboxPath MAILBOX_PATH_1 = MailboxPath.forUser(Username.of("bob"), "Important"); private static final int UID_VALIDITY_1 = 452; - private static final Mailbox MAILBOX_1 = new Mailbox(MAILBOX_PATH_1, UID_VALIDITY_1); private static final CassandraId MAILBOX_ID_1 = CassandraId.timeBased(); public static final CassandraModule MODULES = CassandraModule.aggregateModules( @@ -83,13 +83,12 @@ class MailboxPathV2MigrationTest { daoV2, userMailboxRightsDAO, new CassandraACLMapper(cassandra.getConf(), userMailboxRightsDAO, CassandraConfiguration.DEFAULT_CONFIGURATION)); - - MAILBOX_1.setMailboxId(null); } @Test void newValuesShouldBeSavedInMostRecentDAO() throws Exception { - CassandraId mailboxId = (CassandraId) mailboxMapper.create(MAILBOX_1); + Mailbox mailbox = createMailbox(); + CassandraId mailboxId = (CassandraId) mailbox.getMailboxId(); assertThat(daoV2.retrieveId(MAILBOX_PATH_1).blockOptional()) .contains(new CassandraIdAndPath(mailboxId, MAILBOX_PATH_1)); @@ -97,7 +96,7 @@ class MailboxPathV2MigrationTest { @Test void newValuesShouldNotBeSavedInOldDAO() throws Exception { - mailboxMapper.create(MAILBOX_1); + createMailbox(); assertThat(daoV1.retrieveId(MAILBOX_PATH_1).blockOptional()) .isEmpty(); @@ -105,10 +104,10 @@ class MailboxPathV2MigrationTest { @Test void readingOldValuesShouldMigrateThem() throws Exception { - MAILBOX_1.setMailboxId(MAILBOX_ID_1); + Mailbox mailbox = new Mailbox(MAILBOX_PATH_1, UID_VALIDITY_1, MAILBOX_ID_1); daoV1.save(MAILBOX_PATH_1, MAILBOX_ID_1).block(); - mailboxDAO.save(MAILBOX_1).block(); + mailboxDAO.save(mailbox).block(); mailboxMapper.findMailboxByPath(MAILBOX_PATH_1); @@ -131,4 +130,8 @@ class MailboxPathV2MigrationTest { .contains(new CassandraIdAndPath(MAILBOX_ID_1, MAILBOX_PATH_1)); softly.assertAll(); } + + private Mailbox createMailbox() throws MailboxException { + return mailboxMapper.create(MAILBOX_PATH_1, UID_VALIDITY_1); + } } \ No newline at end of file diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java index 6fc69c5..b126711 100644 --- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java +++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndexTest.java @@ -177,8 +177,7 @@ class ElasticSearchListeningMessageSearchIndexTest { messageToElasticSearchJson, sessionProvider, new MailboxIdRoutingKeyFactory()); session = sessionProvider.createSystemSession(USERNAME); - mailbox = new Mailbox(MailboxPath.forUser(USERNAME, DefaultMailboxes.INBOX), MAILBOX_ID.id); - mapperFactory.getMailboxMapper(session).create(mailbox); + mailbox = mapperFactory.getMailboxMapper(session).create(MailboxPath.forUser(USERNAME, DefaultMailboxes.INBOX), MAILBOX_ID.id); } @Test diff --git a/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java b/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java index 5ebbe0a..63bab78 100644 --- a/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java +++ b/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java @@ -85,15 +85,14 @@ class SpamAssassinListenerTest { spamAssassin = mock(SpamAssassin.class); mapperFactory = mailboxManager.getMapperFactory(); MailboxMapper mailboxMapper = mapperFactory.createMailboxMapper(MAILBOX_SESSION); - inbox = new Mailbox(MailboxPath.forUser(USER, DefaultMailboxes.INBOX), UID_VALIDITY); - mailbox1 = new Mailbox(MailboxPath.forUser(USER, "mailbox1"), UID_VALIDITY); - mailbox2 = new Mailbox(MailboxPath.forUser(USER, "mailbox2"), UID_VALIDITY); - mailboxMapper.create(inbox); - mailboxId1 = mailboxMapper.create(mailbox1); - mailboxId2 = mailboxMapper.create(mailbox2); - spamMailboxId = mailboxMapper.create(new Mailbox(MailboxPath.forUser(USER, "Spam"), UID_VALIDITY)); - spamCapitalMailboxId = mailboxMapper.create(new Mailbox(MailboxPath.forUser(USER, "SPAM"), UID_VALIDITY)); - trashMailboxId = mailboxMapper.create(new Mailbox(MailboxPath.forUser(USER, "Trash"), UID_VALIDITY)); + inbox = mailboxMapper.create(MailboxPath.forUser(USER, DefaultMailboxes.INBOX), UID_VALIDITY); + mailbox1 = mailboxMapper.create(MailboxPath.forUser(USER, "mailbox1"), UID_VALIDITY); + mailbox2 = mailboxMapper.create(MailboxPath.forUser(USER, "mailbox2"), UID_VALIDITY); + mailboxId1 = mailbox1.getMailboxId(); + mailboxId2 = mailbox2.getMailboxId(); + spamMailboxId = mailboxMapper.create(MailboxPath.forUser(USER, "Spam"), UID_VALIDITY).getMailboxId(); + spamCapitalMailboxId = mailboxMapper.create(MailboxPath.forUser(USER, "SPAM"), UID_VALIDITY).getMailboxId(); + trashMailboxId = mailboxMapper.create(MailboxPath.forUser(USER, "Trash"), UID_VALIDITY).getMailboxId(); listener = new SpamAssassinListener(spamAssassin, systemMailboxesProvider, mailboxManager, mapperFactory, MailboxListener.ExecutionMode.SYNCHRONOUS); } diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java index 9341913..77eae6b 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java @@ -259,10 +259,6 @@ public class StoreMailboxManager implements MailboxManager { getStoreRightManager(), preDeletionHooks); } - private Mailbox doCreateMailbox(MailboxPath mailboxPath) { - return new Mailbox(mailboxPath, randomUidValidity()); - } - @Override public MessageManager getMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException { @@ -382,20 +378,22 @@ public class StoreMailboxManager implements MailboxManager { List<MailboxId> mailboxIds = new ArrayList<>(); locker.executeWithLock(mailboxPath, (LockAwareExecution<Void>) () -> { if (!mailboxExists(mailboxPath, mailboxSession)) { - Mailbox mailbox = doCreateMailbox(mailboxPath); MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession); try { - mapper.execute(Mapper.toTransaction(() -> mailboxIds.add(mapper.create(mailbox)))); - // notify listeners - eventBus.dispatch(EventFactory.mailboxAdded() - .randomEventId() - .mailboxSession(mailboxSession) - .mailbox(mailbox) - .build(), - new MailboxIdRegistrationKey(mailbox.getMailboxId())) - .block(); + mapper.execute(Mapper.toTransaction(() -> { + Mailbox mailbox = mapper.create(mailboxPath, randomUidValidity()); + mailboxIds.add(mailbox.getMailboxId()); + // notify listeners + eventBus.dispatch(EventFactory.mailboxAdded() + .randomEventId() + .mailboxSession(mailboxSession) + .mailbox(mailbox) + .build(), + new MailboxIdRegistrationKey(mailbox.getMailboxId())) + .block(); + })); } catch (MailboxExistsException e) { - LOGGER.info("{} mailbox was created concurrently", mailbox.generateAssociatedPath()); + LOGGER.info("{} mailbox was created concurrently", mailboxPath.asString()); } } return null; diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java index 0778e6d..408e6ad 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java @@ -54,8 +54,7 @@ public abstract class MailboxMapperACLTest { void setUp() throws Exception { mailboxMapper = createMailboxMapper(); MailboxPath benwaInboxPath = MailboxPath.forUser(Username.of("benwa"), "INBOX"); - benwaInboxMailbox = createMailbox(benwaInboxPath); - mailboxMapper.create(benwaInboxMailbox); + benwaInboxMailbox = mailboxMapper.create(benwaInboxPath, UID_VALIDITY); } @Test @@ -231,11 +230,6 @@ public abstract class MailboxMapperACLTest { .containsEntry(key, rights); } - private Mailbox createMailbox(MailboxPath mailboxPath) { - Mailbox mailbox = new Mailbox(mailboxPath, UID_VALIDITY); - return mailbox; - } - @Test void findMailboxesShouldReturnEmptyWhenNone() throws MailboxException { assertThat(mailboxMapper.findNonPersonalMailboxes(USER, Right.Administer)).isEmpty(); diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java index 28733d0..89ffb3b 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperTest.java @@ -50,22 +50,22 @@ public abstract class MailboxMapperTest { private static final char DELIMITER = '.'; private static final long UID_VALIDITY = 42; private static final Username BENWA = Username.of("benwa"); + private static final MailboxPath benwaInboxPath = MailboxPath.forUser(BENWA, "INBOX"); + private static final MailboxPath benwaWorkPath = MailboxPath.forUser(BENWA, "INBOX" + DELIMITER + "work"); + private static final MailboxPath benwaWorkTodoPath = MailboxPath.forUser(BENWA, "INBOX" + DELIMITER + "work" + DELIMITER + "todo"); + private static final MailboxPath benwaPersoPath = MailboxPath.forUser(BENWA, "INBOX" + DELIMITER + "perso"); + private static final MailboxPath benwaWorkDonePath = MailboxPath.forUser(BENWA, "INBOX" + DELIMITER + "work" + DELIMITER + "done"); + private static final MailboxPath bobInboxPath = MailboxPath.forUser(Username.of("bob"), "INBOX"); + private static final MailboxPath bobyMailboxPath = MailboxPath.forUser(Username.of("boby"), "INBOX.that.is.a.trick"); + private static final MailboxPath bobDifferentNamespacePath = new MailboxPath("#private_bob", Username.of("bob"), "INBOX.bob"); - private MailboxPath benwaInboxPath; private Mailbox benwaInboxMailbox; - private MailboxPath benwaWorkPath; private Mailbox benwaWorkMailbox; - private MailboxPath benwaWorkTodoPath; private Mailbox benwaWorkTodoMailbox; - private MailboxPath benwaPersoPath; private Mailbox benwaPersoMailbox; - private MailboxPath benwaWorkDonePath; private Mailbox benwaWorkDoneMailbox; - private MailboxPath bobInboxPath; private Mailbox bobyMailbox; - private MailboxPath bobyMailboxPath; private Mailbox bobInboxMailbox; - private MailboxPath bobDifferentNamespacePath; private Mailbox bobDifferentNamespaceMailbox; private MailboxMapper mailboxMapper; @@ -77,8 +77,6 @@ public abstract class MailboxMapperTest { @BeforeEach void setUp() { this.mailboxMapper = createMailboxMapper(); - - initData(); } @Test @@ -89,7 +87,7 @@ public abstract class MailboxMapperTest { @Test void createShouldPersistTheMailbox() throws MailboxException { - mailboxMapper.create(benwaInboxMailbox); + benwaInboxMailbox = createMailbox(benwaInboxPath); assertThat(mailboxMapper.findMailboxByPath(benwaInboxPath)).isEqualTo(benwaInboxMailbox); assertThat(mailboxMapper.findMailboxById(benwaInboxMailbox.getMailboxId())).isEqualTo(benwaInboxMailbox); @@ -97,28 +95,17 @@ public abstract class MailboxMapperTest { @Test void createShouldThrowWhenMailboxAlreadyExists() throws MailboxException { - mailboxMapper.create(benwaInboxMailbox); - - Mailbox mailbox = new Mailbox(benwaInboxMailbox); - mailbox.setMailboxId(null); + benwaInboxMailbox = createMailbox(benwaInboxPath); - assertThatThrownBy(() -> mailboxMapper.create(mailbox)) + assertThatThrownBy(() -> createMailbox(benwaInboxPath)) .isInstanceOf(MailboxExistsException.class); } @Test void createShouldSetAMailboxIdForMailbox() throws MailboxException { - MailboxId mailboxId = mailboxMapper.create(benwaInboxMailbox); - - assertThat(mailboxId).isNotNull(); - } - - @Test - void createShouldThrowWhenMailboxIdNotNull() { - benwaInboxMailbox.setMailboxId(generateId()); + benwaInboxMailbox = createMailbox(benwaInboxPath); - assertThatThrownBy(() -> mailboxMapper.create(benwaInboxMailbox)) - .isInstanceOf(IllegalArgumentException.class); + assertThat(benwaInboxMailbox.getMailboxId()).isNotNull(); } @Test @@ -129,9 +116,10 @@ public abstract class MailboxMapperTest { @Test void renameShouldRenameTheMailbox() throws MailboxException { - MailboxId mailboxId = mailboxMapper.create(benwaInboxMailbox); + benwaInboxMailbox = createMailbox(benwaInboxPath); + MailboxId mailboxId = benwaInboxMailbox.getMailboxId(); - benwaWorkMailbox.setMailboxId(mailboxId); + benwaWorkMailbox = new Mailbox(benwaWorkPath, UID_VALIDITY, mailboxId); mailboxMapper.rename(benwaWorkMailbox); assertThat(mailboxMapper.findMailboxById(mailboxId)).isEqualTo(benwaWorkMailbox); @@ -139,7 +127,7 @@ public abstract class MailboxMapperTest { @Test void renameShouldThrowWhenMailboxAlreadyExist() throws MailboxException { - mailboxMapper.create(benwaInboxMailbox); + benwaInboxMailbox = createMailbox(benwaInboxPath); assertThatThrownBy(() -> mailboxMapper.rename(benwaInboxMailbox)) .isInstanceOf(MailboxExistsException.class); @@ -147,7 +135,7 @@ public abstract class MailboxMapperTest { @Test void renameShouldThrowWhenMailboxDoesNotExist() { - benwaInboxMailbox.setMailboxId(generateId()); + benwaInboxMailbox = new Mailbox(benwaInboxPath, UID_VALIDITY, generateId()); assertThatThrownBy(() -> mailboxMapper.rename(benwaInboxMailbox)) .isInstanceOf(MailboxNotFoundException.class); @@ -155,9 +143,9 @@ public abstract class MailboxMapperTest { @Test void renameShouldRemoveOldMailboxPath() throws MailboxException { - MailboxId mailboxId = mailboxMapper.create(benwaInboxMailbox); + MailboxId mailboxId = createMailbox(benwaInboxPath).getMailboxId(); - benwaWorkMailbox.setMailboxId(mailboxId); + benwaWorkMailbox = new Mailbox(benwaWorkPath, UID_VALIDITY, mailboxId); mailboxMapper.rename(benwaWorkMailbox); assertThatThrownBy(() -> mailboxMapper.findMailboxByPath(benwaInboxPath)) @@ -271,16 +259,7 @@ public abstract class MailboxMapperTest { .isInstanceOf(MailboxNotFoundException.class); } - private void initData() { - benwaInboxPath = MailboxPath.forUser(BENWA, "INBOX"); - benwaWorkPath = MailboxPath.forUser(BENWA, "INBOX" + DELIMITER + "work"); - benwaWorkTodoPath = MailboxPath.forUser(BENWA, "INBOX" + DELIMITER + "work" + DELIMITER + "todo"); - benwaPersoPath = MailboxPath.forUser(BENWA, "INBOX" + DELIMITER + "perso"); - benwaWorkDonePath = MailboxPath.forUser(BENWA, "INBOX" + DELIMITER + "work" + DELIMITER + "done"); - bobInboxPath = MailboxPath.forUser(Username.of("bob"), "INBOX"); - bobyMailboxPath = MailboxPath.forUser(Username.of("boby"), "INBOX.that.is.a.trick"); - bobDifferentNamespacePath = new MailboxPath("#private_bob", Username.of("bob"), "INBOX.bob"); - + private void createAll() throws MailboxException { benwaInboxMailbox = createMailbox(benwaInboxPath); benwaWorkMailbox = createMailbox(benwaWorkPath); benwaWorkTodoMailbox = createMailbox(benwaWorkTodoPath); @@ -291,19 +270,8 @@ public abstract class MailboxMapperTest { bobDifferentNamespaceMailbox = createMailbox(bobDifferentNamespacePath); } - private void createAll() throws MailboxException { - mailboxMapper.create(benwaInboxMailbox); - mailboxMapper.create(benwaWorkMailbox); - mailboxMapper.create(benwaWorkTodoMailbox); - mailboxMapper.create(benwaPersoMailbox); - mailboxMapper.create(benwaWorkDoneMailbox); - mailboxMapper.create(bobyMailbox); - mailboxMapper.create(bobDifferentNamespaceMailbox); - mailboxMapper.create(bobInboxMailbox); - } - - private Mailbox createMailbox(MailboxPath mailboxPath) { - return new Mailbox(mailboxPath, UID_VALIDITY); + private Mailbox createMailbox(MailboxPath mailboxPath) throws MailboxException { + return mailboxMapper.create(mailboxPath, UID_VALIDITY); } } diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java index 69329b9..292feea 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageIdMapperTest.java @@ -958,9 +958,7 @@ public abstract class MessageIdMapperTest { } private Mailbox createMailbox(MailboxPath mailboxPath) throws MailboxException { - Mailbox mailbox = new Mailbox(mailboxPath, UID_VALIDITY); - mailboxMapper.create(mailbox); - return mailbox; + return mailboxMapper.create(mailboxPath, UID_VALIDITY); } protected void saveMessages() throws MailboxException { diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java index c558d92..1e4b4e5 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java @@ -1187,11 +1187,7 @@ public abstract class MessageMapperTest { } private Mailbox createMailbox(MailboxPath mailboxPath) throws MailboxException { - Mailbox mailbox = new Mailbox(mailboxPath, UID_VALIDITY); - - mailboxMapper.create(mailbox); - - return mailbox; + return mailboxMapper.create(mailboxPath, UID_VALIDITY); } private void saveMessages() throws MailboxException { diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMoveTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMoveTest.java index 61b084e..f0ddc85 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMoveTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMoveTest.java @@ -134,10 +134,7 @@ public abstract class MessageMoveTest { } private Mailbox createMailbox(MailboxPath mailboxPath) throws MailboxException { - Mailbox mailbox = new Mailbox(mailboxPath, UID_VALIDITY); - mailboxMapper.create(mailbox); - - return mailbox; + return mailboxMapper.create(mailboxPath, UID_VALIDITY); } private MailboxMessage retrieveMessageFromStorage(Mailbox mailbox, MailboxMessage message) throws MailboxException { diff --git a/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java b/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java index cf64cf1..c1ab9e9 100644 --- a/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java +++ b/server/container/mailbox-jmx/src/test/java/org/apache/james/adapter/mailbox/MailboxManagementTest.java @@ -38,6 +38,7 @@ import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.MessageRange; import org.apache.james.mailbox.store.MailboxSessionMapperFactory; import org.apache.james.mailbox.store.StoreMailboxManager; +import org.apache.james.mailbox.store.mail.MailboxMapper; import org.apache.james.mailbox.store.mail.MessageMapper; import org.apache.james.mailbox.store.mail.model.MailboxMessage; import org.junit.jupiter.api.BeforeEach; @@ -65,44 +66,42 @@ public class MailboxManagementTest { @Test void deleteMailboxesShouldDeleteMailboxes() throws Exception { - mapperFactory.createMailboxMapper(session).create(new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY)); + mapperFactory.createMailboxMapper(session).create(MailboxPath.forUser(USER, "name"), UID_VALIDITY); mailboxManagerManagement.deleteMailboxes(USER.asString()); assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty(); } @Test void deleteMailboxesShouldDeleteInbox() throws Exception { - mapperFactory.createMailboxMapper(session).create(new Mailbox(MailboxPath.inbox(USER), UID_VALIDITY)); + mapperFactory.createMailboxMapper(session).create(MailboxPath.inbox(USER), UID_VALIDITY); mailboxManagerManagement.deleteMailboxes(USER.asString()); assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty(); } @Test void deleteMailboxesShouldDeleteMailboxesChildren() throws Exception { - mapperFactory.createMailboxMapper(session).create(new Mailbox(MailboxPath.forUser(USER, "INBOX.test"), UID_VALIDITY)); + mapperFactory.createMailboxMapper(session).create(MailboxPath.forUser(USER, "INBOX.test"), UID_VALIDITY); mailboxManagerManagement.deleteMailboxes(USER.asString()); assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty(); } @Test void deleteMailboxesShouldNotDeleteMailboxesBelongingToNotPrivateNamespace() throws Exception { - Mailbox mailbox = new Mailbox(new MailboxPath("#top", USER, "name"), UID_VALIDITY); - mapperFactory.createMailboxMapper(session).create(mailbox); + Mailbox mailbox = mapperFactory.createMailboxMapper(session).create(new MailboxPath("#top", USER, "name"), UID_VALIDITY); mailboxManagerManagement.deleteMailboxes(USER.asString()); assertThat(mapperFactory.createMailboxMapper(session).list()).containsExactly(mailbox); } @Test void deleteMailboxesShouldNotDeleteMailboxesBelongingToOtherUsers() throws Exception { - Mailbox mailbox = new Mailbox(MailboxPath.forUser(Username.of("userbis"), "name"), UID_VALIDITY); - mapperFactory.createMailboxMapper(session).create(mailbox); + Mailbox mailbox = mapperFactory.createMailboxMapper(session).create(MailboxPath.forUser(Username.of("userbis"), "name"), UID_VALIDITY); mailboxManagerManagement.deleteMailboxes(USER.asString()); assertThat(mapperFactory.createMailboxMapper(session).list()).containsExactly(mailbox); } @Test void deleteMailboxesShouldDeleteMailboxesWithEmptyNames() throws Exception { - mapperFactory.createMailboxMapper(session).create(new Mailbox(MailboxPath.forUser(USER, ""), UID_VALIDITY)); + mapperFactory.createMailboxMapper(session).create(MailboxPath.forUser(USER, ""), UID_VALIDITY); mailboxManagerManagement.deleteMailboxes(USER.asString()); assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty(); } @@ -121,9 +120,9 @@ public class MailboxManagementTest { @Test void deleteMailboxesShouldDeleteMultipleMailboxes() throws Exception { - mapperFactory.createMailboxMapper(session).create(new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY)); - mapperFactory.createMailboxMapper(session).create(new Mailbox(MailboxPath.forUser(USER, "INBOX"), UID_VALIDITY)); - mapperFactory.createMailboxMapper(session).create(new Mailbox(MailboxPath.forUser(USER, "INBOX.test"), UID_VALIDITY)); + mapperFactory.createMailboxMapper(session).create(MailboxPath.forUser(USER, "name"), UID_VALIDITY); + mapperFactory.createMailboxMapper(session).create(MailboxPath.forUser(USER, "INBOX"), UID_VALIDITY); + mapperFactory.createMailboxMapper(session).create(MailboxPath.forUser(USER, "INBOX.test"), UID_VALIDITY); mailboxManagerManagement.deleteMailboxes(USER.asString()); assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty(); } @@ -138,8 +137,7 @@ public class MailboxManagementTest { @Test void createMailboxShouldThrowIfMailboxAlreadyExists() throws Exception { MailboxPath path = MailboxPath.forUser(USER, "name"); - Mailbox mailbox = new Mailbox(path, UID_VALIDITY); - mapperFactory.createMailboxMapper(session).create(mailbox); + mapperFactory.createMailboxMapper(session).create(path, UID_VALIDITY); assertThatThrownBy(() -> mailboxManagerManagement.createMailbox(MailboxConstants.USER_NAMESPACE, USER.asString(), "name")) .isInstanceOf(RuntimeException.class) @@ -149,8 +147,7 @@ public class MailboxManagementTest { @Test void createMailboxShouldNotCreateAdditionalMailboxesIfMailboxAlreadyExists() throws Exception { MailboxPath path = MailboxPath.forUser(USER, "name"); - Mailbox mailbox = new Mailbox(path, UID_VALIDITY); - mapperFactory.createMailboxMapper(session).create(mailbox); + Mailbox mailbox = mapperFactory.createMailboxMapper(session).create(path, UID_VALIDITY); assertThat(mapperFactory.createMailboxMapper(session).list()).containsExactly(mailbox); } @@ -193,18 +190,13 @@ public class MailboxManagementTest { @Test void listMailboxesShouldReturnUserMailboxes() throws Exception { - Mailbox mailbox1 = new Mailbox(new MailboxPath("#top", USER, "name1"), UID_VALIDITY); - Mailbox mailbox2 = new Mailbox(MailboxPath.forUser(USER, "name2"), UID_VALIDITY); - Mailbox mailbox3 = new Mailbox(MailboxPath.forUser(Username.of("other_user"), "name3"), UID_VALIDITY); - Mailbox mailbox4 = new Mailbox(MailboxPath.forUser(USER, "name4"), UID_VALIDITY); - Mailbox mailbox5 = new Mailbox(MailboxPath.forUser(USER, "INBOX"), UID_VALIDITY); - Mailbox mailbox6 = new Mailbox(MailboxPath.forUser(USER, "INBOX.toto"), UID_VALIDITY); - mapperFactory.createMailboxMapper(session).create(mailbox1); - mapperFactory.createMailboxMapper(session).create(mailbox2); - mapperFactory.createMailboxMapper(session).create(mailbox3); - mapperFactory.createMailboxMapper(session).create(mailbox4); - mapperFactory.createMailboxMapper(session).create(mailbox5); - mapperFactory.createMailboxMapper(session).create(mailbox6); + MailboxMapper mapper = mapperFactory.createMailboxMapper(session); + mapper.create(new MailboxPath("#top", USER, "name1"), UID_VALIDITY); + mapper.create(MailboxPath.forUser(USER, "name2"), UID_VALIDITY); + mapper.create(MailboxPath.forUser(Username.of("other_user"), "name3"), UID_VALIDITY); + mapper.create(MailboxPath.forUser(USER, "name4"), UID_VALIDITY); + mapper.create(MailboxPath.forUser(USER, "INBOX"), UID_VALIDITY); + mapper.create(MailboxPath.forUser(USER, "INBOX.toto"), UID_VALIDITY); assertThat(mailboxManagerManagement.listMailboxes(USER.asString())).containsOnly("name2", "name4", "INBOX", "INBOX.toto"); } @@ -222,40 +214,35 @@ public class MailboxManagementTest { @Test void deleteMailboxShouldDeleteGivenMailbox() throws Exception { - mapperFactory.createMailboxMapper(session).create(new Mailbox(MailboxPath.forUser(USER, "name"), UID_VALIDITY)); + mapperFactory.createMailboxMapper(session).create(MailboxPath.forUser(USER, "name"), UID_VALIDITY); mailboxManagerManagement.deleteMailbox(MailboxConstants.USER_NAMESPACE, USER.asString(), "name"); assertThat(mapperFactory.createMailboxMapper(session).list()).isEmpty(); } @Test void deleteMailboxShouldNotDeleteGivenMailboxIfWrongNamespace() throws Exception { - Mailbox mailbox = new Mailbox(new MailboxPath("#top", USER, "name"), UID_VALIDITY); - mapperFactory.createMailboxMapper(session).create(mailbox); + Mailbox mailbox = mapperFactory.createMailboxMapper(session).create(new MailboxPath("#top", USER, "name"), UID_VALIDITY); mailboxManagerManagement.deleteMailbox(MailboxConstants.USER_NAMESPACE, USER.asString(), "name"); assertThat(mapperFactory.createMailboxMapper(session).list()).containsOnly(mailbox); } @Test void deleteMailboxShouldNotDeleteGivenMailboxIfWrongUser() throws Exception { - Mailbox mailbox = new Mailbox(MailboxPath.forUser(Username.of("userbis"), "name"), UID_VALIDITY); - mapperFactory.createMailboxMapper(session).create(mailbox); + Mailbox mailbox = mapperFactory.createMailboxMapper(session).create(MailboxPath.forUser(Username.of("userbis"), "name"), UID_VALIDITY); mailboxManagerManagement.deleteMailbox(MailboxConstants.USER_NAMESPACE, USER.asString(), "name"); assertThat(mapperFactory.createMailboxMapper(session).list()).containsOnly(mailbox); } @Test void deleteMailboxShouldNotDeleteGivenMailboxIfWrongName() throws Exception { - Mailbox mailbox = new Mailbox(MailboxPath.forUser(USER, "wrong_name"), UID_VALIDITY); - mapperFactory.createMailboxMapper(session).create(mailbox); + Mailbox mailbox = mapperFactory.createMailboxMapper(session).create(MailboxPath.forUser(USER, "wrong_name"), UID_VALIDITY); mailboxManagerManagement.deleteMailbox(MailboxConstants.USER_NAMESPACE, USER.asString(), "name"); assertThat(mapperFactory.createMailboxMapper(session).list()).containsOnly(mailbox); } @Test void importEmlFileToMailboxShouldImportEmlFileToGivenMailbox() throws Exception { - Mailbox mailbox = new Mailbox(MailboxPath.forUser(USER, "name"), - UID_VALIDITY); - mapperFactory.createMailboxMapper(session).create(mailbox); + Mailbox mailbox = mapperFactory.createMailboxMapper(session).create(MailboxPath.forUser(USER, "name"), UID_VALIDITY); String emlpath = ClassLoader.getSystemResource("eml/frnog.eml").getFile(); mailboxManagerManagement.importEmlFileToMailbox(MailboxConstants.USER_NAMESPACE, USER.asString(), "name", emlpath); @@ -270,9 +257,7 @@ public class MailboxManagementTest { @Test void importEmlFileToMailboxShouldNotImportEmlFileWithWrongPathToGivenMailbox() throws Exception { - Mailbox mailbox = new Mailbox(MailboxPath.forUser(USER, "name"), - UID_VALIDITY); - mapperFactory.createMailboxMapper(session).create(mailbox); + Mailbox mailbox = mapperFactory.createMailboxMapper(session).create(MailboxPath.forUser(USER, "name"), UID_VALIDITY); String emlpath = ClassLoader.getSystemResource("eml/frnog.eml").getFile(); mailboxManagerManagement.importEmlFileToMailbox(MailboxConstants.USER_NAMESPACE, USER.asString(), "name", "wrong_path" + emlpath); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
