You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2021/11/25 09:51:20 UTC

[GitHub] [james-project] quantranhong1999 commented on a change in pull request #757: JAMES-3534 Identity/set update should work on existing server-set Identities

quantranhong1999 commented on a change in pull request #757:
URL: https://github.com/apache/james-project/pull/757#discussion_r756731336



##########
File path: server/data/data-jmap/src/test/scala/org/apache/james/jmap/api/identity/IdentityRepositoryTest.scala
##########
@@ -135,11 +134,47 @@ class IdentityRepositoryTest {
   @Test
   def updateShouldSuccessWhenCustomExists(): Unit = {
     when(identityFactory.listIdentities(BOB)).thenReturn(List())
-    SMono.fromPublisher(customIdentityDAO.save(BOB, CREATION_REQUEST)).block()
-    val identity: Identity = SFlux(customIdentityDAO.list(BOB)).blockFirst().get
+    val customIdentity: Identity = SMono.fromPublisher(customIdentityDAO.save(BOB, CREATION_REQUEST)).block()
 
-    assertThatCode(() => SMono.fromPublisher(testee.update(BOB, identity.id, UPDATE_REQUEST)).block())
+    assertThatCode(() => SMono.fromPublisher(testee.update(BOB, customIdentity.id, UPDATE_REQUEST)).block())
       .doesNotThrowAnyException()
   }
 
+  @Test
+  def updateShouldModifiedEntry(): Unit = {
+    when(identityFactory.listIdentities(BOB)).thenReturn(List())
+    val customIdentity: Identity = SMono.fromPublisher(customIdentityDAO.save(BOB, CREATION_REQUEST)).block()
+
+    assertThatCode(() => SMono.fromPublisher(testee.update(BOB, customIdentity.id, UPDATE_REQUEST)).block())
+      .doesNotThrowAnyException()
+
+    assertThat(SFlux(testee.list(BOB)).collectSeq().block().asJava)
+      .containsExactlyInAnyOrder(Identity(id = customIdentity.id,
+        name = IdentityName("Bob (new name)"),
+        email = BOB.asMailAddress(),
+        replyTo = Some(List(EmailAddress(Some(EmailerName("My Boss (updated)")), new MailAddress("boss-updated@domain.tld")))),
+        bcc = Some(List(EmailAddress(Some(EmailerName("My Boss 2 (updated)")), new MailAddress("boss-updated-2@domain.tld")))),
+        textSignature = TextSignature("text 2 signature"),
+        htmlSignature = HtmlSignature("html 2 signature"),
+        mayDelete = MayDeleteIdentity(true)))
+  }
+
+  @Test
+  def updateShouldSuccessWhenMultiUpdateServerSetId(): Unit = {
+    when(identityFactory.listIdentities(BOB)).thenReturn(List(IDENTITY1))
+    SMono.fromPublisher(testee.update(BOB, IDENTITY1.id, UPDATE_REQUEST)).block()
+
+    assertThatCode(() => SMono.fromPublisher(testee.update(BOB, IDENTITY1.id, UPDATE_REQUEST.copy(name = Some(IdentityNameUpdate(IdentityName("Bob (3)")))))).block())
+      .doesNotThrowAnyException()
+
+    assertThat(SFlux(testee.list(BOB)).collectSeq().block().asJava)
+      .containsExactlyInAnyOrder(Identity(id = IDENTITY1.id,
+        name = IdentityName("Bob (3)"),
+        email = BOB.asMailAddress(),
+        replyTo = Some(List(EmailAddress(Some(EmailerName("My Boss (updated)")), new MailAddress("boss-updated@domain.tld")))),
+        bcc = Some(List(EmailAddress(Some(EmailerName("My Boss 2 (updated)")), new MailAddress("boss-updated-2@domain.tld")))),
+        textSignature = TextSignature("text 2 signature"),
+        htmlSignature = HtmlSignature("html 2 signature"),
+        mayDelete = MayDeleteIdentity(true)))
+  }

Review comment:
       Maybe this is what Benoit suggests?
   ```scala
   @Test
     def updateShouldSuccessWhenSecondPartialUpdateServerSetId(): Unit = {
       when(identityFactory.listIdentities(BOB)).thenReturn(List(IDENTITY1))
       SMono.fromPublisher(testee.update(BOB, IDENTITY1.id, UPDATE_REQUEST)).block()
       val secondUpdateWithName = IdentityUpdateRequest(name = Some(IdentityNameUpdate(IdentityName("Bob (3)"))), None, None,None, None)
   
       assertThatCode(() => SMono.fromPublisher(testee.update(BOB, IDENTITY1.id, secondUpdateWithName)).block())
         .doesNotThrowAnyException()
   
       assertThat(SFlux(testee.list(BOB)).collectSeq().block().asJava)
         .containsExactlyInAnyOrder(Identity(id = IDENTITY1.id,
           name = IdentityName("Bob (3)"),
           email = BOB.asMailAddress(),
           replyTo = Some(List(EmailAddress(Some(EmailerName("My Boss (updated)")), new MailAddress("boss-updated@domain.tld")))),
           bcc = Some(List(EmailAddress(Some(EmailerName("My Boss 2 (updated)")), new MailAddress("boss-updated-2@domain.tld")))),
           textSignature = TextSignature("text 2 signature"),
           htmlSignature = HtmlSignature("html 2 signature"),
           mayDelete = MayDeleteIdentity(true)))
     }
   ```




-- 
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