You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by "Arsnael (via GitHub)" <gi...@apache.org> on 2023/03/20 04:31:35 UTC

[GitHub] [james-project] Arsnael commented on a diff in pull request #1492: JAMES-3885 - Change username - should migrate succeed when mailboxes from old user already exist on the new user

Arsnael commented on code in PR #1492:
URL: https://github.com/apache/james-project/pull/1492#discussion_r1141611928


##########
server/container/mailbox-adapter/src/test/java/org/apache/james/adapter/mailbox/MailboxUsernameChangeTaskStepTest.java:
##########
@@ -147,4 +151,51 @@ void shouldTransferSubscriptionToNewUser() throws Exception {
         assertThat(subscriptionManager.subscriptions(mailboxManager.createSystemSession(BOB)))
             .containsOnly(MailboxPath.forUser(BOB, "subscribed"));
     }
+
+    @Test
+    void shouldMigrateMailboxesWhenNewUserHasAlreadyMailbox() throws Exception {
+        MailboxSession aliceSession = mailboxManager.createSystemSession(ALICE);
+        MailboxSession bobSession = mailboxManager.createSystemSession(BOB);
+        MailboxPath aliceInbox = MailboxPath.inbox(ALICE);
+        MailboxPath bobInbox = MailboxPath.inbox(BOB);
+        mailboxManager.createMailbox(aliceInbox, MailboxManager.CreateOption.NONE, aliceSession);
+        mailboxManager.createMailbox(bobInbox, MailboxManager.CreateOption.NONE, bobSession);
+
+        mailboxManager.getMailbox(aliceInbox, aliceSession)
+            .appendMessage(MessageManager.AppendCommand.from(Message.Builder.of()
+                .setSubject("toto")
+                .setBody("alice33333", StandardCharsets.UTF_8)
+                .build()), aliceSession);
+
+        mailboxManager.getMailbox(bobInbox, bobSession)
+            .appendMessage(MessageManager.AppendCommand.from(Message.Builder.of()
+                .setSubject("toto")
+                .setBody("bob", StandardCharsets.UTF_8)
+                .build()), bobSession);
+
+        Mono.from(testee.changeUsername(ALICE, BOB)).block();
+
+        assertThat(mailboxManager.getMailbox(bobInbox, bobSession).getMessageCount(bobSession))
+            .isEqualTo(2);
+
+        assertThat(mailboxManager.list(bobSession)).containsOnly(bobInbox);
+    }
+
+    @Test
+    void shouldMigrateSubMailboxesWhenNewUserHasAlreadyMailbox() throws Exception {

Review Comment:
   I thought your change was supposed to be able to do the migration when mailboxes have the same name? I don't get your comment sorry



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org