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


The following commit(s) were added to refs/heads/master by this push:
     new 00a4ef8e6f JAMES-4077 Add a BackReference test for SearchSnippet/get
00a4ef8e6f is described below

commit 00a4ef8e6f6bf10fd8c5afea636d0a0b88c28bbe
Author: Quan Tran <hqt...@linagora.com>
AuthorDate: Thu Nov 14 14:43:03 2024 +0700

    JAMES-4077 Add a BackReference test for SearchSnippet/get
---
 .../contract/SearchSnippetGetMethodContract.scala  | 91 ++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/SearchSnippetGetMethodContract.scala
 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/SearchSnippetGetMethodContract.scala
index 696272c801..f25a1d7d2c 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/SearchSnippetGetMethodContract.scala
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/SearchSnippetGetMethodContract.scala
@@ -198,6 +198,97 @@ trait SearchSnippetGetMethodContract {
     }
   }
 
+  @Test
+  def searchSnippetGetShouldSupportBackReference(server: GuiceJamesServer): 
Unit = {
+    
server.getProbe(classOf[MailboxProbeImpl]).createMailbox(MailboxPath.inbox(BOB))
+    val messageId = server.getProbe(classOf[MailboxProbeImpl])
+      .appendMessage(BOB.asString, MailboxPath.inbox(BOB), 
AppendCommand.builder().build(
+        Message.Builder
+          .of
+          .setBody("You can close this page and return to the IDE intellij", 
StandardCharsets.UTF_8)
+          .setSubject("Yet another day in paradise")
+          .build))
+      .getMessageId
+
+    val request: String =
+      s"""{
+         |    "using": [
+         |        "urn:ietf:params:jmap:core",
+         |        "urn:ietf:params:jmap:mail"
+         |    ],
+         |    "methodCalls": [
+         |        [
+         |            "Email/query",
+         |            {
+         |                "accountId": "$ACCOUNT_ID",
+         |                "filter": {
+         |                    "body": "IDE"
+         |                },
+         |                "sort": [
+         |                    {
+         |                        "isAscending": false,
+         |                        "property": "receivedAt"
+         |                    }
+         |                ],
+         |                "limit": 20
+         |            },
+         |            "c0"
+         |        ],
+         |        [
+         |            "SearchSnippet/get",
+         |            {
+         |                "accountId": "$ACCOUNT_ID",
+         |                "filter": {
+         |                    "body": "IDE"
+         |                },
+         |                "#emailIds": {
+         |                    "resultOf": "c0",
+         |                    "name": "Email/query",
+         |                    "path": "/ids/*"
+         |                }
+         |            },
+         |            "c1"
+         |        ]
+         |    ]
+         |}""".stripMargin
+
+    awaitAtMostTenSeconds.untilAsserted { () =>
+      val response: ResponseBodyExtractionOptions = `given`
+        .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+        .body(request)
+      .when
+        .post
+      .`then`
+        .statusCode(SC_OK)
+        .contentType(JSON)
+        .extract()
+        .body
+
+      assertThatJson(response.asString())
+        .withOptions(IGNORING_ARRAY_ORDER)
+        .inPath("methodResponses[1]")
+        .isEqualTo(
+          s"""[
+             |  "SearchSnippet/get",
+             |  {
+             |    "accountId": "$ACCOUNT_ID",
+             |    "list": [
+             |      {
+             |        "emailId": "${messageId.serialize}",
+             |        "subject": null,
+             |        "preview": "$${json-unit.ignore}"
+             |      }
+             |    ],
+             |    "notFound": []
+             |  },
+             |  "c1"
+             |]""".stripMargin)
+
+      
assertThat(response.jsonPath().get("methodResponses[1][1].list[0].preview").toString)
+        .contains("return to the <mark>IDE</mark> intellij")
+    }
+  }
+
   @Test
   def searchSnippetShouldAcceptSharedMailboxesWhenExtension(server: 
GuiceJamesServer): Unit = {
     // Given: andres inbox with a message


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

Reply via email to