quantranhong1999 commented on code in PR #2902:
URL: https://github.com/apache/james-project/pull/2902#discussion_r2667682805
##########
mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/blob/BlobStoreDeletedMessageVaultTest.java:
##########
@@ -163,4 +173,67 @@ void
deleteExpiredMessagesTaskShouldPublishRetentionTimerMetrics() throws Except
assertThat(metricFactory.executionTimesFor(DELETE_EXPIRED_MESSAGES_METRIC_NAME))
.hasSize(1);
}
+
+ @Test
+ public void loadMimeMessageShouldReturnOldMessage() {
+ Mono.from(getVault().appendV1(DELETED_MESSAGE, new
ByteArrayInputStream(CONTENT))).block();
+
+ assertThat(Mono.from(getVault().loadMimeMessage(USERNAME,
MESSAGE_ID)).blockOptional())
+ .isNotEmpty()
+ .satisfies(maybeContent ->
assertThat(maybeContent.get()).hasSameContentAs(new
ByteArrayInputStream(CONTENT)));
+ }
+
+ @Test
+ public void loadMimeMessageShouldReturnEmptyWhenOldMessageDeleted() {
+ Mono.from(getVault().appendV1(DELETED_MESSAGE, new
ByteArrayInputStream(CONTENT))).block();
+
+ Mono.from(getVault().delete(USERNAME, MESSAGE_ID)).block();
+
+ assertThat(Mono.from(getVault().loadMimeMessage(USERNAME,
MESSAGE_ID)).blockOptional())
+ .isEmpty();
+ }
+
+ @Test
+ public void searchAllShouldReturnOldMessage() {
+ Mono.from(getVault().appendV1(DELETED_MESSAGE, new
ByteArrayInputStream(CONTENT))).block();
+
+ assertThat(Flux.from(getVault().search(USERNAME,
ALL)).collectList().block())
+ .containsOnly(DELETED_MESSAGE);
+ }
+
+ @Test
+ public void searchAllShouldReturnOldAndNewMessages() {
+ Mono.from(getVault().appendV1(DELETED_MESSAGE, new
ByteArrayInputStream(CONTENT))).block();
+ Mono.from(getVault().appendV1(DELETED_MESSAGE_2, new
ByteArrayInputStream(CONTENT))).block();
+
+ assertThat(Flux.from(getVault().search(USERNAME,
ALL)).collectList().block())
+ .containsOnly(DELETED_MESSAGE, DELETED_MESSAGE_2);
+ }
+
+ @Test
+ public void searchAllShouldSupportLimitQueryWithOldAndNewMessages() {
+ Mono.from(getVault().appendV1(DELETED_MESSAGE, new
ByteArrayInputStream(CONTENT))).block();
+ Mono.from(getVault().appendV1(DELETED_MESSAGE_2, new
ByteArrayInputStream(CONTENT))).block();
+ DeletedMessage deletedMessage3 =
DELETED_MESSAGE_GENERATOR.apply(InMemoryMessageId.of(33).getRawId());
+ Mono.from(getVault().appendV1(deletedMessage3, new
ByteArrayInputStream(CONTENT))).block();
Review Comment:
`append` ?
##########
mailbox/plugin/deleted-messages-vault/src/test/java/org/apache/james/vault/blob/BlobStoreDeletedMessageVaultTest.java:
##########
@@ -163,4 +173,67 @@ void
deleteExpiredMessagesTaskShouldPublishRetentionTimerMetrics() throws Except
assertThat(metricFactory.executionTimesFor(DELETE_EXPIRED_MESSAGES_METRIC_NAME))
.hasSize(1);
}
+
+ @Test
+ public void loadMimeMessageShouldReturnOldMessage() {
+ Mono.from(getVault().appendV1(DELETED_MESSAGE, new
ByteArrayInputStream(CONTENT))).block();
+
+ assertThat(Mono.from(getVault().loadMimeMessage(USERNAME,
MESSAGE_ID)).blockOptional())
+ .isNotEmpty()
+ .satisfies(maybeContent ->
assertThat(maybeContent.get()).hasSameContentAs(new
ByteArrayInputStream(CONTENT)));
+ }
+
+ @Test
+ public void loadMimeMessageShouldReturnEmptyWhenOldMessageDeleted() {
+ Mono.from(getVault().appendV1(DELETED_MESSAGE, new
ByteArrayInputStream(CONTENT))).block();
+
+ Mono.from(getVault().delete(USERNAME, MESSAGE_ID)).block();
+
+ assertThat(Mono.from(getVault().loadMimeMessage(USERNAME,
MESSAGE_ID)).blockOptional())
+ .isEmpty();
+ }
+
+ @Test
+ public void searchAllShouldReturnOldMessage() {
+ Mono.from(getVault().appendV1(DELETED_MESSAGE, new
ByteArrayInputStream(CONTENT))).block();
+
+ assertThat(Flux.from(getVault().search(USERNAME,
ALL)).collectList().block())
+ .containsOnly(DELETED_MESSAGE);
+ }
+
+ @Test
+ public void searchAllShouldReturnOldAndNewMessages() {
+ Mono.from(getVault().appendV1(DELETED_MESSAGE, new
ByteArrayInputStream(CONTENT))).block();
+ Mono.from(getVault().appendV1(DELETED_MESSAGE_2, new
ByteArrayInputStream(CONTENT))).block();
Review Comment:
```suggestion
Mono.from(getVault().append(DELETED_MESSAGE_2, new
ByteArrayInputStream(CONTENT))).block();
```
to append the new message?
--
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]