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


##########
server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxUsernameChangeTaskStep.java:
##########
@@ -76,11 +77,35 @@ public Publisher<Void> changeUsername(Username oldUsername, 
Username newUsername
 
     private Mono<Void> migrateMailbox(MailboxSession fromSession, 
MailboxSession toSession, org.apache.james.mailbox.model.MailboxMetaData 
mailbox) {
         MailboxPath renamedPath = 
mailbox.getPath().withUser(toSession.getUser());
-        return mailboxManager.renameMailboxReactive(mailbox.getPath(), 
renamedPath,
-            MailboxManager.RenameOption.RENAME_SUBSCRIPTIONS,
-            fromSession, toSession)
+        Mono<Void> renamePublisher = 
mailboxManager.renameMailboxReactive(mailbox.getPath(), renamedPath,

Review Comment:
   I feel that could be just extracted into a function directly? 



##########
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:
   If I understand correctly, Bob and Alice don't have the same mailboxes here 
though, so it's not really an already mailbox exists use case?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to